You are a Backend Engineer at DoorDash and notice that your service can no longer keep up with traffic.
To handle the increased load, the team decides to scale horizontally by adding more pods running your service.
A colleague implemented a traffic router that distributes requests to pods using a round-robin algorithm. However, the implementation does not work correctly, and you are asked to debug it.
The system consists of the following classes:
- TrafficRouter: Handles routing. It takes a list of backend pods.
- Pod: Represents a service pod (hostname + port).
- Backend: Represents a pod with its state (
AVAILABLE,UNAVAILABLE). - HttpRequest: Represents an incoming HTTP request. All requests from the same user share the same request ID.
Methods you must debug or implement
TrafficRouter.get_backend(request)
Returns the next available pod (round robin). If all pods are unavailable, returnsNone.TrafficRouter.reportAvailability(backend, state)
Update pod availability.TrafficRouter.add_backend(backend)
Add a new backend pod at runtime.
Follow-up: Optimize using Consistent Hashing
After debugging the above implementation, you are told:
The service is stateful and keeps in-memory user sessions inside each pod.
To improve session cache hit rate, requests from the same user should ideally hit the same pod.
You must optimize the router using consistent hashing.
Consistent hashing is defined as:
- Create a hash function that maps request IDs to a numeric range.
- Create a ring structure representing that numeric space.
- Assign pods to positions on the ring.
- Route a request by hashing its ID and choosing the next clockwise pod.
- If a pod becomes unavailable, its range is taken over by its next neighbors.
- When a new pod is added, only a small portion of keys are remapped.
Original Code Snippets (for debugging)
class HttpRequest:
def __init__(self, id):
self.id = id
class Pod:
def __init__(self, hostname, port):
self.hostname = hostname
self.port = port
class Backend:
def __init__(self, pod, state):
self.pod = pod
self.state = state
def get_state(self):
return self.state
def set_state(self, updated_state):
self.state = updated_state
class TrafficRouter:
def __init__(self, backends):
self.backends = list(backends)
def get_backend(self, request):
index = 0
backend = self.backends[index]
if backend.state == "AVAILABL":
return backend
index += 1
return None
Unit test examples were provided to verify:
- Round robin works
- Unavailable pods are skipped
- Adding new pods updates routing behavior
This DoorDash VO problem evaluates two major backend skills:
✅ 1. Debugging Production-like Systems
You must identify why the round-robin load balancer is broken:
- The index is always reset to 0
- The state check has a typo (“AVAILABL”)
- The router never advances through pods
- New backends overwrite the existing list
- Unavailable pods are not skipped correctly
This tests your ability to reason about state, correctness, and control flow in distributed routing logic.
✅ 2. Designing a Stateful Load Balancer with Consistent Hashing
The second part tests system design thinking:
- Stateful services need sticky routing
- Round robin breaks session locality
- Consistent hashing keeps the majority of users on the same pod
- Adding or removing pods only remaps a small portion of keys
- You must explain virtual nodes, ring structure, and resilience to node failures
This is a very typical real-world distributed systems question used in VO interviews to check if candidates can translate debugging into scalable architecture design.
The VOprep team has long accompanied candidates through various major company OAs and VOs, including Doordash, Google, Amazon, Citadel, SIG, providing real-time voice assistance, remote practice, and interview pacing reminders to help you stay smooth during critical moments. If you are preparing for Tiktok or similar engineering-focused companies, you can check out our customized support plans—from coding interviews to system design, we offer full guidance to help you succeed.