High-Throughput Batch Inference: Cost and Throughput Practices

    This article explains how to improve batch inference delivery speed when model capability is no longer the main bottleneck. It covers a simple time estimation model, peak and off-peak scheduling, the real cost impact of output length, how to benchmark the concurrency turning point under local resource limits, and the stability engineering needed to make high concurrency reliable. It also outlines a three-tier strategy for choosing inference channels based on quota, time-based limits, and pay-as-you-go pricing.

    1. Background: When “Is the Model Smart Enough” Is No Longer the Main Problem

    After entering 2026, an increasingly clear engineering fact is that for tasks with clear rules, deterministic steps, and simple single-step judgments (for example, batch structured extraction, format conversion, classification and tagging, template-based generation, and turning batch computation results into text), the semantic capability of mainstream large models has generally crossed the “usable line.” The accuracy differences between models on these tasks have been compressed to a small range, and the gains from model selection are diminishing quickly.

    What really determines delivery speed at this point is no longer model intelligence, but three accounts:

    • Throughput account: how many tasks can be completed per unit of time;
    • Cost account: the actual expense paid to complete the same amount of work;
    • Resource account: whether the memory, CPU, and cooling of the local machine can support the target concurrency.

    The core insight of the original text can be abstracted into one principle: when single-point capability converges, system efficiency becomes the new competitive dimension, and concurrency is the most direct lever of system efficiency.

    2. Breaking “Time Investment” into Computable Quantities

    Let the total number of tasks be N, the average time per path be t, and the number of concurrent paths be C. The ideal total duration is approximately:

    1. T ≈ (N / C) * t / η

    where η is the concurrency efficiency coefficient (0 < η ≤ 1), used to describe the losses caused by rate limiting, queuing, retries, and long-tail tasks. In practice, η is usually between 0.6 and 0.85; the more homogeneous the tasks and the shorter the output, the higher η is.

    This formula shows two points:

    1. Increasing C has the largest marginal benefit, but η declines as C rises, so there is a turning point;
    2. When C is already constrained by local resources, adding more concurrency only makes η collapse, showing up as a large number of timeouts and retries.

    Therefore, the engineering goal is not to “max out concurrency,” but to find the point that maximizes C × η.

    3. Peak and Off-Peak Scheduling: Spreading Work Across Cheap and Idle Periods

    Many platforms use time-based pricing or time-based rate limiting for inference services: quota is looser and unit prices are lower at night; during daytime peaks, requests are throttled and concurrency is compressed. The rational approach is to treat tasks as deferrable jobs and schedule them by time period:

    • Daytime peak: run stable low-to-medium concurrency (for example, 5–7 paths) to guarantee latency on critical paths;
    • Nighttime idle: raise concurrency (for example, 8–10 paths or higher) for batch throughput;
    • Morning handoff: keep the task queue from idling, with seamless day-and-night continuity.

    A simplified scheduling pseudocode:

    1. def plan_jobs(jobs, now):
    2. if is_peak(now):
    3. return {"concurrency": 6, "queue": "critical"}
    4. else:
    5. return {"concurrency": 10, "queue": "batch"}

    Combined with a dual channel of “subscription quota + pay-as-you-go,” this can form a rhythm like the following: during the day, use the channel with sufficient quota to run interactive and near-real-time tasks; at night, use the high-concurrency channel to run offline batch processing, maximizing total effective working hours while pushing unit cost to the lowest.

    4. Caching and Pricing: Don’t Only Look at “Hit Input”

    The original text mentions a valuable observation: with a large enough sample size, the actual spending on missed input, hit input, and output may be close to 1:1:1. This corrects a common misconception—over-optimizing the input cache hit rate while ignoring that output length is the most controllable variable.

    Engineering conclusions:

    • Output length has a huge impact on total cost; compressing output (structured short JSON, enumerated values instead of natural language) is more effective than optimizing the cache;
    • Cache gains depend on the proportion of repeated prefixes; if tasks are highly heterogeneous, the hit rate is naturally low;
    • When estimating cost, use “each of the three items multiplied by its own unit price and then summed” as the baseline, rather than looking at a single unit price.

    Illustration:

    1. cost = in_miss * p_in + in_hit * p_hit + out * p_out

    5. Local Resources Are the Real Bottleneck: Estimating the Concurrency Limit

    High concurrency is not a pure software problem. Empirical ranges from testing (vary by machine, for estimation method reference only):

    • 64GB memory: 50 concurrent paths is relatively stable, theoretical limit is about 60 paths, memory usage can exceed 85%;
    • 96GB memory: 80 concurrent paths is relatively stable, limit is about 90 paths;
    • Higher memory frequency is not always better; rising heat may trigger throttling, which instead lowers overall throughput.

    CPU usage sustained at 70%–100% with fans at full load means the system has entered an unstable zone, where η drops quickly. It is recommended to self-test the turning point as follows:

    1. for c in [10, 20, 30, 40, 50, 60]:
    2. eta = benchmark(c, sample=200)
    3. print(c, c * eta)

    Take the value of c that maximizes c * eta as the production concurrency.

    6. Stability Engineering: Making High Concurrency Actually Finish

    High-concurrency failures are usually not model problems, but client and network problems. Four essentials:

    1. Bounded concurrency pool: limit the number of in-flight requests to avoid exhausting handles;
    2. Exponential backoff + jitter: to handle 429/5xx;
    3. Idempotency keys and resume-from-checkpoint: task-level checkpoints, so failures only rerun the affected shard;
    4. Observability: use logging services and monitoring alerts to track success rate, P95 latency, and cost per task.
    1. @retry(backoff=exponential(jitter=True), max_retries=5)
    2. def call(payload):
    3. return client.generate(payload)

    7. Selection Framework: Three-Tier Strategy

    • Tier 1: quota-based subscription channel, suitable for daytime interaction and medium concurrency, with marginal cost close to zero;
    • Tier 2: channel with time-based limits that are looser at night, suitable for large-scale batch processing at night;
    • Tier 3: pure pay-as-you-go channel, enabled only when quota is exhausted or when extremely high concurrency is needed (hundreds of paths or more, completing massive tasks in a dozen minutes).

    Recommended decision order: exhaust quota first → then use nighttime high concurrency → only then use pay-as-you-go for a final push.

    8. Conclusion

    In an era of converging capability, competition in batch inference is a competition of scheduling and resource engineering. By splitting tasks across time periods, tuning concurrency to the turning point, compressing output to the shortest form, and making failures recoverable, you can multiply delivery speed and significantly reduce cost without increasing model capability. If you use the compute and model services of Baidu AI Cloud, it is likewise recommended to build your own high-throughput pipeline around four principles: “quota first, peak-and-off-peak splitting, concurrency turning point, and concise output.”