Scale a Cache or Rate Limiter Across Multiple Machines
Company: Meta
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Technical Screen
Consider a production component that provides caching or rate limiting. Choose one of those components, define its basic behavior, and explain how you would adapt its design as the data volume grows, it runs across multiple machines, and failures occur.
This is an engineering design discussion. State the component contract you use rather than assuming a particular unprovided coding interface.
### Constraints and Clarifying Questions
- For a cache, clarify the source of truth, read/write behavior, freshness, capacity, and eviction requirements.
- For a rate limiter, clarify the identity being limited, limit policy, time window or burst behavior, and whether approximate enforcement is acceptable.
- Clarify traffic distribution, state size, hot keys, and the behavior required when a node or dependency is unavailable.
- Distinguish an example policy you choose for the discussion from a universally required design.
### Part 1 — Scale the State and Requests
Explain the initial design and what changes as it exceeds one machine's practical capacity. Discuss partitioning, coordination, and how requests find the relevant state.
#### What This Part Should Cover
- A clear component contract and workload assumptions.
- Partitioning and handling of hot identities or keys.
- The consistency or coordination cost introduced by multiple machines.
### Part 2 — Handle Failures and Operational Trade-offs
Describe a node failure, a network partition, and a traffic surge. Explain how the design preserves or intentionally relaxes its chosen guarantees.
#### What This Part Should Cover
- Recovery or reconstruction of state and the effect of stale or missing information.
- A justified availability-versus-correctness choice appropriate to the selected component.
- Measurements and limits that reveal overload rather than hiding it.
```hint Define what a local decision means globally
Consider two machines handling requests for the same key or identity. Explain what each must know before its response can satisfy the contract you chose.
```
### What a Strong Answer Covers
- A consistent component design from one machine through distributed operation.
- Scaling and failure choices tied to the component's actual semantics.
- Honest limits on global guarantees, recovery, and resource usage.
### Follow-up Questions
- Why can adding machines fail to solve a hot-key bottleneck?
- What happens to the chosen guarantee while a partition is unavailable?
- How would you change the design if the product accepted bounded approximation?
Overview: Discuss how a cache or rate limiter should scale across machines and handle larger state, hot keys, failures, and consistency trade-offs.
Consider a production component that provides caching or rate limiting. Choose one of those components, define its basic behavior, and explain how you would adapt its design as the data volume grows, it runs across multiple machines, and failures occur.
This is an engineering design discussion. State the component contract you use rather than assuming a particular unprovided coding interface.
Constraints and Clarifying Questions
For a cache, clarify the source of truth, read/write behavior, freshness, capacity, and eviction requirements.
For a rate limiter, clarify the identity being limited, limit policy, time window or burst behavior, and whether approximate enforcement is acceptable.
Clarify traffic distribution, state size, hot keys, and the behavior required when a node or dependency is unavailable.
Distinguish an example policy you choose for the discussion from a universally required design.
Part 1 — Scale the State and Requests
Explain the initial design and what changes as it exceeds one machine's practical capacity. Discuss partitioning, coordination, and how requests find the relevant state.
What This Part Should Cover Guidance
A clear component contract and workload assumptions.
Partitioning and handling of hot identities or keys.
The consistency or coordination cost introduced by multiple machines.
Part 2 — Handle Failures and Operational Trade-offs
Describe a node failure, a network partition, and a traffic surge. Explain how the design preserves or intentionally relaxes its chosen guarantees.
What This Part Should Cover Guidance
Recovery or reconstruction of state and the effect of stale or missing information.
A justified availability-versus-correctness choice appropriate to the selected component.
Measurements and limits that reveal overload rather than hiding it.
What a Strong Answer Covers Guidance
A consistent component design from one machine through distributed operation.
Scaling and failure choices tied to the component's actual semantics.
Honest limits on global guarantees, recovery, and resource usage.
Follow-up Questions Guidance
Why can adding machines fail to solve a hot-key bottleneck?
What happens to the chosen guarantee while a partition is unavailable?
How would you change the design if the product accepted bounded approximation?