Ailoot Engineering
A practical guide to balancing throughput, latency, and cost in LLM inference, including the hardware, model, and scheduling choices that shape deployment trade-offs.
Scaling traditional web services often involves placing a load balancer in front of stateless microservices and adding CPU instances as traffic grows. Large language models change this approach because inference is stateful, can be bottlenecked by memory bandwidth, and depends on physical hardware interconnects. Scaling LLM inference involves a multi-dimensional optimization problem.
The classic trilemma
Increasing throughput can increase latency. Reducing latency can increase GPU costs. Optimizing cost can require compromises in one of the other two dimensions.
This tension among throughput, latency, and cost is a central engineering challenge in dedicated LLM hosting. Understanding it helps teams scale while accounting for economics and infrastructure budgets.
This guide explains the trade-offs, the different dimensions of inference cost, the choices that affect cost, and how hardware selection and benchmarking can help reveal the cost surface. It also discusses when to optimize for throughput or latency and the associated trade-offs.
What does “cost” actually mean in LLM inference?
In standard web hosting, costs often increase with traffic as more servers are added. In LLM hosting, cost is a multi-dimensional metric. Inference costs are often expressed as dollars per million tokens, but the cost of serving an LLM on dedicated infrastructure includes at least four dimensions.
Capital cost (CapEx): paying for the full node
This is the hardware cost. Because GPUs are connected by high-speed interconnects such as NVLink, capacity may need to be purchased in node-sized units. For example, an 8-GPU H100 node may be a single purchase even if a 70B model needs only four GPUs. The model may use only part of the cluster’s capacity, while the full capacity still incurs a cost.
Operational cost (OpEx): electricity and cloud costs
Owning hardware involves ongoing power and cooling costs, while renting it shifts those costs to hourly rates. Cloud rental is an OpEx alternative; the cost of idle capacity remains a challenge for OpEx efficiency.
Opportunity cost: the utilization gap
Every minute a GPU sits idle during low-traffic hours is paid-for capacity that is not being used. Because dedicated hardware may be difficult to share across models without performance impacts, bursty traffic can create a gap between paid-for capacity and actual use.
Without orchestration or serverless-on-dedicated setups, limited multi-tenancy on dedicated nodes can reduce return on investment.
Autoscaling can therefore serve as a cost-optimization tool as well as a reliability mechanism. For example, a coding assistant serving North American developers might scale down to a single replica between 2 a.m. and 6 a.m. Pacific time, reducing idle GPU hours.
Engineering cost: specialized labor
Engineering cost is often underestimated. Beyond the hardware, specialized labor is needed to tune deployments. Finding an appropriate configuration for vLLM or TensorRT-LLM can require substantial systems engineering time.
The software stack involves tasks such as profiling with Nsight and managing CUDA versions. Benchmarking can also require considerable engineering time, even when the goal is to reduce monthly GPU costs.
The levers that dictate cost
Model architecture, quantization, parallelism, and batching account for much of the cost variation between deployments. These choices connect engineering decisions with economics.
Model architecture: dense vs. MoE
For dense models such as Llama 3 70B, cost scales with memory and VRAM requirements. For mixture-of-experts (MoE) models such as DeepSeek-V3, communication can be a major factor. A dense 70B model activates all 70 billion parameters for every token. DeepSeek-V3 has 671B total parameters but activates about 37B per token, changing the cost equation.
At two bytes per BF16 parameter, a 70B model needs roughly 140 GB for its weights. Two 80 GB H100 GPUs have 160 GB combined, and an MI300X has 192 GB. Check the usable memory left for the KV cache and runtime buffers before choosing a configuration. Llama 4 Maverick has 400B total parameters and 17B active per token. Storing its weights in BF16 alone would take about 800 GB, beyond the 640 GB of eight 80 GB GPUs. Size the deployment from usable memory per card and measured runtime needs.
For dense models, the cost challenge is memory: every parameter is activated for every token, so cost depends on how quickly the GPU can move weights from HBM to its compute cores. Low memory bandwidth can increase latency.
For MoE models, the challenge shifts from raw compute to communication. Because only a subset of experts fires for each token, total compute may be modest. However, experts are distributed across GPUs, requiring “all-to-all” routing patterns that can put pressure on the interconnect.
Quantization: trading precision for efficiency
FP8 can roughly halve raw weight storage compared with BF16. Total VRAM also depends on the KV cache, runtime buffers and any quantization metadata.
FP8 (E4M3/E5M2) is used in production. DeepSeek-V3 was natively trained in FP8, and models such as Qwen3 have official FP8 checkpoints. The Qwen3-235B-A22B-FP8 model card is listed in the references.
On supported accelerators (H100, H200, B300, MI300X), FP8 can increase decode throughput while keeping quality within acceptable bounds, depending on the model and workload.
INT4 (GPTQ, AWQ) compresses weights by a factor of four, but can reduce quality on multi-step reasoning tasks where rounding errors compound. MXFP4/NVFP4 uses block-scaled microscaling; native support requires Blackwell or MI350X GPUs.
Parallelism strategy: tensor, expert, and data parallelism
How a model is distributed across GPUs affects both hardware cost and latency.
- Tensor parallelism (TP) shards weight matrices across GPUs within each layer. All GPUs work on every token, reducing per-token latency but requiring AllReduce synchronization and a high-bandwidth interconnect. It scales poorly beyond 8 GPUs.
- Expert parallelism (EP) places different MoE experts on different GPUs. This can use bandwidth more efficiently than TP because only activated experts communicate, but it can cause load imbalance when some experts receive more work.
- Data parallelism (DP) serves different requests on separate model replicas. Throughput can grow when requests are balanced and shared resources have spare capacity. Measure latency under load.
Choosing a cost-effective parallelism strategy means matching the model architecture to deployment goals. For a dense 70B model where latency is critical, one option is tensor parallelism across a single 8-GPU node (TP=8). For a throughput-heavy MoE deployment, EP can help fit the model’s weights, paired with DP to scale request handling.
Batching and scheduling
In the memory-bound part of decode, a batch can reuse weight reads across several sequences. Increasing batch size can raise throughput until another resource becomes a bottleneck.
Near the saturation point, B_sat, additional sequences may yield less throughput and higher latency. Continuous batching and chunked prefill can change where that trade-off appears.
Sweep batch sizes on the same workload. Compare throughput and tail latency at each size to find where further throughput gains become small or latency exceeds the target.
When to optimize for throughput vs. latency
There is no universal answer: the right choice depends on the workload, users, and business model.
Two principles help explain LLM performance:
- Little’s Law: connecting QPS, latency, and concurrency
Average in-flight requests = QPS * mean end-to-end time in seconds
At a steady 10 requests per second with a mean end-to-end time of two seconds, about 20 requests are in the system on average, including any waiting in a queue. Estimate KV-cache needs from active sequences and their context lengths.
If a benchmark shows that one replica sustains 16 QPS within the latency target, a demand of 100 QPS requires at least seven such replicas before spare capacity. Test the whole deployment under realistic traffic.
- The Roofline Model
The Roofline Model identifies whether performance is capped by processing power (compute-bound) or by the speed of data movement (memory-bound). This distinction can help guide hardware decisions.
The model maps to the two phases of LLM inference as follows:
| Phase | Bottleneck | Efficiency target |
|---|---|---|
| Prefill (input) | Compute | Process prompt chunks in parallel |
| Decode (output) | Memory | Reuse weight reads across batched sequences |
Latency-sensitive workloads
Latency matters for interactive chat, code completion, real-time agents, search augmentation, and other user-facing applications.
Key SLO metrics include TTFT (time to first token) and ITL (inter-token latency). Users perceive TTFT as responsiveness and ITL as streaming speed.
How to tune
Keep batch sizes moderate because queuing can delay TTFT.
- Limit batch size to stay well below the B_Sat “knee.”
- In latency-critical applications, optimize for P99 tail latency, not average throughput.
- Every request added to a batch increases the possibility of a prefill spike that delays other users’ tokens.
Use TP to minimize per-token latency, with all GPUs working on every token.
- Scale tensor parallelism (TP) within a single NVLink-connected node.
- Once you cross nodes using Ethernet or InfiniBand, GPU communication overhead can increase ITL.
- For latency-sensitive tasks, keep the model on the smallest number of GPUs that provides the necessary memory bandwidth.
Enable chunked prefill to prevent long prompts from blocking decode steps.
- Without chunking, a large prompt (for example, a 20k-token document) can occupy the GPU until its prefill finishes, making other users wait.
- Breaking prompts into smaller chunks (for example, 512 tokens) lets the engine interleave prefill work with decode steps for other active requests.
- This can help keep inter-token latency (ITL) consistent and let the scheduler fill otherwise-unused GPU compute cycles, balancing the high arithmetic intensity of prefill with the memory-bound nature of decode.
Consider speculative decoding to reduce effective ITL.
- Speculative decoding uses a draft model to predict tokens ahead of time, trading compute efficiency for lower ITL.
- This trades compute efficiency (OpEx cost) for lower ITL (latency).
Provision some extra capacity to handle traffic bursts without queuing.
- This can increase cost per token through lower utilization, but may be necessary to meet user experience requirements.
Throughput-sensitive workloads
Throughput can take priority for batch summarization, offline data extraction, synthetic data generation, evaluation pipelines, and workloads where total job completion time matters more than individual request latency.
Tokens per second (or tokens per dollar) is the primary metric. Individual request latency is secondary as long as the total batch completes within the required time window.
How to tune
Choose the batch size using measured throughput and the workload’s latency or completion-time budget.
- Batching can reuse weight reads across sequences when memory bandwidth is the bottleneck.
- Increasing batch size performs more arithmetic operations for each byte of weight data loaded.
- Test around the measured saturation point, B_sat, with a representative mix of requests.
- Use the setting that gives the highest measured aggregate throughput while meeting the job deadline and any per-request latency limit.
Add data-parallel replicas to raise aggregate throughput.
- Data parallelism serves different requests on separate replicas. A replica can span several GPUs. DP can be combined with TP or, where supported, EP.
- Four independent replicas serving 1,000 tokens per second each have an ideal combined rate of 4,000 tokens per second. Measure the actual rate under shared infrastructure and real traffic.
- Account for communication introduced by TP or EP and for shared resources when measuring throughput at scale.
Increase the limit for concurrent token processing during prefill to handle large prompt chunks more efficiently and maximize GPU utilization.
- Prefill is the most compute-intensive part of the process. To maximize throughput, aim to keep the GPU’s Tensor Cores occupied.
- Processing large chunks of tokens simultaneously can keep the GPU busy, maximizing the FLOPS used per second.
Use aggressive quantization (INT4/GPTQ) if quality requirements permit. The throughput gain from fitting more in memory may outweigh the accuracy cost.
- Throughput depends in part on how many sequences fit in VRAM.
- Quantize model weights and configure KV-cache precision separately according to what the inference engine and hardware support.
- Benchmark concurrency, throughput and latency at your actual context lengths to see whether quantization reduces cost per token.
- Evaluate the model after quantization to confirm the accuracy impact is acceptable.
Minimize over-provisioning and run GPUs at high utilization when queuing is acceptable.
- In batch workloads, queuing can be useful.
- A queue ensures that when one request finishes, another is ready to take its place.
- Without a person waiting for a response, the latency spike at high utilization may be acceptable.
- Success is measured by the total time to complete the entire job, which is minimized when the GPU does not sit idle.
The hybrid reality
Most production systems combine latency-sensitive and throughput-sensitive workloads. A deployment might serve interactive chat during business hours and run batch evaluation jobs overnight.
A cost-effective approach can use workload-aware scheduling:
- Dynamic autoscaling: Scale up GPU replicas during peak interactive hours and down during off-peak hours. The autoscaler can respond to both queue depth (reactive) and traffic forecasts (predictive).
- Priority queuing: Serve interactive requests at lower latency while processing batch requests in the background when spare capacity exists.
- Workload-specific configurations: Run separate vLLM instances with different tuning parameters—one for low-latency interactive traffic and another for high-throughput batch processing.
A decision framework
How can you make a decision given these trade-offs? This framework can help:
Step 1: Characterize your workload
Consider ISL/OSL distribution, QPS requirements (average and peak), and latency SLOs (TTFT and ITL at p50, p95, and p99).
Step 2: Select your model and quantization
Start with the smallest model that meets your quality requirements. Benchmark FP8 first, since it may offer efficiency benefits with a small accuracy trade-off. Use BF16 if testing shows a quality regression with FP8.
Step 3: Benchmark on candidate hardware
Run your ISL/OSL sweep at varying QPS on at least two hardware options. Use measured throughput under your workload to guide the decision.
Step 4: Find the knee
For each hardware option, identify the maximum QPS that stays within your latency SLOs. This is the sustainable capacity per instance.
Step 5: Size your deployment
Estimate the replica count from peak traffic and each replica's measured QPS within the latency target. Keep spare capacity so a burst can be absorbed while individual replicas operate within that target.
Step 6: Calculate total cost
TCO_per_token = (capital allocated to period + operating costs + engineering costs) / tokens served in the same period
Compare the figures across hardware options. The least expensive GPU does not always produce the least expensive deployment.
Step 7: Plan for autoscaling
For variable traffic, design autoscaling policies that trade cold-start latency for cost savings during off-peak hours. Use spare capacity for batch workloads.
Build for your workload, not the benchmark
The throughput-latency-cost trilemma is a tension to manage. Every configuration choice shifts the balance among the three dimensions, and there is no universally perfect configuration.
Teams can make better deployment decisions by benchmarking and characterizing workloads using specific prompts, models, and hardware rather than relying on spec sheets alone.
Serving frameworks and hardware continue to evolve, but the fundamental physics of LLM inference remain the same. Benchmarking and tuning against the metrics that matter to a business can help teams navigate the trade-offs.
References
- NVIDIA DGX H100 User Guide (official)
- DeepSeek-V3 technical paper
- Qwen3-235B-A22B-FP8 model card: https://huggingface.co/Qwen/Qwen3-235B-A22B-FP8
- NVIDIA Blackwell whitepaper
- AMD Instinct MI350X specifications and launch information
Ailoot · The company and its project portfolio
Ailoot combines established operating experience, a large client base, stable service and ongoing KPI control.
The company and its project portfolio: millions of customers; monthly sales in the billions.
Ailoot brings that operating experience to API access for AI features in customer products, agents, applications and automations.
Originally published on Ailoot. The LLM Inference Trilemma: Throughput, Latency, Cost
Explore Ailoot’s LLM inference API. Ailoot issues one API key for 1,284 models and variants across 15 categories, making it one of the world’s largest AI routers by model count. The same key covers GPT, Claude, Gemini, Grok, Qwen and DeepSeek, plus Nano Banana for photos, Veo for video, Eleven v4 for speech, Suno for music, Tripo3D for 3D and BGE for search.
“llm inference api” — Put GPT, Claude, Gemini and DeepSeek to work in your app through one Ailoot key. Add document analysis, images, speech and video from the same balance.
Use Ailoot Arena to compare models and agents, or bring Ailoot into an editor, CLI, SDK or automation tool through one of 77 integrations.
Ailoot adds new flagship models at launch, and one subscription covers the full catalogue. Find a promo code in your account at https://ailoot.ai/. Ailoot subscriptions and promo codes offer up to 50% off official provider API prices.
Top comments (0)