Uber | Goldman Sachs | Rubrik LLD Interview Question : Design Scheduled Executor
Summary
I encountered a challenging low-level design question focused on designing a custom ScheduledThreadPoolExecutor, which is frequently asked by companies like Uber, Goldman Sachs, and Rubrik to assess senior engineering skills.
Full Experience
The interview question required designing a custom ScheduledThreadPoolExecutor or ScheduledExecutorService from scratch. This is a classic concurrency problem commonly seen in interviews for senior engineering roles.
Key Concepts:
- Thread pool with worker threads
- DelayQueue to hold tasks ordered by next execution time
- Delayed interface for time‑based ordering
- Scheduling strategies:
- schedule after initial delay
- schedule at fixed‑rate
- schedule at fixed‑delay
- Thread safety and rescheduling logic
Solution Overview:
- Use a DelayQueue to store ScheduledTask objects (implements Runnable + Delayed).
- Worker threads loop, calling take() – this blocks until a task’s delay expires.
- Once executed, if the task is periodic, update its next trigger time and put it back into the queue.
- For fixed‑rate, next trigger = previous trigger + period;
- for fixed‑delay, next trigger = current time + delay.
- Shutdown interrupts workers and clears the queue.
Interview Questions (1)
Design Scheduled Executor Service
Design a custom ScheduledThreadPoolExecutor or ScheduledExecutorService from scratch – a classic concurrency problem asked by Uber, GS, and Rubrik to test senior engineering skills.
Key Concepts:
- Thread pool with worker threads
- DelayQueue to hold tasks ordered by next execution time
- Delayed interface for time‑based ordering
- Scheduling strategies:
- schedule after initial delay
- schedule at fixed‑rate
- schedule at fixed‑delay
- Thread safety and rescheduling logic