LLM Batch Processing: Concurrency Scheduling and Cost Optimization in Practice
A practical guide to running large-scale LLM batch jobs: how to establish quality gates before comparing throughput, measure effective throughput under concurrency, budget tokens and deadlines together, account for real costs per valid result, distinguish remote rate limiting from local bottlenecks, and build resumable batch pipelines.
1. Set the Quality Bar First, Then Compare Throughput
When LLMs are used for tasks like text classification, field extraction, or format conversion, individual requests are usually simple—the real pressure comes from volume. When processing tens of thousands of records, even a few seconds of per-request difference can translate into hours of difference in total delivery time once rate limiting, retries, and queue backlog accumulate over a long run. So the right selection question is not “which model answers fastest?” but: “Given that output meets acceptance criteria, which execution approach can deliver on time at an acceptable cost?”
Start by building a quality baseline with the same representative sample set. Samples should cover common inputs as well as edge cases: missing fields, overly long content, and ambiguous phrasing. When validating, separate format validity from business correctness: structurally complete results may still be wrong, and semantically correct results that downstream programs cannot parse are not directly usable either. Use programs to check field types, value ranges, and required fields, then use manual sampling or existing ground-truth answers to assess semantic correctness. Only approaches that meet a minimum quality threshold are worth taking into the next round of throughput and cost comparisons. For a small number of hard cases, route them to a separate review lane rather than raising processing costs for the whole batch just to cover every exception.
2. Measure Concurrency Gains with Effective Throughput
Concurrency—the number of in-flight requests at a given moment—does not equal requests completed per second, and certainly not validated results delivered per second. Assuming neither the server nor the client is saturated and per-request latency stays roughly constant, moving from a single stream to multiple streams usually shortens batch completion time. But as concurrency keeps rising, queuing, rate limiting, and timeouts tend to grow together. If doubling concurrency doubles per-request latency, batch throughput will not scale proportionally; if failures trigger concentrated retries, effective throughput can even fall.
Batch load testing should record at least four metrics:
| Metric | Definition | Purpose |
|---|---|---|
| Effective throughput | Deduplicated results passing acceptance ÷ actual elapsed time | Measures real delivery speed |
| Tail latency | 95th percentile of request latency, noting whether queuing and retries are included | Determines whether a few slow requests drag out the finish |
| First-pass rate | Tasks passing acceptance on first request ÷ tasks submitted | Surfaces quality or format issues masked by retries |
| Cost per valid result | Batch-related spend ÷ deduplicated results passing acceptance | Compares the economics of different approaches |
During load tests, fix the sample composition, acceptance rules, and output requirements. Increase concurrency step by step from a low baseline, running each level until throughput and error rates stabilize. If input lengths vary widely in production, make sure each concurrency level includes similar proportions of short, medium, and long requests, so sample differences are not mistaken for concurrency effects. Also retest during the time window you actually plan to run: short tests during idle periods do not represent sustained capacity at peak.
Choose a stable concurrency level with headroom, not the occasional peak you can hit. A practical signal to stop pushing higher: after raising concurrency one more level, effective throughput barely changes while tail latency, rate-limit hits, or resource usage clearly climbs. Backing off to the previous level usually serves on-time batch completion better.
3. Put Request Volume, Token Volume, and Deadlines in the Same Ledger
Even when the server allows many concurrent in-flight requests, it may impose separate limits on requests per unit time or token usage. When short requests dominate, request frequency may hit its cap first; when long documents or long outputs dominate, token throughput tends to become the bottleneck earlier. So the scheduler should track request rate and token consumption in addition to concurrency, and adjust submission pacing based on real feedback. For workloads with highly variable lengths, split tasks into separate queues by estimated processing size, so a batch of long tasks does not occupy all execution slots and block short tasks from finishing promptly.
When planning execution windows, estimate the base duration as “items to deliver ÷ measured effective throughput,” then reserve time for startup, exception retries, and batch wrap-up. If six hours remain until the deadline, don’t schedule the entire job into a single window just because an idealized concurrency calculation says it finishes in five. A more reliable practice is to periodically update the estimated completion time based on remaining work and recent throughput: if the remaining window is too short, decide whether to bring up backup capacity early, prioritize tasks with dependencies, or adjust the delivery scope.
For work with loose deadlines, schedule it in windows where measured throughput is more stable and costs are lower; for work with hard deadlines, prioritize predictable delivery speed. Whether peak/off-peak pricing, time-based throttling, or quota cycles exist should be verified against the actual applicable terms and billing—never extrapolate long-term behavior from a single run.
4. Cost Should Be Counted per Valid Result, Not per Token Price
Different pricing structures call for different comparison methods. If you have a subscription with ample available quota, a batch may incur no extra cash outlay—but the quota it consumes still competes with future jobs. When deciding whether to spin up pay-as-you-go capacity temporarily, compare incremental costs; when deciding whether to keep a subscription long term, include fixed fees in your accounting and track actual utilization over a period. Mixing the two accounting methods easily produces conclusions that look cheap but are not sustainable.
For pay-as-you-go billing, tally input tokens, output tokens, and any cache-eligible portions separately according to the applicable rules, and verify whether failed requests or retries generate charges. High cache hit rates don’t guarantee a low overall bill: in tasks with long outputs, output costs may dominate; in tasks where format validation frequently fails, repeated generation can wipe out cache savings. Confirm your major cost drivers from the bill first, then decide whether to reuse stable prompt prefixes, trim redundant inputs, or shorten outputs. For example, if downstream only needs a classification label and an evidence snippet, there is no reason to have the model generate a full explanation for every record.
Budget control shouldn’t wait until the batch finishes. Before launch, use a small sample to estimate input length, output length, and failure rate. During the run, roll your budget forward based on actual consumption, with alert and pause thresholds set in advance. If cost per valid result keeps rising, first check whether the input distribution has shifted, whether retries have spiked, or whether acceptance rules are wrongly rejecting valid outputs—before considering more spend.
5. Distinguish Remote Rate Limiting from Local Bottlenecks
The API’s concurrency allowance is only the remote ceiling; the client may not sustain the same load. A batch program also reads inputs, maintains connections, parses responses, runs validation, and writes results. Even if remote inference hasn’t slowed, client-side evaluation, logging, or memory pressure can drag down overall throughput. In particular, if the program keeps the entire input batch, all intermediate responses, and full logs in memory for the whole run, the second half of the batch is far more likely to degrade than the start.
When troubleshooting, record pre-submission queuing time, remote response time, and local post-processing time separately. If rate-limit responses increase, lower your submission rate first. If responses arrive promptly but results take forever to write out, focus on CPU, memory, and disk. For long-running jobs, also watch for thermal throttling or frequency reduction under sustained load rather than judging capacity by startup-phase peaks.
Engineering-wise, safer practices: stream inputs incrementally, use bounded queues to cap in-flight tasks, and write results promptly once validation passes. When writes slow down, the submission side should throttle accordingly to avoid unbounded data buildup. Set the concurrency cap based on sustained load testing on your own machine—not on memory size or clock speed, and not directly on the server’s advertised limit.
6. Make the Batch Recoverable, Not Just Fast
The reliability of large batch jobs depends on whether, after an interruption, you can resume from where you left off. Assign each task a stable identifier and track its state: pending, completed, awaiting retry, or awaiting review. Write results keyed by task ID so writes deduplicate naturally, and after a restart, only rerun unfinished items. Note that output deduplication only prevents duplicate delivery: if a request was already sent but the client hasn’t recorded the response, resubmitting on recovery can still incur duplicate charges, so timeout retries need a hard cap.
Retries should also be categorized by error type. Network jitter or transient rate limiting suits delayed retries with randomized backoff to avoid synchronized request surges; invalid input should be fixed at the data level first; recurring business errors should go to a review queue rather than be retried identically forever. When error rates spike, first lower concurrency or pause new submissions and preserve completed results, then determine whether the anomaly comes from the server, the network, or your own program.
A practical execution sequence: use representative samples to set the quality bar; measure effective throughput and cost across time windows; schedule the batch based on deadline and remaining quota; monitor rate limiting, validation failures, and client load during the run; and reconcile delivered counts, retry overhead, and the actual bill afterward. The goal of batch optimization is not to max out concurrency, but to keep delivering usable results within the constraints of quality, budget, and deadlines.
