|
|
|
|
|
by dansingerman
3367 days ago
|
|
The code examples are written in ruby and lua - I take it that in your live environment you use the lua script compiled into nginx? Does this mean every rate limited request is hitting redis? I had this problem years ago, and I used varnish to offload the rate limited traffic, which scaled very well then. Here is a blog post I wrote about it: http://blog.dansingerman.com/post/4604532761/how-to-block-ra... (it was written directly in response to a 'One of your users has a misbehaving script which is accidentally sending you a lot of requests' issue) |
|
So yes, our Redis traffic is strictly higher than our whole API requests per second. This is actually pretty easy since Redis scales pretty well horizontally (the keys shard well) in addition to being able to handle many orders of magnitude more traffic than a normal web stack per machine.
Thanks for linking to your blog post. I like the simplicity of not having to enter the web stack at all. I'm not very familiar with varnish, how do you end up doing the actual rate limiting algorithm? I see you making a hash but not dripping tokens into a bucket.