Design A Rate Limiter Flashcards
Examples of rate limiter usage?
- user can write no more than 2 posts per second
- you can create max of 10 accounts per day from the same IP address
- you can claim rewards no more than 5 times per week from the same device
What are the benefits of using rate limiters?
DCO
- D: DoS by blocking excess calls
- C: Reduce costs
- O: Prevent servers from being overloaded
What is the API Gateway?
It’s a fully managed service that supports rate limiting, SSL termination, authentication, IP whitelisting,
servicing static content, etc.
What are the popular rate limiter algorithms?
- token bucket
- leaking bucket
- fixed window counter
- sliding window log
- sliding window counter
Token bucket? Pros and cons?
+
easy to implement
memory efficient
allow burst of traffic
-
might be challenging to tune
Leaking bucket? Pros and cons?
+
memory efficient
fixed rate and stable outflow
-
burst of traffic doesn’t work here
might be challenging to tune
Fixed window counter? Pros and cons?
+
memory efficient
easy to understand
-
spike in traffic at the edges of a window
Sliding window log? Pros and cons?
+
is very accurate
-
consumes a lot of memory
HTTP code for to many requests?
429
Lua script?