Config
Type of rate limiting
Single machine vs cluster-based rate limiting.
Account-based rate limiting: VIP account vs general account.
Resource-based rate limiting: Specific IP address
Handle rate limited request
Directly return service unavailable 429.
Turn synchronous requests to asynchrous handling.
Synchronously block until available.
Adjust load balancing mechanism.
If directly returning 429 to client
The following response headers could be referenced.
Request size
Rate limit threshold is also related to the size of request.
If one machine handles all request with big payload, the other handles requests will small payload. Then the threshold should be adjusted accordingly.
Deciding on rate limit threadshold
Observe the peak time QPS
Watch the peak time QPS
Leave additional 20% capacity. Divide by machine number if needed.
Pressure test
After pressure test, you could get some charts as follow:
A: If want best resource utilization
B: If want best throughput, it is the tipping point where the system will crash.
C: If want best response time
Reference related service
If a service A has a certain conversion rate to service B, then we could reference the rate limiting number for A when deciding on B.
Manually estimation
The worst case scenario.
Rate limiting config sample
Using the example of lyft envoy: https://github.com/envoyproxy/ratelimit
Last updated