DEV Community

Cover image for Behind Every 429 Too Many Requests
Sreya Satheesh
Sreya Satheesh

Posted on

Behind Every 429 Too Many Requests

Most developers have seen this message before:

429 Too Many Requests

A request gets rejected because a limit has been reached.

But what actually happens behind the scenes?

How does the system know you've made too many requests?

Where are those requests counted?

What happens when millions of users are sending requests at the same time?

Those questions got me interested in rate limiter design.

What Is a Rate Limiter?

A rate limiter controls how many requests a user, client, or service can make within a given period of time.

You'll find them almost everywhere:

  • APIs
  • Authentication systems
  • Payment services
  • AI applications
  • Public platforms

Without rate limiting, a single user or script could overwhelm a system with requests.

Why Does Designing One Matter?

A simple rate limiter might work for a small application.

Things become more interesting when the traffic grows.

Where should request counts be stored?

How much data needs to be maintained?

How many requests should the system handle every second?

How do multiple servers share the same limits?

Answering those questions is where system design comes in.

Breaking Down the Design

The project covers the different stages involved in designing a rate limiter:

  • Functional Requirements
  • Non-Functional Requirements
  • Capacity Estimation
  • High-Level Design

Each section builds on the previous one.

Requirements influence the scale.

Scale influences the architecture.

And the architecture influences the implementation choices.

High-Level Design

Once the requirements and scale are clear, the architecture becomes much easier to understand.

The High-Level Design section explains the major components involved and how requests move through the system.

What's Next?

Algorithms and race conditions are currently being added.

Future updates will cover:

  • Fixed Window
  • Sliding Window
  • Token Bucket
  • Leaky Bucket
  • Distributed rate limiting challenges

👉 https://rate-limiter-two.vercel.app/

Top comments (0)