Sitemap
Acing the Software Engineer Interview

A collection of interview prep notes

Follow publication

Member-only story

[System Design] Rate Limiting Algorithms

--

Photo by Alisa Anton on Unsplash

Read full article for free if you don’t have medium membership: https://liverungrow.medium.com/system-design-rate-limiting-algorithms-8a26892fb97f?sk=a3a37f345e80fd2503ba5b494f105cec

Fixed Window

A simple counter that resets every window (e.g. every 60 seconds).
If the limit is 4 requests per minute:

  • Client can send up to 4 requests between 00:00 and 00:59.
  • At 01:00, the counter resets to zero.
https://www.linkedin.com/pulse/rate-limiting-simplified-redis-antematter-e0hnf/

❌ ‘Burst at boundary’ does not handle bursts of traffic efficiently. Users can send a huge burst of request at the end of the first window, and the beginning of the second window. (A client could send 4 requests at 00:59, and another 4 at 01:00.) This could potentially overload the server.

Sliding Window

The sliding window algorithm is used to limit the number of requests a client can make over a specific period. It’s more flexible than a fixed window, and smoother than token bucket in many cases.

You define a rate limit, like 100 requests per 60 seconds.

--

--

LiveRunGrow
LiveRunGrow

Written by LiveRunGrow

𓆉︎ 𝙳𝚛𝚎𝚊𝚖𝚎𝚛 🪴𝙲𝚛𝚎𝚊𝚝𝚘𝚛 👩‍💻𝚂𝚘𝚏𝚝𝚠𝚊𝚛𝚎 𝚎𝚗𝚐𝚒𝚗𝚎𝚎𝚛 ☻ I write & reflect about software engineering, my life and books. Ŧ๏ɭɭ๏ฬ ๓є!

No responses yet