How inference servers juggle many users on the same hardware

APIFreeGroqKey · Updated 2026-11-22 · 9 min read

Passengers boarding and leaving a city bus at a stop
Continuous batching lets requests join and leave at every step.

Every hosted model you call, whether on Groq, a big cloud provider or the free endpoint on this site, serves many users on shared hardware. How the server groups those users' requests together, a process called batching, has a huge effect on how many requests it can handle, how much each one costs and how long you wait. It is also a favourite topic in system design interviews for AI infrastructure roles, where candidates are asked to design a high-concurrency inference API with queueing, streaming and rate limits.

This explainer is for application developers who want to understand why hosted APIs behave the way they do, and for engineers preparing to build or operate inference services. We cover why batching helps, the difference between static and continuous batching, the role of the KV cache, how scheduling trades latency for throughput and what all of this means for the code you write against an API.

Frequently asked questions

What is batching in LLM inference?

Batching means processing several requests together in one pass through the model. Because generating each token requires reading the model's weights from memory, sharing that read across many requests makes much better use of the hardware than serving them one by one.

How does continuous batching differ from static batching?

Static batching waits for a group of requests, runs them together and returns when all finish, so short requests wait for long ones. Continuous batching adds and removes requests at every generation step, so a finished request leaves immediately and a new one can join.

What is the KV cache?

During generation the model stores intermediate key and value tensors for every token processed so far, so it does not recompute them for each new token. This cache grows with context length and batch size and is often what limits how many requests fit on a device.

Does batching make my request slower?

It can add a little latency per token because the server is doing more work per step, and you may wait in a queue for a slot. In exchange, the provider serves far more users per device, which is what makes cheap or free access possible.

What is the difference between throughput and latency here?

Throughput is total tokens per second across all users. Latency is how long one user waits. Larger batches raise throughput but can raise latency. Schedulers balance the two according to the provider's goals.

Why do providers limit parallel requests per user?

Each parallel request occupies a batch slot and KV cache memory. Limiting parallelism per key or IP keeps a single client from crowding out everyone else and keeps latency predictable for the rest.

Do specialised chips still use batching?

Most serving systems batch to some degree. Designs that keep weights in very fast on-chip memory reduce the penalty of reading weights per token, which changes the trade-offs, but grouping work still improves efficiency.

Can I batch requests on the client side?

For independent short tasks you can combine several items into one prompt, such as classifying ten texts at once, which saves overhead. For true server-side batching, some providers offer batch APIs with lower prices and delayed results.

Why one request at a time wastes hardware

Generating a token means running the full model once. For a model with tens of billions of parameters, that requires reading all the weights from memory for every single token. On GPUs, memory bandwidth, not arithmetic, is the bottleneck during this decode phase. If the server handles one request, the arithmetic units sit mostly idle while weights stream through.

Batching fixes this. If sixteen requests are decoded together, the weights are read once and used sixteen times. The cost per token falls dramatically while the time per step rises only modestly. This is the main reason hosted inference can be offered cheaply, and why a single user running a model at home often sees lower efficiency than a busy provider.

Prefill is different

Processing the prompt, known as prefill, handles many tokens at once and is already compute-heavy. Batching prefill helps less, and long prefills can stall decode for other users, which is why schedulers treat the two phases separately.

Static batching and its problem

The simplest approach collects requests until a batch is full or a timeout passes, runs them together and returns all results at the end. It is easy to implement and works for offline jobs where every item has similar length.

For interactive traffic it is a poor fit. Requests have very different output lengths. A batch containing one five-hundred-token essay and fifteen ten-token answers keeps all sixteen slots busy until the essay finishes, so most of the batch does useless padding work, and the short requests wait far longer than necessary.

Padding waste

Inputs in a static batch are padded to the same length. With varied prompt sizes, a large share of computation goes into padding tokens that produce nothing. Bucketing requests by length reduces but does not remove this waste.

Where static batching still fits

Offline jobs such as embedding a whole document collection or scoring a test set have no waiting user. Grouping similar-length items into fixed batches is simple and efficient there, and many batch APIs work this way behind the scenes.

Oven tray with loaves of different sizes and doneness
Static batching makes short jobs wait for the longest one.

Continuous batching: joining and leaving every step

Continuous batching, sometimes called in-flight batching, schedules at the level of individual generation steps. After each step, the server removes requests that have finished and inserts waiting requests into the free slots. Short answers return as soon as they are done, and the hardware stays busy.

This change alone can multiply throughput on real traffic compared with static batching, and it is now standard in popular open-source serving engines. It also makes streaming natural: each step produces one token per active request, which is sent straight to the client.

Chunked prefill

A new request's prompt must be processed before it can join decoding. Splitting long prompts into chunks and interleaving them with decode steps prevents one huge prompt from freezing the stream for everyone else.

Preemption

When memory runs short, the scheduler may pause a request, drop its cache and recompute it later, or move it to slower memory. You see this as an occasional stall in an otherwise smooth stream.

The KV cache sets the real limit

Each active request keeps a cache of attention keys and values for every token it has seen. For long contexts and large models, this cache can rival the model weights in size. The number of requests a server can batch is therefore limited less by compute than by how much cache memory remains after loading the weights.

Techniques such as paging the cache in fixed-size blocks, sharing cache blocks for identical prompt prefixes and quantizing the cache all aim to fit more requests in the same memory. Prefix sharing is why some providers offer discounts for repeated system prompts: the shared part is computed once and reused.

Why context limits exist

The keyless endpoint here caps context at 32,000 tokens and output at 16,000. Limits like these keep cache use per request bounded, so many users can be served at once on shared hardware.

  • Longer contexts mean fewer concurrent requests per device
  • Shared prefixes, like a common system prompt, can be cached once
  • Context limits on public APIs partly reflect cache memory budgets
  • Very long outputs hold their slot for a long time
Warehouse shelves with equal-sized boxes in blocks
Paged caches store attention data in fixed-size blocks.

Scheduling: the throughput versus latency dial

A scheduler decides how large batches get and which requests go first. Bigger batches mean more total tokens per second but slower steps, so each user's stream slows down. Smaller batches feel snappier but serve fewer people. Providers tune this according to their product: a premium low-latency service keeps batches smaller, a cheap bulk service runs them larger.

Fairness matters too. Without limits, one client sending hundreds of parallel requests could take most slots. That is why APIs combine per-client parallelism caps with request rate limits. The free endpoint here, for example, allows two parallel requests and one request per second per IP, with short bursts of three.

Priority classes

Some services give paying or interactive traffic priority over free or batch traffic. Free users then see longer queues at busy times. If you depend on predictable latency, a paid tier with an SLA is the only real guarantee.

Burst allowances

Small bursts above the steady rate are usually tolerated so that a page opening several requests at once does not fail. Sustained traffic above the rate gets 429 responses with a Retry-After header telling the client how long to wait.

What specialised hardware changes

Fast-inference providers built on custom chips approach the bandwidth problem differently. Groq, for instance, designed its own processors that hold model data in large amounts of on-chip memory and run with a deterministic schedule, which reduces the per-token cost of reading weights and is a big part of its low-latency reputation. Questions about where such chips fit alongside GPUs, which serve prefill-heavy and memory-heavy work well, come up often among infrastructure engineers.

The details of any provider's internal serving stack are their own; this site is not affiliated with Groq and has no inside view of it. For application developers the practical point is simple: different providers make different trade-offs between speed per request, throughput and price, and you should measure them on your own workload. Our guide to benchmarking providers on your prompts shows how.

Per-request speed versus aggregate throughput

Headline figures sometimes describe tokens per second for one request, sometimes total throughput across a node. They answer different questions. A system can give one user a blazing stream while serving fewer users in total, or the reverse.

Mixing desk with sliders at different positions
Schedulers balance throughput against per-user latency.

What this means for your application code

Understanding batching explains several behaviours you will see from any hosted API, and suggests how to write clients that work well with them.

Pack small tasks into one prompt

If you need labels for twenty short texts, sending them in one request with a numbered list is often faster overall than twenty separate calls, especially under a one-request-per-second limit. Validate the output carefully, since one malformed answer affects the whole set.

  • Expect latency to vary with load; measure percentiles, not single runs
  • Keep prompts lean so your request prefills quickly and frees cache sooner
  • Respect parallelism caps; extra concurrent requests just queue or fail
  • Retry 503 responses after a short delay, as the server is full right now
  • Set max_tokens to what you need so slots are not held needlessly
import time
import requests

URL = "https://api.apifreegroqkey.com/v1/chat/completions"

def ask(prompt, attempts=4):
    body = {"model": "free-ai", "messages": [{"role": "user", "content": prompt}], "max_tokens": 200}
    for i in range(attempts):
        r = requests.post(URL, json=body, timeout=60)
        if r.status_code == 429:
            time.sleep(float(r.headers.get("Retry-After", 2)))
            continue
        if r.status_code == 503:
            time.sleep(2 + i)  # server busy: wait 2-5 seconds
            continue
        r.raise_for_status()
        return r.json()["choices"][0]["message"]["content"]
    raise RuntimeError("service busy, try later")

print(ask("In one sentence, what is a KV cache?"))

Further steps if you are designing a serving system

If you are on the other side, designing an inference API, the core components are a request queue with admission control, a scheduler implementing continuous batching, a KV cache manager, a streaming layer that pushes tokens to clients and a rate limiter per client. Autoscaling adds capacity when queues grow, and metrics on queue time, time to first token and tokens per second tell you when it is needed. Our article on time to first token explains the metric users feel most.

Open-source serving engines implement most of this already, and studying their schedulers is a good way to learn. If you are deciding whether to run such a stack yourself at all, see self-hosting versus a hosted API.

Measure queue time separately

Users experience queue time and prefill time as one wait. Logging them separately on the server tells you whether you need more capacity or just better scheduling.

Queue at a museum turnstile
Rate limits and parallel caps keep shared capacity fair.
Try the free API

Send a request to the keyless free-ai endpoint from the home page and see how it fits your project, no sign-up needed.

Read also