Skip to content

Ratelimit question #35

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
xiaozi opened this issue Sep 29, 2016 · 1 comment
Open

Ratelimit question #35

xiaozi opened this issue Sep 29, 2016 · 1 comment

Comments

@xiaozi
Copy link

xiaozi commented Sep 29, 2016

code

var redback = require('redback').createClient();
var ratelimit = redback.createRateLimit('requests', {
    bucket_span: 6,
    bucket_interval: 1,
    subject_expiry: 12
});

// if request 1 times per 3 seconds
setInterval(function () {
    ratelimit.add('127.0.0.1');
}, 3000);

redis monitor

1475139642.585969 [0 127.0.0.1:50241] "multi"
1475139642.585994 [0 127.0.0.1:50241] "hincrby" "requests:127.0.0.1" "0" "1"
1475139642.586005 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "1"
1475139642.586010 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "2"
1475139642.586015 [0 127.0.0.1:50241] "expire" "requests:127.0.0.1" "12"
1475139642.586023 [0 127.0.0.1:50241] "exec"
1475139645.592772 [0 127.0.0.1:50241] "multi"
1475139645.592794 [0 127.0.0.1:50241] "hincrby" "requests:127.0.0.1" "3" "1"
1475139645.592804 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "4"
1475139645.592809 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "5"
1475139645.592814 [0 127.0.0.1:50241] "expire" "requests:127.0.0.1" "12"
1475139645.592822 [0 127.0.0.1:50241] "exec"
1475139648.594619 [0 127.0.0.1:50241] "multi"
1475139648.594651 [0 127.0.0.1:50241] "hincrby" "requests:127.0.0.1" "0" "1"
1475139648.594669 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "1"
1475139648.594677 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "2"
1475139648.594685 [0 127.0.0.1:50241] "expire" "requests:127.0.0.1" "12"
1475139648.594698 [0 127.0.0.1:50241] "exec"
1475139651.597944 [0 127.0.0.1:50241] "multi"
1475139651.597967 [0 127.0.0.1:50241] "hincrby" "requests:127.0.0.1" "3" "1"
1475139651.597978 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "4"
1475139651.597983 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "5"
1475139651.597987 [0 127.0.0.1:50241] "expire" "requests:127.0.0.1" "12"
1475139651.597995 [0 127.0.0.1:50241] "exec"

bucket 0 and 3 will not be deleted.
now I'd like to get the count on bucket 0, it's 2.
actually I just hit 1 times in this second, or in last 2 seconds.

@wendy260310
Copy link

I found the same issue.For example:I increment the 0 bulk,then I wait for a span time and add , suppose it increment the 1 bulk.I count the visit time it returns 2. In fact, the count in 0 bulk is out of date.

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