Order Microservice Deployments Into Parallel Waves
Last updated: November 29, 2026
Quick Overview
Given a list of services and dependency pairs (a, b) meaning a must be deployed before b, group the services into the fewest sequential waves where each wave can deploy in parallel, or report the services stuck in a cycle.
Netflix
November 29, 20260
0
0 solved
Given a list of services and dependency pairs (a, b) meaning a must be deployed before b, group the services into the fewest sequential waves where each wave can deploy in parallel, or report the services stuck in a cycle.
Netflix runs hundreds of microservices and pushes changes through Spinnaker pipelines, so dependency ordering is a natural coding round topic. The interviewer checks that the candidate knows Kahn's algorithm, can produce level-by-level output rather than just one valid order, and gives a useful error when the graph has a cycle.
What the Interviewer Expects
- Model dependencies as a directed graph with in-degree counts
- Use BFS by levels so each level is one parallel wave
- Detect cycles by comparing placed count to total services
- Report which services are involved in or blocked by the cycle
- Keep output deterministic by sorting within a wave
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you cap each wave at m services because of deploy capacity?
- How would you find the minimum total time if each service has its own deploy duration?
- If a cycle is found, how would you report one concrete cycle path?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Services are nodes, a pair (a, b) is an edge a -> b. A wave is the set of services whose prerequisites are all deployed. We want the list of waves in order, where wave 1 has no prerequisites. If some ...
High-Level Design
Compute in-degrees. The first wave is every service with in-degree 0. Deploying a wave decrements the in-degree of each successor; any service that reaches 0 joins the next wave. This is Kahn's algori...