# Latency vs Throughput Trade-Off

> Why a server that serves more users at once can make each user wait longer, and how to pick a setting for chat or for batch work, explained simply for your AI interview.

**In short:** Latency is how long one user waits. Throughput is how much work the whole server finishes in a set time. Sharing more requests in one batch raises throughput but usually makes each user wait longer, so teams pick a setting for live chat or for batch jobs.

AI and LLM interview question Q317, Inference, performance and cost. Intermediate, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/the-latency-vs-throughput-trade-off

## Say it in 30 seconds

Latency is how long one user waits. Throughput is how much work the whole server gets done. They pull against each other: when the server groups more requests into each run, it finishes more in total, but each user waits longer. So for a live chat I keep latency low, and for a big overnight job I push throughput up and accept the wait, using the batch option the provider offers.

## Say it in 2 minutes

Latency is the time one person waits for an answer. Throughput is the total work the system finishes in a set time, across everyone. A chat assistant cares most about latency, because a support agent is watching the screen. A nightly job that tags two hundred thousand claim notes cares about throughput, because nobody is waiting and the job just has to finish by morning.

The two pull against each other. A GPU, the chip that runs AI models, works more efficiently when it runs many requests together in one batch, where each step gives one new token to every request in it. Total output rises, but each step takes a little longer, so each user sees fewer tokens a second. In my made-up example, one user gets about 25 tokens a second alone, and about 14 when 64 share the server. The server's total goes from about 25 to about 890.

So I split the work. Chat goes to its own low-latency lane with a small batch. I watch the time to first word, and its 95th percentile, which is how long one chat in twenty waits at least. The nightly job goes to a batch queue. OpenAI's Batch API gives a 50% cost discount, and each batch completes within 24 hours. Anthropic's batches can take up to 24 hours too, though many finish sooner.

I'd be honest that there is no free setting. Pick the target that matters, measure it on real traffic, and say which users pay for the other.

## What are latency and throughput, in plain words?

Both are measures of speed, but they look at different things. Latency is about one person: how long they wait. Throughput is about the whole queue: how much work gets finished in a set time.

A hospital lab is a good picture. A technician who runs one blood test at a time gets each result fast. A machine that runs 200 samples in one cycle finishes far more tests per hour, but every sample waits for the cycle to end. An AI server works the same way, and the shared run is where the trade-off comes from. In an AI server, a chat reply and a nightly job share the same batch run.

- **Latency:** How long one request takes, from sending it to receiving the complete answer.
- **Time to first token (TTFT):** How long until the first word appears. This is the wait a chat user feels most.
- **Throughput:** Total tokens the whole server makes per second, across all its users.
- **Batch:** Several requests that the server runs together in one step.
- **Token:** A small piece of text, about a word or part of one, that the model reads or writes one at a time.

## Why do they pull against each other?

A batch is shared. When the server adds more requests to it, the server makes more tokens in total each second. But every step now carries more work, so each request gets its next token a little later.

*Diagram, One server, two batch settings: One server, two settings. A small batch keeps each user's wait short. A large batch makes more tokens in total, and each user waits longer. The chart shows the choice only, with no measured numbers.*
1. Some requests land on the small batch, which runs a few at a time.
2. Other requests join the large batch, which runs many at once.
3. Each step is quick, so every user sees more tokens a second.
4. Each step is slower, so every user sees fewer tokens a second.
5. The same work adds up across users: total output rises.

A queue adds a second effect. Once more requests arrive than the batch can hold, the extra ones wait for a free slot, and their first words come later still. NVIDIA's benchmarking guide says throughput saturates around the maximum batch size.

> "Therefore, the throughput of the system generally saturates around the maximum batch size while the latency will continue to steadily increase." (NVIDIA, LLM inference benchmarking)
>
> "High throughput serving of large language models (LLMs) requires batching sufficiently many requests at a time." (Kwon et al., PagedAttention paper (2023))

The paper explains why servers batch at all: high throughput needs many requests in one run. NVIDIA's guide shows the cost: past a point, more load adds almost no throughput and only adds delay.

## What does batching do to a server's numbers?

Here is a made-up server with invented numbers. Each step costs 40 ms, plus 0.5 ms for every request in the batch. The script prints what one user sees, and what the whole server makes.

```python
# A made-up GPU server. Each step gives one new token to every request in the batch.
# Assumed numbers (made up): a step takes 40 ms, plus 0.5 ms for each request in it.
BASE_MS = 40.0
PER_REQUEST_MS = 0.5

def step_ms(batch):
    return BASE_MS + PER_REQUEST_MS * batch

print("batch  per-user tok/s  total tok/s")
for batch in (1, 8, 32, 64):
    per_user = 1000 / step_ms(batch)   # tokens one user sees each second
    total = per_user * batch           # tokens the whole server makes each second
    print(f"{batch:>5}  {per_user:>15.1f}  {total:>11.1f}")
```

Output:

```text
batch  per-user tok/s  total tok/s
    1             24.7         24.7
    8             22.7        181.8
   32             17.9        571.4
   64             13.9        888.9
```

1. **Read the top row:** One user on its own gets 24.7 tokens a second, and the server makes 24.7 in total.
2. **Read the bottom row:** With 64 users, each one drops to 13.9 tokens a second, but the server makes 888.9. That is about 36 times the total.
3. **Ask who is waiting:** A chat user sits near the top rows. A batch job can sit near the bottom, because nobody is typing.

Real numbers depend on your model and hardware, so you measure the base cost and the per-request cost yourself. The shape of the trade-off is what carries over.

## How do you choose: live chat or a batch job?

Decide by who is waiting. If a person is watching the screen, optimise for latency. If nobody is waiting, optimise for cost and total work. OpenAI's and Anthropic's batch options are built for the second case.

*Diagram, Chat and batch jobs take different paths: Two jobs, two paths. The chat reply goes to a live endpoint and comes back in seconds. The nightly tagging goes to a batch queue, which trades the wait for a lower price. The volumes are made up.*
1. The question goes straight to the live path.
2. The job is queued with the other batch work.
3. The answer streams back in seconds.
4. Results arrive when the whole batch finishes.

OpenAI's Batch API sends groups of requests asynchronously. It gives a 50% cost discount and completes each batch within 24 hours, often sooner. The price is the wait, so a batch queue never suits someone typing a question.

> "Batches might take up to 24 hours for processing, but many complete sooner." (Anthropic, batch processing)

> **Tip:** In an interview, state the rule first: if a person is waiting, you optimise latency; if nobody is, you batch for throughput and cost.

### How would you run chat and a nightly job on one set of GPUs?

Give them separate lanes. A small-batch pool keeps chat latency steady, and the batch lane fills the spare capacity overnight. Mixing both in one queue lets a big job hold the batch and make chat replies wait.

- **Mixed in one queue: Chat waits behind the job.** The big job fills the batch, so each chat user's first word arrives late.
- **Two lanes: Each lane keeps its target.** Chat keeps a small batch and a latency target. The nightly job runs on spare capacity and has a deadline.

Measure both lanes separately: time to first token for chat, and whether the job finishes before the deadline.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain definition: latency is one user's wait, throughput is total work per second.
- [ ] Why they trade off: a shared batch adds total output but slows each step for every user.
- [ ] Which numbers to watch: time to first token and its 95th percentile for chat, jobs finished by the deadline for batch.
- [ ] The choice depends on who is waiting, and the answer names a setting you would change.
- [ ] Batch options trade time for price, so they never suit live replies.

**Common traps**

- Trap: "Bigger batches are always faster." Better: Bigger batches raise total output, but each user waits longer. Faster depends on which number you mean.
- Trap: "Throughput is just another word for speed." Better: Throughput counts the work of all users; latency counts one user's wait. A fast total can hide slow replies.
- Trap: "Put everything in one queue to save money." Better: One queue makes chat wait behind the big job. Split the lanes so each keeps its own target.

## Can you spot the slow tail?

**Spot the problem:** Your support dashboard looks healthy overall. Which line shows a user still waiting too long?

A. Cluster throughput: 920 tokens a second, up 12% this week.
B. Requests served today: 41,200, with no failed calls.
C. p95 time to first token: 9.8 seconds, so one chat in twenty waits at least that long for a first word.
D. GPU memory use: 71% on each node.

**Answer:** C. The first, second and fourth lines describe the whole server. The 95th percentile shows the slow tail: one chat in twenty waits almost ten seconds for its first word. Track p95 time to first token for chat.

**Quick check:** A chat assistant feels slow, and the same server also runs a nightly job. What is the best first change?

A. Raise the batch size on the chat pool so more users share it
B. Move the nightly job to a batch queue and keep chat on its own low-latency lane
C. Switch the chat to a bigger model
D. Turn up the sampling temperature

**Answer:** B. The job fills the shared batch and delays chat. Splitting the lanes gives chat its own latency target. A bigger batch, model or temperature does not remove the wait.

## Can you answer these from memory?

**Flash cards**

- **What is latency?** How long one user waits for the full answer.
- **What is throughput?** Total work the whole server finishes per second, across users.
- **Why do they trade off?** A shared batch adds total output but slows each step for everyone.
- **Which number for chat?** Time to first token, and its 95th percentile (p95).
- **Which path for a nightly job?** A batch queue: 50% cheaper, and it can take up to 24 hours.
- **Can the Batch API serve live chat?** No. A person waiting needs the live path, not a queue.

## Likely follow-up questions

- Q316 TTFT vs tokens/sec vs total latency? https://designervenkat.online/interview/ai/ttft-vs-tokens-per-second-vs-latency
- Q344 What is a p95/p99 latency budget? https://designervenkat.online/interview/ai/what-is-a-p95-p99-latency-budget
- Q369 How do you design for low latency? https://designervenkat.online/interview/ai/how-do-you-design-for-low-latency
- Q340 How do reasoning tokens affect cost and latency? https://designervenkat.online/interview/ai/how-do-reasoning-tokens-affect-cost-and-latency
- Q272 How do you track latency and cost in evals? https://designervenkat.online/interview/ai/how-do-you-track-latency-and-cost-in-evals

## Learn it in depth

- [Watching cost and speed](https://designervenkat.online/learn/ai-engineering/cost-latency-monitoring)
