Breaking Down LLM Inference Service Costs: From Hardware Selection to Pricing Strategies
This article deconstructs the components of Large Language Model (LLM) inference service costs, analyzing hardware selection trade-offs, common throughput optimization techniques, and cost-based pricing strategies. It provides a practical cost estimation example, compares self-hosting with managed services, and outlines a pre-launch checklist to help engineering teams optimize infrastructure utilization and manage expenses effectively.
1. Components of Inference Costs
Inference costs can be broken down into four categories: depreciation or rental fees for accelerator cards, concurrency limits determined by memory and bandwidth, power and data center overhead, and the operational investment of the engineering team. The theoretical cost per token is calculated by dividing the hardware cost per unit of time by the effective throughput. Effective throughput depends on utilization. If requests are sparse and utilization is only 20-30%, the cost per token will be significantly higher than at full load. Therefore, improving utilization is often more effective at reducing costs than simply lowering hardware prices.
2. Trade-offs in Hardware Selection
When selecting accelerator cards, three dimensions must be compared. The single-card memory capacity determines the size of the model that can be loaded and the number of requests a single batch can accommodate. Memory bandwidth affects the generation speed during the decoding phase. The interconnect bandwidth between multiple cards determines the communication overhead during tensor partitioning. There are differences between NPUs and general-purpose GPUs in terms of ecosystem maturity, operator coverage, and driver versions. Before migration, you should verify whether the operators required by the target model have been adapted; otherwise, performance estimates based on theoretical peak values will deviate significantly from reality. It is recommended to conduct a round of benchmark testing under real business workloads before deciding on the scale of procurement or rental.
3. Common Methods for Improving Throughput
- Continuous Batching: Dynamically merging requests of different lengths to reduce idle time of compute units.
- KV Cache Management: Reusing caches for requests with shared prefixes to reduce time-to-first-token (TTFT) and eliminate redundant computation.
- Quantization: Compressing weights from 16-bit to 8-bit or 4-bit can reduce memory footprint and increase batch sizes, but an evaluation set must be used to verify whether the accuracy loss is acceptable.
- Replicas and Elastic Scheduling: Automatically scaling the number of instances based on load to avoid idle costs during off-peak hours.
The following example estimates the cost per million tokens. The numbers used are hypothetical and only serve to illustrate the calculation method:
def cost_per_million_tokens(hourly_price, tokens_per_second, utilization):"""Estimate the inference cost per million tokens, unit matches hourly_price."""effective_tps = tokens_per_second * utilizationtokens_per_hour = effective_tps * 3600return hourly_price / tokens_per_hour * 1_000_000# Assumptions: 10 USD/hour, theoretical throughput 2000 token/sprint(round(cost_per_million_tokens(10, 2000, 0.6), 2)) # 60% utilization, approx 2.31print(round(cost_per_million_tokens(10, 2000, 0.2), 2)) # 20% utilization, approx 6.94
As shown in the example, with the same hardware and throughput, reducing utilization from 60% to 20% increases the unit cost by about 200%. This indicates that scheduling strategies and request distributions often have a greater impact on cost than the unit price difference of the hardware itself.
4. Deriving Quota Pricing from Costs
The basic logic of quota pricing is: under the target gross margin, the unit price should not be lower than the unit cost divided by (1 minus the target gross margin). During calculation, additional overheads such as cold starts, failed retries, and cache misses must be reserved; otherwise, deviations will occur between theoretical pricing and actual billing.
The purpose of tiered quotas is to guide users toward stable and predictable usage, smoothing the overall utilization curve. During design, tiers can be divided into Basic, Advanced, and Professional, with each tier corresponding to different concurrency limits, response priorities, and model versions, rather than just adjusting the total quota number. This not only protects the resource pool but also allows users of different scales to find a matching plan.
5. Self-Hosted Deployment vs. Managed Services
The cost advantage of self-hosted deployment only manifests when the daily token volume is stable and sufficiently high. When usage fluctuates significantly or the team lacks operational capabilities, calling a managed service is usually more economical. When evaluating, hidden costs should be factored into the model, including engineering personnel investment, incident response time, compliance audits, model version upgrades, and service interruptions caused by hardware failures.
6. Pre-Launch Checklist
- Conduct stress testing using real request distributions, not just idealized single-request data.
- Record P95 latency, failure rates, and actual utilization by usage tier.
- Review the cost model weekly, using utilization and unit token cost as core metrics.
- Confirm data export and privacy requirements with the compliance team in advance and incorporate them into the deployment plan.
