Rate Limiting Pattern
Learn Rate Limiting Pattern (Core Microservices Patterns, Microservices Design Patterns) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
What is Rate Limiting? Rate Limiting controls HOW MANY requests a client (or a service) is allowed to make in a given time window, protecting a service from being overwhelmed - whether by a buggy retry loop, a traffic spike, or a malicious client. The Token Bucket Concept A common algorithm: imagine a bucket that holds up to N tokens, refilled at a steady rate (e.g. 10 tokens/second). Every incoming request must take one token to proceed; if the bucket is empty, the request is rejected (or queued) until a token is available. This allows short bursts (up to the bucket size) while still...