Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

Handbooks  /  Batch vs Real-Time Inference
AI~9 min readComparison
Head to Head

Batch vs real-time inference: throughput, or latency?

BatchvsReal-Time

The whole question is whether a human is waiting for the answer. If nobody is, you can pack thousands of inputs together and squeeze every last drop of throughput out of the GPU. If someone is staring at a spinner, you optimize for the milliseconds — and give up a lot of that efficiency to get them.

01

The one distinction that decides everything

Batch inference runs the model over many inputs together, offline or asynchronously — a scheduled job or a queue drains a big pile of work and writes results somewhere. Nobody is waiting on any single prediction, so you optimize for throughput (predictions per second per GPU) and cost per token. Real-time inference (a.k.a. online) answers one request at a time, synchronously, while a user or a calling service waits — so you optimize for latency (time to first token, tail latency) even if it means the GPU sits underused between requests.

→ The rule

Is a human or a live request blocked on the result? Real-time. Is the work a bulk job whose results are consumed later? Batch. The presence or absence of someone waiting sets every other trade-off.

02

Head to head

DimensionBatchReal-Time
Optimizes forThroughput & cost/tokenLatency per request
Latency toleranceHigh — minutes to hours is fineLow — milliseconds matter
Triggered byA schedule or a queue of workAn incoming request
GPU utilizationHigh — big batches keep it busyLower — idle gaps between requests
Cost per tokenLowestHigher
Batching styleLarge static batchesDynamic / continuous batching
Typical workEmbed a corpus, score a dataset, nightly jobsChat, autocomplete, live APIs
03

When to use each

Reach for batch

  • Embedding a whole corpus for a search index
  • Scoring or classifying a large dataset offline
  • Nightly report generation or bulk summarization
  • Backfilling predictions over historical data
  • Anything where results are consumed later, not now

Reach for real-time

  • Chat assistants and interactive generation
  • Autocomplete and typeahead
  • Live APIs a product calls per user action
  • Fraud or moderation checks in the request path
  • Anything a user or upstream service waits on
04

Continuous batching blurs the line

The old framing — "batch is efficient, online is slow" — has softened, because modern serving engines (vLLM, TGI and friends) use continuous batching: they dynamically pack many in-flight online requests into a shared batch on the GPU, adding and removing sequences as they start and finish. That recovers much of batch inference’s throughput while serving interactive traffic at low latency. So online serving is no longer synonymous with "one request, one underused GPU." Still, a dedicated offline batch job — no latency budget at all, maximal batch size — remains the cheapest way to push a fixed pile of work through a GPU.

→ The cheap default

If the work isn’t interactive, run it as an offline batch job — it’s the lowest cost per token, full stop. Use a real-time endpoint (with continuous batching) only for the traffic that actually has someone waiting on it.

05

The GPU-utilization reality behind the cost

Why is batch cheaper? GPUs are throughput machines: they hit peak efficiency when they have a large batch of work to chew through in parallel, and they waste cycles when fed one small request at a time. A naive online server that runs each request alone leaves the GPU mostly idle between and within requests — you pay for the whole card but use a fraction of it. Batch inference fills the GPU: big batches mean near-100% utilization, which is exactly why cost per token drops.

Continuous batching is the clever middle path — it keeps utilization high by always topping up the batch with whatever requests are in flight, so online serving stops leaving the GPU idle. But there’s still a floor: interactive traffic is bursty and latency-bounded, so you can’t always wait to assemble a perfectly full batch. A pure offline job has no such constraint, which is why "just run it as a batch overnight" remains the move whenever latency truly doesn’t matter.

→ The trade you’re actually making

Real-time buys low latency by accepting lower GPU utilization (and higher cost per token). Batch buys maximum utilization and the lowest cost by giving up interactivity entirely.

06

A worked scenario: a chat product and its nightly jobs

The chat box itself is unavoidably real-time: a user typed a message and is watching for tokens, so you serve it from an online endpoint with continuous batching to keep latency low while still getting decent GPU utilization from concurrent users. Optimizing this for raw throughput at the expense of time-to-first-token would make the product feel broken, so latency wins here.

But the same product has a pile of non-interactive work: embedding the 10M documents behind its retrieval, re-scoring yesterday’s conversations for quality, generating weekly summary emails. None of that has a human waiting, so it runs as batch jobs — huge batches, maximal GPU utilization, lowest possible cost — scheduled off-peak. Same models, two serving modes, chosen per workload by the one question: is someone waiting?

→ The pattern generalizes

Interactive path → real-time (with continuous batching). Bulk, deferred, or scheduled work → batch. Most AI products run both, and the cost win comes from correctly moving everything that can be batch off the real-time path.

The picture

The picture: why static batches leave the GPU idle

step 1step 8 static A idle until C ends B idle C (longest) D and E wait in the queue until step 9 continuous A D joins at step 4 B E joins C busy slot-steps: static 16/24, continuous 24/24
Generated outputs have different lengths. A static batch finishes only when its longest sequence does, so short ones leave their slots idle and new requests wait outside. Continuous batching refills a slot at the next decode step. Here that takes utilisation from 16 of 24 slot-steps (67%) to all 24, without making anyone wait for a full batch to assemble.
By the numbers

Worked example: a nightly job, priced both ways

A product summarises yesterday’s 200,000 support conversations every night: 1,500 input tokens and 150 output tokens each, and the summaries are read the next morning. Using Claude Haiku 4.5’s rates from the site’s LLM API pricing table ($1/$5 per million tokens live, $0.50/$2.50 through the Batch API), trace the bill both ways.

StepQuantityLive endpointBatch API
1Input tokens: 200,000 × 1,500300M300M
2Output tokens: 200,000 × 15030M30M
3Input cost300M × $1 = $300300M × $0.50 = $150
4Output cost30M × $5 = $15030M × $2.50 = $75
5Per night$450$225
6Per month (30 nights)$13,500$6,750
7When results landAs each call returnsWithin the batch window (up to 24 hours at OpenAI and Anthropic)

The tokens are identical, so the saving is exactly the discount: $6,750 a month for changing how the job is submitted. Row 7 is the catch. A batch API promises a window, not a time. If the summaries must be ready by 08:00 and the job starts at 01:00, a 24-hour window does not guarantee the deadline. Submit earlier, as soon as each conversation closes, or keep a fallback that sends any stragglers to the live endpoint near the deadline. The same reasoning applies when you self-host: a nightly job pushed through the live chat endpoint pays full rate and also competes with daytime users for slots, which raises their time to first token.

Trade-offs

Latency, cost and the trade-offs between serving modes

Here Time is the latency a caller sees and Space is the cost and capacity side.

CaseTimeSpaceWhy
Offline batch job (self-hosted)Minutes to hours; no per-request targetLowest cost per token: the batch is as big as memory allowsNo one is waiting, so the scheduler only has to fill the GPU.
Provider Batch APIAsynchronous, up to the provider’s window50% off input and output at OpenAI, Anthropic and GoogleYou trade the deadline for the discount.
Real-time, one request at a timeLowest at light load, then it queuesWorst utilisation: one sequence holds the GPUFine for a prototype, ruinous at scale.
Real-time, static batchesAdds a wait to fill the batch, and short requests wait for long onesBetter utilisation, with idle slots (16/24 in the diagram)Works for fixed-size inputs such as images or embeddings, but poorly for generation.
Real-time, continuous batchingA new request joins at the next stepHigh utilisation; KV-cache memory caps the batchThe standard for LLM serving today.
Precompute and serve from a storeA key lookupPaid once per refresh, whether or not anyone reads itResults are as stale as the last refresh. The recommendations case on this page.

To size a real-time endpoint, use Little’s law: requests in flight = arrival rate × time each request takes. At 50 requests a second and 4 seconds per generation, 200 sequences are in flight at any moment. That is the batch continuous batching has to hold in KV memory, so it tells you how many GPUs you need before you run a single benchmark.

Watch for

Common mistakes with batch and real-time inference

  • Running bulk work through the live endpoint

    It is the path of least resistance, because the endpoint already exists. But a backfill of a million items through it pays full price, and it fills slots that interactive users needed, so their time to first token climbs while it runs. Give bulk work its own queue, its own capacity or the provider’s batch API.

  • A batch job that cannot resume

    A 40-million-row scoring job that dies at 90% and restarts from row one wastes nine-tenths of a night. Write results keyed by input ID as you go, make every write idempotent, and have the job skip IDs that already have a result. Then a crash costs minutes, not the whole run.

  • Treating the batch window as a deadline

    A provider batch can take up to its full window. If the morning dashboard depends on it, either submit early enough that the window ends before the deadline, or watch progress and send the unfinished remainder to the live endpoint.

  • Measuring real-time with the average

    The mean hides the requests that queue behind a long generation. Track p95 and p99, and track time to first token separately from total time: a user watching a stream minds the first far more than the second.

  • Static batching for generation

    A fixed batch finishes when its longest output does. As the diagram shows, the short sequences sit idle and new requests wait. Use an engine with continuous batching for anything that generates text, and keep static batches for fixed-size work.

In the wild

Where this shows up in production and interviews

  • Search and RAG indexing

    One embedding model, two modes. Embedding the corpus is a batch job, re-run when documents change. Embedding the user’s query is real-time, one short input on the critical path. Both must use the same model, or the query vectors and document vectors will not match.

  • Recommendations and feeds

    The usual design is a hybrid. A batch job precomputes candidates for every user overnight, and a light real-time model reranks them at request time using what the user just did. Expensive work happens offline, and only cheap work happens in the request path.

  • Evals and LLM-as-judge

    Grading thousands of model outputs before a release is the textbook batch job. Nobody is waiting on one grade, the volume is large, and half price at the same quality is the obvious choice. Run these on the batch API by default.

  • Interviews

    In a design round, ask first “is anyone waiting on this result?”, then size it. For real-time, use Little’s law to get the number of sequences in flight. For batch, divide total tokens by the window to get the throughput you need. Saying which parts of a product move off the live path is usually the cost answer the interviewer wants.

Your call

Which would you pick?

Three situations. Pick the side you'd actually build — the explanation follows.

Nightly, you must score 40 million users for churn risk. The scores are read the next morning by a dashboard.

A fraud check that must decide before a payment is authorised.

Product wants personalised recommendations "as fresh as possible." Traffic is 5,000 requests/sec and the model is expensive.

Frequently asked

Quick answers

What's the difference between batch and real-time inference?

Batch inference runs the model over many inputs together, offline or asynchronously, optimizing for throughput and cost per token because nobody is waiting on any single result. Real-time (online) inference answers one request at a time, synchronously, while a user or service waits, so it optimizes for latency even at the cost of lower GPU utilization. The deciding question is whether something is blocked on the answer.

Why is batch inference cheaper?

GPUs reach peak efficiency on large parallel batches and waste cycles on single small requests. Batch jobs fill the GPU with big batches, pushing utilization near 100% and driving cost per token down. Real-time serving is bounded by latency and bursty traffic, so it can rarely keep the GPU as full — which is why the same tokens cost more online.

What is continuous batching?

A serving technique (used by engines like vLLM) that dynamically packs many in-flight online requests into a shared GPU batch, adding and removing sequences as they start and finish. It recovers much of batch inference’s throughput while still serving interactive traffic at low latency, so online serving is no longer synonymous with an underused GPU.

Can one system do both?

Yes, and most do. A product serves its interactive path (chat, autocomplete) from a real-time endpoint with continuous batching, and runs its bulk, deferred work (embedding a corpus, nightly scoring, summary generation) as offline batch jobs. The cost win comes from moving everything that does not need to be interactive off the real-time path.

▶  Watch it explained

Batch vs Realtime inference: a bus, or a taxi?

Batch vs Real-Time Inference · Vibe Engines · 2026
Finished this one? 0 / 209 Handbooks done
NextThe Model Routing Handbook Next on the “Serving models, and paying for them” ladder · rung 7 of 13

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Handbooks