Skip to main content

Command Palette

Search for a command to run...

An Interactive Guide To Rate Limiting

Updated
2 min read
An Interactive Guide To Rate Limiting
S

Passionate about all areas of computer science, currently exploring DevOps, SRE and Linux

Introduction

Rate limiting is a must have strategy in every back-end app. It prevent one user from overusing a resource and degrading the quality of service for other users. Here are some benefits of rate limiting

  • It presents resource starvation

  • Reduces server hosting cost

  • Provides basic protection against DDoS

I have made four interactive app that let’s you play around with common rate limiting algorithms.

Token bucket

Working:

  • A bucket holds fixed number tokens

  • Tokens are added to bucket at fixed rate

  • When a request comes in:

    • If a token is available, it’s removed from the bucket and the request is allowed.

    • If no tokens are available, the request is rejected or delayed.

  • Allows for occasional short burst if tokens are available

I have created an app that let’s you play with leaky bucket algorithm.

Leaky bucket

Working

  • Think of it as a bucket leaking at a fixed rate

  • Incoming requests are added to the bucket

  • Requests are processed (or "leak") at a constant rate

  • If the bucket is full when a new request arrives, the request is dropped

  • Smooths out bursts; outputs requests at a steady rate

    I have made an app that let’s you play with leaky bucket algorithm.

Fixed window counter

Working:

  • Time is divided into fixed size windows (e.g., 1 minute)

  • A counter tracks the number of requests per client/IP in the current window

  • If the count exceeds the limit, further requests are rejected until the next window

  • Simple and efficient, but allows burst traffic spike at end/start

    I have created an app that let’s you play with fixed bucket algorithm.

Sliding window counter

Working:

  • Keeps a timestamped log of each request

  • When a request comes in, logs are checked to count how many requests were made in the last X seconds

  • If under the limit, the request is allowed and logged; otherwise, it’s rejected

    I have created an app that let’s you play with sliding bucket algorithm.

G

Great article, I'm following you, I hope I can learn such vivid knowledge similar to this one from your follow-up articles in the future

B
BaseOrange11mo ago

Dear respected author,Hello, I would like to request permission to reprint one of your articles on my blog (translated into Chinese). I will give full credit to the original source. Is that acceptable? Looking forward to your reply.

1
B
BaseOrange11mo ago

I need to add one more thing. I won't make any profit by reprinting your article, and my blog doesn't have any advertising revenue either. I just think the article you wrote is relatively clear.

S
Sagyam Thapa11mo ago

Sure I will be delighted. Do send me the link to the translated article. Not that I can read Chinese but I would love to see the translation anyways.

1
B
BaseOrange11mo ago

I appreciate it. I'll get back to you as soon as possible.

B
BaseOrange11mo ago

Hello, I have translated the article and published it on my blog. To honor the copyright of the original author, I have placed the copyright notice at the top of the article. I hope this translation provides value to the readers, and I welcome any feedback. URL:log.660066.xyz/2025/06/13/interactive-guide-to-rate-limiting

1
S
Sagyam Thapa10mo ago

BaseOrange

Thank you for the translation.