Skip to content

That's just a taste — their profile full of gems!

Visit profile
User avatar
Karen Edwards
August 25891

Distributed Rate Limiter Done Right

I just watched a strong breakdown of a distributed rate limiter, and it hit a point I keep making with engineers:

System design interviews are not about sounding smart.
They’re about showing controlled decision-making under pressure.

Rate limiter is one of those “simple” prompts that exposes people fast.

Most candidates rush straight into Redis, token buckets, and sharding before they’ve even made the problem concrete. That’s exactly how people talk themselves into weak interviews.

What I liked here is the structure:

requirements → entities/interface → high-level design → deep dives

That’s interview maturity.

If you can’t walk an interviewer through that sequence, you’re not designing. You’re improvising.

The first thing I’d drill on is this: a rate limiter is not “just block requests after some number.”
You need to define:

  • who you’re identifying
  • what rule applies
  • where enforcement happens
  • what gets returned when a request is rejected

That sounds basic. It isn’t. This is where a lot of candidates get sloppy.

For example, saying “we rate limit by user” is incomplete.
Is it user ID? IP? API key? Authenticated vs anonymous traffic? Premium vs free tier?

Real systems don’t use one flat rule. They layer them.

That’s the kind of answer that gets respect in an interview because it sounds like you’ve seen production systems, not just prep docs.

Another point I liked: placement matters more than people think.

A lot of candidates suggest putting rate limiting inside each service because it feels easy. It is easy. It’s also wrong for a distributed system if you need a global view.

Then they swing too far and create a separate rate limiter service that every backend calls, which fixes coordination but adds avoidable latency.

The better answer is usually at the edge:

gateway / load balancer / API entry point

That’s where you stop bad traffic before it burns expensive backend resources.

That’s not just cleaner architecture. That’s better operational thinking.

Then there’s the algorithm discussion, and this is where candidates love to overperform in the wrong direction.

You do not need to turn the interview into an academic seminar on every rate limiting variant ever invented.

You need to show that you understand tradeoffs.

The important ones:

  • fixed window is simple but has ugly boundary behavior
  • sliding window log is accurate but memory heavy
  • sliding window counter is cheaper but approximate
  • token bucket is usually the best practical answer because it handles bursts and sustained traffic cleanly

If I were coaching someone, I’d tell them to land on token bucket quickly, explain why, and move on.

That’s what strong candidates do.
They don’t wander. They decide.

The distributed state piece is also where weak answers usually fall apart.

Once you have multiple gateways, local memory is dead on arrival. Now you need shared state. So yes, an in-memory store like Redis makes sense for token count + last refill timestamp.

But if you stop there, you’re still incomplete.

Because the real issue is concurrency.

Two gateways can read the same token count at the same time and both allow the request. That’s the bug. And if you don’t call out the race condition, you’re missing the hard part.

This is the difference between surface-level knowledge and actual design sense.

You don’t get credit for naming Redis.
You get credit for saying:

“This read-modify-write must be atomic.”

That’s the interview moment.

And finally, one thing more candidates need to say out loud: fail fast.

If a request exceeds the limit, reject it immediately with the right status and headers. Don’t invent a queue for something that should be denied. That’s not graceful degradation. That’s just delayed confusion.

Overall, this is why rate limiter is such a good interview question.

It tests whether you can:

  • clarify requirements
  • make placement decisions
  • choose a reasonable algorithm
  • think about scale and latency
  • catch concurrency issues
  • communicate tradeoffs without rambling

And that last part matters more than people admit.

I’ve watched hundreds of interview loops. The candidates who get hired are usually not the ones with the most knowledge.

They’re the ones who can make the interviewer feel:

“I’d trust this person to design under ambiguity.”

That’s the game.

If you’re prepping system design, don’t just memorize solutions. Practice delivering them in a way that feels structured, deliberate, and production-aware.

Because in the room, clarity beats cleverness almost every time.

#softwareengineering#systemdesign#distributedsystems#interviewprep#ratelimiter#backendengineering#faanginterviews
Like
Dislike

102

32

Add a comment...