Skip to content

add more discussion to INCR docu case studies #2722

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cbeck88
Copy link

@cbeck88 cbeck88 commented Feb 5, 2025

The discussion about implementing a rate limiter pattern contained in the docu about INCR command may lead one to think that the rate limiter pattern is made somewhat more complicated due to INCR not having NX features similar to SET. This is because a very simple but flawed example is demonstrated, and the working solutions all either use timestamps within the buckets (which adds complexity, and raises questions about clock synchronization across servers), or use lua scripting, or use redis lists. Meanwhile an NX feature on INCR would seem to solve the problem pointed out in the flawed example.

This idea re-appears in github issues where users request additional features to be added to INCR, and point to rate limiter as a motivation:

redis/redis#4423
redis/redis#7631

In all the comments, more experienced users explain how you can already basically do this using a MULTI pipeline, and you can use NX in that pipeline as well if you want, which would accomplish what these feature requests seem to be asking for. However, this idea doesn't actually appear in the case studies in the documentation.

Expanding the case studies to include this idea, and working through explicitly how it avoids race conditions and pitfalls described in the other approaches, may be helpful to users. (It was helpful to me.)

Copy link

netlify bot commented Feb 5, 2025

👷 Deploy request for redis-doc pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 162df3e

@CLAassistant
Copy link

CLAassistant commented Feb 5, 2025

CLA assistant check
All committers have signed the CLA.

The discussion about implementing a rate limiter pattern contained
in the docu about INCR command may lead one to think that the rate
limiter pattern is made somewhat more complicated due to INCR not
having NX features similar to SET. This is because a very simple
but flawed example is demonstrated, and the working solutions all
either use timestamps within the buckets (which adds complexity,
and raises questions about clock synchronization across servers),
or use lua scripting, or use redis lists. Meanwhile an NX feature
on INCR would seem to solve the problem pointed out in the flawed example.

This idea re-appears in github issues where users request additional
features to be added to INCR, and point to rate limiter as a motivation:

redis/redis#4423
redis/redis#7631

In all the comments, more experienced users explain how you can already
basically do this using a MULTI pipeline, and you can use NX in that
pipeline as well if you want, which would accomplish what these feature
requests seem to be asking for. However, this idea doesn't actually
appear in the case studies in the documentation.

Expanding the case studies to include this idea, and working through
explicitly how it avoids race conditions and pitfalls described in the
other approaches, may be helpful to users. (It was helpful to me.)
@cbeck88 cbeck88 force-pushed the add-discussion-to-incr-docu branch from cb8f339 to 162df3e Compare February 5, 2025 10:37
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