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

Batch send_after/3 calls #2

Draft
wants to merge 2 commits into
base: tgrk_master
Choose a base branch
from
Draft

Conversation

aboroska
Copy link

@aboroska aboroska commented Sep 4, 2023

Starting a timer for each item in the cache can be resource intensive and might even reach the capabilities of the VM with a high enough number of items.

Add an option to batch the send_after/3 calls per TTL interval by buffering them for a while in the gen_server's state and sent in one batch per TTL interval. The configuration variable is called: buffer_limit and denotes the maximum length of this internal buffer.

A regular tick event is also added to make sure that the TTL timers are started even when the number of new items do not fill the buffer in a given tick interval set by the configuration variable: expiry_tick_ms.

To keep the implementation simple all the buffered TTL intervals are emptied at each tick.

By not setting the new configuration variable buffer_limit the behaviour remains as it was before: an expiration timer is started for each new item when expriry set other than infinity.

Starting a timer for each item in the cache can be resource intensive
and might even reach the capabilities of the VM with a high enough
number of items.

Add an option to batch the send_after/3 calls per TTL interval by
buffering them for a while in the gen_server's state and sent in one
batch per TTL interval. The configuration variable is called:
`buffer_limit` and denotes the maximum length of this internal buffer.

A regular tick event is also added to make sure that the TTL timers are
started even when the number of new items do not fill the buffer in a
given tick interval set by the configuration variable: `expiry_tick_ms`.

To keep the implementation simple all the buffered TTL intervals are
emptied at each tick.

By not setting the new configuration variable `buffer_limit` the
behaviour remains as it was before: an expiration timer is started for
each new item when expriry set other than infinity.
@aboroska aboroska requested review from a team and legoscia and removed request for a team and legoscia September 4, 2023 10:47
Co-authored-by: Jonathan Prouse <jonathan@gameanalytics.com>
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

Successfully merging this pull request may close these issues.

2 participants