Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support MRU poll order for idle resources #87

Closed
simonbasle opened this issue Jul 21, 2020 · 1 comment
Closed

Support MRU poll order for idle resources #87

simonbasle opened this issue Jul 21, 2020 · 1 comment
Assignees
Labels
status/need-design This needs more in depth design work type/enhancement A general enhancement
Milestone

Comments

@simonbasle
Copy link
Contributor

simonbasle commented Jul 21, 2020

Motivation

There is currently two flavors of pools, fifo and lifo, but these attributes apply to the order in which pending acquire() are served once a resource becomes available (ie no resource is available and no resource can be created, but several acquire() are attempted).

The reverse situation where resources are idle in the pool when a single acquire() comes in is not impacted by this parameter. Instead, provided there is no pending acquires, the pool always produces idle resources in "fifo" insertion order (effectively equivalent to a Least-Recently-Used order)

Desired solution

Add a way to tune the order in which idle resources are chosen when a new acquire() comes in. At a minimum, the following use case should be covered:

When dealing with a TCP Connection, some remote servers may close the connection if it has been inactive for too long. To avoid even receiving this kind of errors entirely, using a MRU (Most-Recently-Used) order when polling for an idle resource could be beneficial.

This should be achievable by either using a Deque (on which we would either call pollFirst() or pollLast() or some form of PriorityQueue (see #88).

Moving aways from the Reactor MPSC queue also enables iteration, a pre-requisite for background eviction (#86)

Challenges

  • The current implementation uses a lock-free MPSC unbounded queue. The alternative must be efficient enough to stand the comparison with that structure.
  • Under low demand, a MRU scheme would mean old connections have less chances to be visited, which also means that they will linger in the queue and won't get evicted. This makes Provide automatic background eviction of pooled objects #86 (background eviction) even more important to have, since this increases the symptoms of low pool utilization.
@simonbasle simonbasle added type/enhancement A general enhancement status/need-design This needs more in depth design work labels Jul 21, 2020
@simonbasle simonbasle self-assigned this Jul 21, 2020
@simonbasle simonbasle added this to the 0.1.x Backlog milestone Jul 21, 2020
@simonbasle
Copy link
Contributor Author

Since there is no efficient non-blocking implementation of a PriorityQueue and since fifo/lifo is enough to implement LRU/MRU usage of idle resources, this issue will focus on LRU/MRU. See #88

@simonbasle simonbasle changed the title Add a way to tune poll order for idle resources Support MRU poll order for idle resources Jul 22, 2020
simonbasle added a commit that referenced this issue Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/need-design This needs more in depth design work type/enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant