Research notebook

Inference queueing notebook

Edit a Python cell and run it here. Your code runs in this browser tab; the notebook runtime and packages are served by this site.

Python starts when you choose Run.

Where the queue hides: a reproducible timing model

This notebook runs the accompanying finite-batch FIFO timing model and plots the checked CSV output. It represents a single service slot, fixed 400 ms service, and 20 requests per scenario.

Assumptions

Twenty requests arrive at a fixed interval. One FIFO service slot takes exactly 400 ms per request. All waiting is before dispatch. The system starts empty, drains completely, and has no network, server queue, batching, tokens, failures, or random variation. The four scenarios use intervals of 100, 200, 400, and 800 ms.

Python · cell 1
80 request rows across 4 scenarios
Model type: deterministic single-server FIFO timing simulation
100 ms arrivals: request mean 400 ms; credit-to-completion mean 3250 ms; inclusive 1 s passes 3/20
200 ms arrivals: request mean 400 ms; credit-to-completion mean 2300 ms; inclusive 1 s passes 4/20
400 ms arrivals: request mean 400 ms; credit-to-completion mean 400 ms; inclusive 1 s passes 20/20
800 ms arrivals: request mean 400 ms; credit-to-completion mean 400 ms; inclusive 1 s passes 20/20
Python · cell 2
Python · cell 3
Chart of mean dispatch-based and credit-inclusive latency across four request arrival intervals.
Python · cell 4
20 requests; dispatch mean 400 ms; credit-inclusive mean 3250 ms; max 6100 ms; 3/20 meet 1000 ms.

Read the result carefully

At 100 ms arrivals, service remains exactly 400 ms per request in every row, while the modeled mean from credit issuance to completion is 3,250 ms. The difference comes from pre-dispatch FIFO waiting. The sample is a drained batch of 20 requests, not a steady-state estimate.

Reproduce the unit suite from this folder with python3 -m unittest -v test_timing_model.py. Change interval_ms in the model cell to explore other deterministic inputs.

Python runs locally in this page. Saved results and figures are visible before execution.

Download full experiment notebook