Scheduling interview problems
Scheduling questions ask you to run work at the right time or in the right order. Examples are a delayed job queue, a periodic task runner, a priority scheduler, or deciding which of N jobs with deadlines to run first. The usual structure is a heapq keyed by (run_at, seq, job) and a loop that sleeps until the earliest deadline. With asyncio you sleep with asyncio.sleep(run_at - loop.time()) or wait on an asyncio.Event so a newly added earlier job can wake the loop. loop.call_later is another option for simple timers.
Interviewers watch for scheduling periodic jobs as sleep(interval) after each run, which drifts by the job's duration, and using wall-clock time.time() instead of a monotonic clock. They also watch for loops that never wake when a sooner job is added, and for cancellation that leaves stale heap entries running. A strong answer computes the next run from the previous scheduled time, uses lazy deletion for cancelled jobs, decides what happens when a job overruns its interval, and takes the clock as a dependency so tests don't sleep for real.
5 locked
These open in order of demand. Open one and press I want this one to ask for it.
- 05Priority Batch Scheduler Lockedmedium
Pick which inference requests go into one GPU batch: highest priority first, FIFO on ties, skip what does not fit, never exceed the token budget.
- 08Retry Scheduler with Exponential Backoff Lockedhard
Build a request scheduler that retries failures with exponential backoff, orders work by ready time and tracks a five-state lifecycle.
- 17GPU Memory Scheduler Lockedhard
Admit async jobs onto a GPU with fixed memory in strict FIFO order, so large jobs never starve, and survive cancelled waiters without leaking memory.
- 26Async Priority Job Scheduler Lockedhard
Run submitted async jobs on N workers in priority order, FIFO within a priority, with cancellation and a draining shutdown.
- 30Least-Loaded Replica Scheduler Lockedhard
Send each async request to the healthy replica with the fewest in-flight requests, wait when all are full, and react to health changes.