Log inStart free
LESSON 29.15 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

FCFS, priority and fairness

Watch four queue policies serve one burst of requests, and see who waits.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 29.15 · SCHEDULER13 REQUESTS · 2 SLOTS
01
Stage 1 of 6 · Bursty arrivals
13 requests arrive in 16 steps. Three long batch prompts come first, then short interactive prompts.
Explain it simply

Each row is one request, and time runs to the right. A square marks a batch request, and a dot marks an interactive one. The dashed bar shows the steps of work it needs. Only 2 requests can run at once, so the rest wait in a queue.

13 rows, one per request. Requests 1 to 3 are long batch prompts that arrive at steps 0 and 1. Requests 4 to 13 are short interactive prompts that arrive up to step 15. 2 slots.

request, prefillwait in queueoutput tokensslots, targets
0481216202428engine step (50 ms)1 A batch2 A batch3 A batch4 B interactive5 A interactive6 B interactive7 A interactive8 A interactive9 B interactive10 A interactive11 A interactive12 A interactive13 B interactive2 slotsfreefree13 requests3 batch10 interactivebatchinteractivework, stepsarrivalswork = ⌈prompt / 512⌉ + output − 1: request 3 is ⌈2048 / 512⌉ + 4 − 1 = 7 steps0481216202428engine step (50 ms)1 A batch2 A batch3 A batch4 B interactive5 A interactive6 B interactive7 A interactive8 A interactive9 B interactive10 A interactive11 A interactive12 A interactive13 B interactive2 slotsfreefree13 requests3 batch10 interactivebatchinteractivework, stepsarrivalswork = ⌈prompt / 512⌉ + output − 1: request 3 is ⌈2048 / 512⌉ + 4 − 1 = 7 steps
Toy: 13 requests, 2 tenants, 1 engine step = 50 ms
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
worki=⌈pi/512⌉+oi−1\sy{w}{data}{\text{work}_i} = \left\lceil \sy{p}{data}{p_i} / 512 \right\rceil + \sy{o}{out}{o_i} - 1
work3=⌈2048/512⌉+4−1=7 steps\text{work}_{3} = \lceil 2048 / 512 \rceil + 4 - 1 = 7\ \text{steps}

A request holds a slot for its prefill steps plus its later tokens.

Common mix-ups

MYTHStrict priority only adds a short delay to the low tier.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With 2 slots, is the first token of request 3 sooner or later under priority than under FCFS?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 2 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.