FCFS Scheduling — Convoy Effect Cripples Payment API
Response time for payment API jumped from <200ms to >15s due to convoy effect in FCFS scheduling.
- Processes execute in arrival order — pure FIFO queue.
- No preemption: once running, a process keeps the CPU until it blocks or exits.
- Convoy effect: a single long job holds the CPU while short jobs wait idle, inflating average waiting time.
- Worst-case average waiting time grows linearly with burst time variance — not robust for interactive loads.
- Production trap: using FCFS for mixed workloads (CPU + I/O) causes I/O devices to starve, tanking throughput.
FCFS is the simplest scheduling algorithm — processes run in the order they arrive, like a queue at a ticket counter. Whoever arrives first gets served first. Simple and fair in principle, but a long process can make everything behind it wait — the convoy effect.
FCFS is the algorithm you implement when you have a queue and zero information about job durations. It is fair in the sense that arrival order is respected — no process waits longer than all processes that arrived before it. But 'fair' does not mean 'efficient', and the convoy effect makes FCFS genuinely harmful for interactive workloads.
Understanding FCFS matters not for implementing it (it is trivially a FIFO queue) but for understanding what it optimises and what it sacrifices. Every scheduling algorithm trades off fairness, average waiting time, response time, and throughput differently. FCFS optimises arrival-order fairness at the cost of average waiting time. This trade-off analysis is the interview skill being tested.
Algorithm and Metrics
- Completion Time (CT): When the process finishes
- Turnaround Time (TAT): CT
- Arrival Time
- Waiting Time (WT): TAT
- Burst Time
- Response Time: Time from arrival to first execution (= WT for non-preemptive)
FCFS is trivially a FIFO queue. You sort processes by arrival time, then execute each to completion. The metrics tell the real story: average waiting time can skyrocket when a long job arrives early.
The Convoy Effect
In the example above, P2 and P3 each take only 3ms but wait 23ms and 25ms because P1 (24ms) arrived first. This is the convoy effect — short processes form a convoy behind a long one.
- P2: WT=0, P3: WT=2, P1: WT=5
- Average WT = 2.33ms vs 16ms for FCFS
This is why FCFS has poor average waiting time for mixed workloads.
Gantt Chart Representation
A Gantt chart visually shows which process runs at each time interval. For FCFS, the chart is simply the processes in arrival order, each spanning its burst duration. This representation makes the convoy effect obvious: long bars push short bars to the right.
When to Use FCFS in Practice
- All jobs have roughly equal burst times (e.g., batch file processing with similar file sizes).
- Order must be strictly preserved (e.g., transactions that must commit in arrival sequence).
- No prior information about job durations exists and you cannot risk priority inversion.
- Interactive systems where response time matters.
- Mixed workloads with heterogeneous burst times.
- Real-time systems where deadlines must be met.
In most general-purpose operating systems, FCFS is used only as a fallback scheduler for equal-priority processes under SCHED_OTHER. Linux's Completely Fair Scheduler (CFS) is fundamentally different — it's a weighted fair queuing scheduler that preempts to maintain fairness.
- No decision: just a queue. Predictable in behaviour, unpredictable in performance.
- Linux CFS targets a 1ms scheduling granularity — the opposite of FCFS's no-granularity.
- FCFS survives as a special case for cooperative multitasking or dispatcher systems where preemption is impossible.
FCFS vs. SJF vs. Round Robin
Comparing scheduling algorithms around burst time variance:
| Algorithm | Average Waiting Time | Starvation Risk | Preemptive |
|---|---|---|---|
| FCFS | High with variance | None (everyone runs eventually) | No |
| SJF (non-preemptive) | Optimal for given arrival order | Yes, long processes | No |
| Round Robin (preemptive) | Moderate, depends on quantum | Low | Yes |
FCFS minimises the maximum waiting time for processes with the same arrival order — that's its fairness guarantee. But it maximises average waiting time when burst times vary.
SJF exploits knowledge of burst times to minimise average waiting time, but can starve long processes. Round Robin trades off average waiting time for response time — good for interactive workloads.
In production, you rarely pick one in isolation. Hybrid schedulers like CFS combine elements: target latency (like RR) with fairness (like FCFS) and dynamic priority adjustments.
Convoy Effect Brings Down an E-Commerce Checkout Service
- Never mix CPU-bound batch jobs and interactive I/O-bound requests on the same FCFS queue.
- Measure queue depth under load — it reveals convoy effect faster than response times alone.
- FCFS belongs in batch systems with homogeneous job sizes, not mixed workloads.
Key takeaways
Common mistakes to avoid
3 patternsAssuming FCFS is 'fair' for all metrics
Using FCFS for I/O-heavy workloads because 'it's simple'
Implementing a thread pool with a single FIFO work queue and claiming it's 'FCFS scheduling'
Interview Questions on This Topic
Explain the convoy effect in FCFS scheduling and show it with an example.
Frequently Asked Questions
That's Scheduling. Mark it forged?
3 min read · try the examples if you haven't