Skip to content

Rate Limiter

Medium — good to knowBackend

ELI5 — The Vibe Check

A rate limiter controls how many requests someone can make to your API in a given time window. It's the bouncer who says 'you've had enough — come back in a minute.' Without it, one bad actor can spam your server into oblivion, or a buggy client can accidentally DDoS you.

Real Talk

Rate limiting restricts the number of API requests a client can make within a time window. It protects against abuse, DDoS attacks, and resource exhaustion. Common algorithms include fixed window, sliding window, token bucket, and leaky bucket. Typically implemented via middleware using Redis for distributed counting.

Show Me The Code

const rateLimit = require('express-rate-limit');

app.use(rateLimit({
  windowMs: 15 * 60 * 1000, // 15 minutes
  max: 100, // 100 requests per window
  message: 'Too many requests, slow down!'
}));

When You'll Hear This

"We need rate limiting on the login endpoint to prevent brute force." / "The rate limiter returns 429 Too Many Requests when you exceed the limit."

Made with passive-aggressive love by manoga.digital. Powered by Claude.