Implement a Bounded Per-Key Ordered Task Executor
Last updated: August 2, 2026
Quick Overview
Design and implement a bounded per-key ordered task executor that processes tasks in the order they are received for each key, while ensuring that the number of concurrent tasks for each key does not exceed a specified limit.
Microsoft
August 2, 20262
0
21 solved
Design and implement a bounded per-key ordered task executor that processes tasks in the order they are received for each key, while ensuring that the number of concurrent tasks for each key does not exceed a specified limit.
This question is typically asked during the technical screen round to assess a candidate's understanding of concurrency, task scheduling, and data structures. The interviewer is evaluating the candidate's ability to design a system that efficiently manages tasks while maintaining order and respecting concurrency limits. This question also tests problem-solving skills and the ability to think critically about system design.
What the Interviewer Expects
- Clearly define the requirements and constraints of the task executor.
- Explain the data structures used to manage tasks and keys.
- Provide a detailed implementation plan, including concurrency handling.
- Discuss potential edge cases and how to handle them.
- Evaluate the performance and scalability of the solution.
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you handle task failures or retries?
- What would you change if the order of tasks was not important?
- Can you explain how you would test your implementation?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
To implement a bounded per-key ordered task executor, we need to consider the following requirements:
- Each key can have a maximum number of concurrent tasks.
- Tasks for each key must be executed ...
High-Level Design
The high-level design involves using a combination of data structures:
- Map<Key, Queue
> : This will store a queue of tasks for each key. - Map<Key, Semaphore>: This will manage the concu...