This page is the drill hall for Model serving frameworks (TorchServe, Triton) . The parent gave you three formulas. Here we push each of them into every corner — every sign of the ratio c / m , the zero cases, the infinite-batch limits, a word problem, and an exam trap.
Before touching a single number, let's re-anchor the three symbols so nobody uses a letter they haven't earned.
Definition The three quantities, in plain words
c = fixed overhead per batch (milliseconds). Think of it as the cost of opening the kitchen door — you pay it once no matter how many plates go out. It comes from kernel launch, CPU→GPU data copy, and framework glue.
m = marginal compute per sample (milliseconds). The cost of cooking one extra plate . Every sample in the batch adds this.
B = batch size = how many requests we stack into one forward pass. A whole number ≥ 1 .
Time to process a batch of B : pay the door cost c once , then m for each of B plates:
T batch = c + B m .
Time if you served them one at a time : pay the door cost every single time:
T serial = B ( c + m ) .
The single number that decides everything is the ratio r = c / m . It answers: "how many samples' worth of compute does one door-opening cost?" Large r → door is expensive → batching is a jackpot. Small r → door is cheap → batching is pointless. Watch that ratio in every row below.
Every serving-math question you can be asked is one of these cells. The examples that follow are each tagged with the cell they cover.
Cell
Regime / input
What's special
Example
A
c ≫ m (large r )
Overhead-bound → huge speedup
Ex 1
B
m ≫ c (small r )
Compute-bound → batching flops
Ex 2
C
c ≈ m (r≈1)
The "typical" middle
Ex 3
D
B → ∞
Limiting ceiling 1 + r
Ex 4
E
B = 1
Degenerate: no batch at all
Ex 5
F
c = 0
Zero overhead → speedup is exactly 1
Ex 6
G
m = 0
Zero compute → division-by-zero danger
Ex 6
H
Throughput + concurrency N
Real capacity planning
Ex 7
I
Word problem: SLA vs delay
L req budget under a p99 limit
Ex 8
J
Exam twist: find B for target S
Invert the formula
Ex 9
We visualise the whole S ( B ) landscape once, so every example lands on a curve you can see.
Look at the figure: three curves, one per regime. The magenta curve (overhead-bound) rockets up and flattens near a high ceiling. The orange curve (compute-bound) barely lifts off 1 . The violet middle curve sits between. Every dashed horizontal line is that curve's ceiling 1 + r . This is the mental picture behind all ten examples.
Worked example Ex 1 — Cell A: overhead-bound, batching is a jackpot
c = 8 ms, m = 2 ms/sample, B = 16 . Find speedup S and its ceiling.
Forecast: guess — will S be closer to 1 × or 5 × ? Jot it down.
Compute the ratio r = c / m = 8/2 = 4 . Why this step? r tells us instantly the door costs 4 plates' worth — batching should pay off big.
Serial time T serial = 16 ( 8 + 2 ) = 160 ms. Why? each of 16 requests pays the full door + one plate.
Batch time T batch = 8 + 16 ( 2 ) = 40 ms. Why? the 8 ms door is paid once ; only the 16 × 2 = 32 ms of plates scales.
S = 160/40 = 4 × . Why? speedup is just serial ÷ batch.
Ceiling = 1 + r = 1 + 4 = 5 × . Why? the best you can ever do is spread one door over infinitely many plates.
Verify: 4 < 5 ✓ (must be below its ceiling). Units: ms/ms → dimensionless ✓. We're at 80% of the ceiling — good ROI.
Worked example Ex 2 — Cell B: compute-bound, batching disappoints
c = 1 ms, m = 40 ms/sample (a heavy LLM layer), B = 8 . Find S .
Forecast: the door is cheap and each plate is a feast — will batching help at all?
r = c / m = 1/40 = 0.025 . Why? tiny r means the door is almost free; there's nothing to save.
T serial = 8 ( 1 + 40 ) = 328 ms. Why? 8 requests each pay 41 ms.
T batch = 1 + 8 ( 40 ) = 321 ms. Why? we saved only 7 ms — the seven extra door-openings we avoided.
S = 328/321 ≈ 1.022 × . Why? almost no gain because m dominates.
Ceiling 1 + r = 1.025 × . Why? even infinite batch buys you 2.5% .
Verify: 1.022 < 1.025 ✓. Takeaway: here you reach for quantization / TensorRT to shrink m , or more concurrent instances — not a bigger batch.
Worked example Ex 3 — Cell C: the balanced middle (
c ≈ m )
c = 5 ms, m = 5 ms/sample, B = 10 .
Forecast: r = 1 . Where between 1 × and 2 × will S land?
r = 5/5 = 1 . Why? door costs exactly one plate — the "textbook" case.
T serial = 10 ( 5 + 5 ) = 100 ms.
T batch = 5 + 10 ( 5 ) = 55 ms.
S = 100/55 ≈ 1.818 × . Why? batching helps meaningfully but the ceiling is low.
Ceiling 1 + r = 2 × . Why? you can at most halve the total.
Verify: 1.818 < 2 ✓, and it's 91% of ceiling — B = 10 is already near saturation for r = 1 .
Worked example Ex 4 — Cell D: the limit
B → ∞
With c = 8 , m = 2 (same as Ex 1), what does S approach as B grows without bound? Confirm with B = 1000 .
Forecast: does S blow up to infinity, or settle somewhere?
Write S ( B ) = c + B m B ( c + m ) and divide top and bottom by B : S = B c + m c + m . Why this step? dividing by B isolates what dies as B → ∞ : the c / B term.
As B → ∞ , c / B → 0 . Why? a fixed number split into ever-more pieces vanishes.
So S → m c + m = 1 + m c = 1 + r = 5 . Why? this is the ceiling — the door cost, fully amortised, disappears.
Sanity at B = 1000 : S = 8 + 1000 ( 2 ) 1000 ( 10 ) = 2008 10000 ≈ 4.98 × . Why? should be a hair under 5 .
Verify: 4.98 < 5 and 4.98 > 4 (Ex 1's value) — monotone climb toward the ceiling ✓.
Worked example Ex 5 — Cell E: the degenerate batch
B = 1
Any c , m . What is S ( 1 ) ? Use c = 8 , m = 2 to check.
Forecast: if the "batch" is a single request, can batching possibly help?
Plug B = 1 : S ( 1 ) = c + 1 ⋅ m 1 ( c + m ) = c + m c + m = 1 . Why this step? with one request, serial is batched — same thing.
Numeric check c = 8 , m = 2 : 8 + 2 1 ( 10 ) = 10 10 = 1 × . Why? confirms the algebra.
Verify: S ( 1 ) = 1 for all c , m ✓ — the curve always starts at 1 (look at the left edge of every curve in the figure). This is why the x-axis in the figure begins at B = 1 , not 0 .
Worked example Ex 6 — Cells F & G: the two zero-inputs
F (c = 0 ): free door. G (m = 0 ): free plates. Use B = 16 .
Forecast: one of these breaks the math. Which?
Cell F , c = 0 , m = 2 : S = 0 + 16 ( 2 ) 16 ( 0 + 2 ) = 32 32 = 1 × . Why? with no door cost there's nothing to amortise, so batching gives nothing — S = 1 exactly, for any B . Ceiling 1 + 0/ m = 1 ✓.
Cell G , c = 8 , m = 0 : throughput = c + B m B = 8 + 0 16 = 2 req/ms. Why this step? with zero compute, only the door cost limits you — throughput becomes B / c , and rises without bound as B grows. Watch: S = 8 + 0 16 ( 8 + 0 ) = 16 = B . Why? with m = 0 the ceiling 1 + c / m is + ∞ , and S equals B exactly.
Danger note: never plug m = 0 and B = 0 — denominator c + B m would be c = 8 (fine here), but B = 0 makes throughput 0/8 = 0 (a batch of nothing does nothing). Guard against B = 0 in code.
Verify: F gives S = 1 ✓ (matches its ceiling). G gives S = B = 16 ✓ and throughput 2 ✓. Both edge cases handled, no illegal division.
Worked example Ex 7 — Cell H: capacity planning with
N instances
c = 4 ms, m = 1 ms, B = 8 . Throughput of one instance, then of N = 3 concurrent instances (Triton instance_group count: 3).
Forecast: guess the single-instance requests/second first.
Batch time T batch = c + B m = 4 + 8 ( 1 ) = 12 ms = 0.012 s. Why this step? throughput needs the time to clear one batch.
Single-instance throughput = T batch B = 0.012 8 ≈ 666.7 req/s. Why? it clears 8 requests every 12 ms.
With N = 3 : multiply by 3 (copies run in parallel) ⇒ 3 × 666.7 = 2000 req/s. Why? concurrency adds independent copies — until GPU memory/compute saturates.
Verify: units check — 0.012 s 8 req = 666.7 req/s ✓. Concurrency and batching are orthogonal : batching cut per-request door cost, N multiplied the whole pipeline.
Worked example Ex 8 — Cell I: word problem, SLA-bounded delay
Requests arrive at λ = 500 /s. Your p99 SLA says L req ≤ 50 ms. Model c = 4 ms, m = 1 ms, t net = 6 ms. What's the largest queue-wait w (≈ max_queue_delay) you can afford, and how many requests B does that gather?
Forecast: guess whether you can afford more or less than 30 ms of waiting.
Budget: L req = w + ( c + B m ) + t net ≤ 50 . Why this step? the SLA caps the total a request feels, so solve for the free knob w .
We don't yet know B , but B is set by w : at λ = 500 /s = 0.5 req/ms, in w ms you gather B ≈ λ w = 0.5 w . Why? arrival rate × wait gives expected arrivals (see the parent's note that this is not the throughput formula).
Substitute: w + ( 4 + 0.5 w ⋅ 1 ) + 6 ≤ 50 ⇒ 1.5 w + 10 ≤ 50 ⇒ 1.5 w ≤ 40 ⇒ w ≤ 26.67 ms. Why? collect the w terms (w from waiting, 0.5 w from the extra compute those gathered samples add).
At w = 26.67 ms, B = 0.5 × 26.67 ≈ 13.3 ⇒ round down to B = 13 . Why? you can only batch whole requests.
Verify: plug w = 26.67 , B = 13.3 : L = 26.67 + ( 4 + 13.3 ) + 6 = 26.67 + 17.3 + 6 = 49.97 ≈ 50 ms ✓ — sits right on the SLA. Set max_queue_delay ≈ 26 ms.
Worked example Ex 9 — Cell J: exam twist, invert for the batch size
c = 6 ms, m = 2 ms. What batch size B gives a speedup of exactly S = 3 × ?
Forecast: the ceiling is 1 + 6/2 = 4 , and we want 3 . Will B be small or large?
Start from S = c + B m B ( c + m ) and set S = 3 : 3 = 6 + 2 B B ( 6 + 2 ) = 6 + 2 B 8 B . Why this step? we're solving backwards — given the target, find the knob.
Cross-multiply: 3 ( 6 + 2 B ) = 8 B ⇒ 18 + 6 B = 8 B . Why? clear the fraction to get a linear equation in B .
Solve: 18 = 2 B ⇒ B = 9 . Why? the 6 B moves over, leaving 2 B = 18 .
Verify: plug B = 9 : S = 6 + 2 ( 9 ) 8 ( 9 ) = 24 72 = 3 × ✓. And 3 < 4 (the ceiling) ✓, so this target is achievable — if we'd asked for S = 4 exactly, no finite B works (only the limit reaches it, per Ex 4).
Recall Which single number predicts whether batching is worth it?
The ratio r = c / m ::: overhead over marginal compute. Ceiling speedup is 1 + r ; large r → batch hard, small r → don't bother (quantize instead).
Recall What is
S ( B ) when B = 1 , and why?
Exactly 1 × ::: a batch of one is serial — nothing is amortised, for any c , m .
Recall Concurrency (
N instances) vs batching — how do they combine in throughput?
Multiply ::: batching sets per-instance throughput B / ( c + B m ) ; N independent copies multiply it by N until the GPU saturates.
"Door once, plates each." T = door once c + plates each B m . Everything else — speedup, throughput, SLA budget — is bookkeeping around this one line.