The Cost Math Behind Self-Hosted Compute Handling 44% of Inference Traffic

    An analysis of what it actually costs to run self-hosted GPU capacity for LLM inference under short-term leases, how effective utilization, per-million-token pricing, and cache hit rates determine break-even, and how to build a hybrid gateway that routes traffic between owned accelerators and external APIs. Includes a cost baseline model, subscription vs. usage-based margin comparison, and a reusable checklist.

    1. What Changed: A Compute Mix Shift Completed in Three Months

    An AI coding tool moved nearly half of its inference traffic off external APIs and onto its own accelerator cards in roughly three months, creating a dual-channel setup: external inference resources plus a self-hosted cluster. By public figures, about 20 trillion tokens still go through external pay-as-you-go APIs, while about 16 trillion tokens are served by owned accelerators — roughly 44% of the total.

    Those 16 trillion tokens run on just three rack-scale deployments, about 216 accelerators in total. The team’s secured resource pool is around 1,000 cards: roughly 40% latest-generation high-bandwidth models and roughly 60% previous-generation models from the same line. All contracts run less than a year — a textbook short-term elastic lease.

    This structure is more interesting than the conclusion “self-hosting is always cheaper.” Short leases mean nearly all cost is variable cost, with depreciation and idle risk pushed onto the supplier. The trade-off is a higher unit price and uncertain renewal.

    2. Cost Baseline: Converting Rent Into a Per-Million-Token Price

    Public ranges put the latest-generation machines at about $9–10 per card-hour and the previous generation at about $6–7 per card-hour. Using 216 cards at the high end:

    1. Hourly: 216 × 9~10 ≈ $1,944 ~ $2,160
    2. Daily: ≈ $46,656 ~ $51,840
    3. Monthly: ≈ $1.4M ~ $1.56M (30 days at full load)

    If those three racks produce 16 trillion tokens continuously across 24 hours, the compute cost works out to about $0.0029–0.0032 per million tokens. That number looks good only under the assumption of full utilization, zero idle time, and zero failed retries. Real systems lose on all three fronts, so it is safer to introduce an effective utilization factor:

    1. Effective cost = rent / (token throughput × effective utilization)
    2. 70% utilization → ~$0.0041 ~ $0.0046 per million tokens
    3. 50% utilization → ~$0.0058 ~ $0.0064 per million tokens

    The takeaway: the cost advantage of self-hosting does not come from “buying cards is cheaper than renting APIs.” It comes from the ability to push utilization high. A drop from 90% to 50% nearly doubles unit cost — enough to erase the entire gross margin.

    3. Revenue Side: Gross Margin Differences Between Subscriptions and Usage-Based Billing

    The same compute has completely different margin structures depending on how it is monetized. External usage-based APIs typically carry markups several times the underlying rent, so a 50%–70% gross margin under a full-load assumption is not surprising. A low-priced monthly subscription (say, the $10/month tier) is only profitable if per-user monthly consumption is strictly capped.

    A simplified break-even model:

    1. Given: monthly rent C = $1.5M, price p = $0.003 per million tokens
    2. Sellable at full load S = 500,000 million tokens
    3. Break-even utilization u* = C / (p × S) ≈ 100%

    At a price of $0.003 per million tokens, you essentially need full load just to break even. Raise the price to $0.006 and break-even utilization drops to about 50%.

    The subscription equivalent: at $10 per user per month, the supportable compute cost is about $30 per million tokens × actual consumption, so per-user monthly consumption has to be squeezed into a very low range — otherwise the larger the scale, the bigger the loss. This is why these products almost universally invest in context compression, cache reuse, and request batching: those mechanisms directly determine the denominator.

    4. The Overlooked Variables: Caching, Context, and Failed Retries

    Inference cost is not linear in token count. Reusable prefix caches cut repeated computation significantly; long contexts add attention overhead that grows with length; a single timeout retry means double billing. Practical engineering levers include:

    • Fixing prefixes and system prompts to maximize cache hits;
    • Context trimming and layered summarization to control per-request length;
    • Budgeting timeouts and retries to avoid cascading repeat consumption;
    • Admission control based on queue depth, spilling peak traffic to the external channel.

    5. Implementing Hybrid Scheduling

    Abstracting both channels behind a unified gateway that routes dynamically on cost and latency is the core of this architecture:

    1. def route(req, self_cost, api_cost, queue_depth, latency_slo):
    2. # Prefer the self-hosted channel when idle; spill to the external API under congestion or SLO breach
    3. if queue_depth < CAP_HIGH and req.est_latency < latency_slo:
    4. return SELF, self_cost
    5. return EXTERNAL, api_cost

    Three general capabilities are needed alongside it: monitoring and alerting to observe utilization and tail latency, logging services to attribute the token composition of each request class, and a container platform for elastic scaling and canary rollouts. For capacity planning, size the always-on footprint using “peak throughput + redundancy factor,” cover peaks with short-term leases, and use external pay-as-you-go APIs as the fallback for the long tail.

    6. Conclusions and a Reusable Checklist

    Whether self-hosted compute pays off comes down to three quantifiable metrics: effective utilization, per-token selling price, and cache hit rate. The right order of judgment is: measure real utilization and retry rate first, then compute break-even utilization, then decide the self-hosted share. The actionable checklist:

    1. Establish a full-cost per-million-token accounting standard (including rent, operations, and failed retries);
    2. Set a utilization red line and automatically spill to the external channel below it;
    3. Constrain per-user consumption with subscription quotas and caching policy;
    4. Use short leases for elasticity and external APIs as fallback to avoid long-term idle risk.

    Without public financial data, any claim that “self-hosting is already profitable/loss-making” is not rigorous. But the model above is enough for a team to run the numbers on its own real data. If you need a managed inference and elastic resource offering to absorb peak traffic, the relevant general capabilities from Baidu AI Cloud can be one evaluation candidate.