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

Introduce TTL option for dynamic queues #8

Open
lrascao opened this issue Jun 30, 2015 · 2 comments
Open

Introduce TTL option for dynamic queues #8

lrascao opened this issue Jun 30, 2015 · 2 comments

Comments

@lrascao
Copy link
Contributor

lrascao commented Jun 30, 2015

Since the possibility of dynamic queues, we are now able to have a lot of them (one per user for example), they all make use of timers to replenish their token buckets so this may introduce heavy load on pre-OTP18 timer wheels. Perhaps a TTL option could be provided to the queue upon creation, after this TTL expires the queue dies. This implies that the queue creator must be made aware of this and invalidate it's reference to the queue, could this be an interesting option? i'm available to put forward a PR with this

@jlouis
Copy link
Owner

jlouis commented Jun 30, 2015

This is a nice idea. What is your implementation strategy, before embarking on it?

@jlouis
Copy link
Owner

jlouis commented Jun 30, 2015

Ok, having given this some thought:

Observation 1:

We don't need to poll all the time. We just need to poll as long as there is a flow and the token bucket is not full. Once the bucket fills up, there is nothing to do until someone invokes the queue and makes changes on the queue. In turn, idle queues will not need any kind of extra work.

Observation 2:

Building on Observation 1, it is easy to add a timeout by simply using the form {noreply, State, State#state.idle_timeout}. If this triggers, we can close down the queue.

Observation 3:

If we want to watch a queue, it is desirable to do so by using a monitor. This is safe, insofar the monitoring client will always be notified if the queue disappears. We should probably shut down with {shutdown, idle} to notify the user of the monitor the exit reason in a graceful way. This behaviour should also be documented.

I'm not sure how far back {shutdown, Term} is supported. This should be checked, but I'd hope at least release 17 supports it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants