Technical Interview Questions

Microservice Rate Limiting and Circuit Breaker Design

"ByteDance runs thousands of microservices. Design a rate limiting and circuit breaker system that prevents cascading failures across the service mesh."

Why Interviewers Ask This

ByteDance's microservice architecture has thousands of interdependent services. A single slow or failing service can trigger cascading failures that take down entire product lines. Backend engineers must understand how to build resilience into the service mesh — this is not optional, it is essential infrastructure at ByteDance's scale.

How to Answer

  1. 1

    Define the problem: cascading failures occur when a slow downstream service causes upstream services to exhaust their thread pools waiting for responses, which then propagates to their callers.

  2. 2

    Describe the rate limiting approach: token bucket per service pair with both local and distributed rate limits, configured via a central policy service.

  3. 3

    Explain the circuit breaker pattern: closed → open → half-open state machine, with configurable failure thresholds and recovery probes.

  4. 4

    Discuss integration into the service mesh: implement as a sidecar proxy or SDK middleware so individual services do not need custom implementations.

Sample Answer

I would build a two-layer resilience system integrated into the service mesh sidecar. Layer 1 — Rate Limiting: each service-to-service call passes through a token bucket rate limiter in the sidecar. Local rate limits use an in-memory token bucket replenished per second. Global rate limits coordinate across instances via a Redis-backed sliding window counter, synced every 500ms to balance accuracy with performance. Rate limit policies are managed centrally in a configuration service and pushed to sidecars via gRPC streaming. When a request is rate-limited, the sidecar returns a 429 with a Retry-After header, and the caller implements exponential backoff. Layer 2 — Circuit Breaker: the sidecar tracks error rate and p99 latency for each downstream service over a sliding 30-second window. If error rate exceeds 50% or p99 exceeds 5x the baseline, the circuit opens — all requests receive an immediate fallback response (cached data or graceful degradation). After 10 seconds, the circuit enters half-open state, allowing 5% of traffic through as probes. If probes succeed, the circuit closes; if they fail, it reopens with doubled cooldown. Both layers emit metrics to a Prometheus-based monitoring system with PagerDuty alerts when circuits open. The key design choice is making this a sidecar concern rather than an application library, so every service gets resilience by default without code changes.

Pro Tips

  • Emphasize the sidecar approach — ByteDance uses a service mesh, so resilience should be infrastructure-level, not application-level.

  • Discuss the difference between local and distributed rate limiting and when each is appropriate.

  • Mention the importance of fallback strategies when a circuit is open — simply failing fast is not enough; you need graceful degradation.

Frequently Asked Questions

What is the difference between rate limiting and circuit breaking?

Rate limiting controls the volume of requests to prevent overload. Circuit breaking detects when a downstream service is unhealthy and stops sending requests to allow it to recover. They complement each other: rate limiting prevents the problem, circuit breaking contains it.

Why use a sidecar proxy instead of an application-level library?

A sidecar proxy provides resilience transparently to all services regardless of programming language. It ensures consistent behavior, simplifies upgrades, and prevents the situation where one team forgets to implement rate limiting in their service.

Worried About Going Blank in Your Interview?

HireMe AI listens to your interview in real-time, detects questions, and generates instant answer suggestions — so you never freeze up again.

Try HireMe AI Free