tag:blogger.com,1999:blog-8540221137227899134.post8225422673849614301..comments2024-03-17T00:36:18.345-07:00Comments on A Dash of Technology: Some Redis Use-casesJosiah Carlsonhttp://www.blogger.com/profile/16662314724540946069noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-8540221137227899134.post-62087549176451292142011-03-16T15:20:16.465-07:002011-03-16T15:20:16.465-07:00Anonymous: You can definitely do that. It has many...Anonymous: You can definitely do that. It has many of the same limitations, though you are then restricted to have every limit be on the same time frame (your n). By using a secondary zset as the above example has, you can have different per second, minute, hour, day, etc., limits.<br /><br />For example, 60 requests per minute, but only 1800 requests per hour. That would allow a short-term burst rate for a minute that is twice as high as the average for the hour. That is possible with the 2-zset version, but isn't possible with a single zset with a Redis 2.2 key expiration.Josiah Carlsonhttps://www.blogger.com/profile/16662314724540946069noreply@blogger.comtag:blogger.com,1999:blog-8540221137227899134.post-60949148454791583502011-03-15T20:29:13.232-07:002011-03-15T20:29:13.232-07:00I've been playing around with your rate limiti...I've been playing around with your rate limiting example functions and think I've finally got a decent understanding of how they work after porting the code to lua. I am wondering about the built in key expiration in redis 2.2.<br /><br />Is it possible to accomplish the same type of rate limiting by adding keys to a sorted set that expire at time.now + n with n being the length of the sliding window you want to use for the rate calculation then using a count of the number of keys / n to determine current rate. This way reset function wouldn't be needed. Being new to redis' capabilities this question has vexed me for some time now.<br /><br />thanksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8540221137227899134.post-84598832037401388412011-03-01T08:04:01.464-08:002011-03-01T08:04:01.464-08:00Thank you for the great article. It's very use...Thank you for the great article. It's very useful!Anonymousnoreply@blogger.com