Optimizing Concurrency, Cost, and Device Capacity for Large-Model Batch Jobs
This article explains how to optimize batch jobs that use large language models by focusing on effective throughput, stable concurrency, end-to-end latency, cost per task, retry cost, and local device capacity. It covers concurrency ramp testing, peak and off-peak scheduling, full token-cost accounting, local memory and CPU limits, dynamic concurrency with tiered queues, and model selection based on a quality floor rather than marginal response quality. The goal is to help teams choose a reliable combination of service capacity, hardware, and scheduling so that batch workloads complete with acceptable quality in the shortest practical time.
In scenarios where rules are clear, individual tasks are relatively independent, and results can be generated in batches, differences in model capability are often diluted by task scale. At that point, continuing to compare small quality differences in individual responses may not produce clear benefits. Instead, concurrency capacity, throughput per unit time, pricing structure, failed-retry cost, and the stability of local devices often determine final delivery efficiency.
Therefore, when using large models in batches, the question should shift from “which model answers best” to “which combination can complete all tasks in the shortest time at acceptable quality.”
1. Core Metrics for Batch Jobs Have Changed
Traditional model evaluation usually focuses on accuracy, context length, reasoning ability, and generation quality. For tasks that need to process tens of thousands of records, however, the following metrics must also be added:
- Effective throughput: the number of successfully completed tasks per unit time, not the theoretical number of concurrent requests.
- Stable concurrency: the number of parallel requests that can still be maintained after running continuously for a period of time.
- End-to-end latency: the total time including queuing, request sending, model generation, result persistence, and failed retries.
- Cost per task: do not look only at the input unit price; also consider cache hits, uncached input, and output costs.
- Failure rate and retry cost: under high concurrency, frequent timeouts or rate limiting may actually reduce nominal throughput.
- Local capacity: including memory, processor usage, network connections, cooling capacity, and disk write speed.
A simple estimation formula can be used:
Total time ≈ total number of tasks ÷ effective concurrency ÷ average processing efficiency per request
Here, effective concurrency is not the same as the concurrency configured in the program. For example, if a program is configured to send 20 requests at the same time, but due to server rate limiting, network waits, or insufficient local memory, only 12 requests are actually being processed effectively, then the final throughput should be estimated based on 12 concurrent requests.
2. Multi-Request Concurrency Is Usually the First Lever for Reducing Total Work Time
When tasks are independent of one another, serial execution causes a large amount of waiting. Even if each request does not take long to process, the total time can increase rapidly once the workload reaches thousands or tens of thousands of records.
The benefits of concurrent execution mainly come from three areas:
- Hiding the network wait time of individual requests;
- Making full use of the processing window allowed by the server;
- Splitting long-running work into a work queue that can run continuously.
However, higher concurrency is not always better. Once concurrency exceeds what the server or local device can handle, common problems include:
- Requests are rate-limited and queue up in large numbers;
- Timeouts and connection errors increase;
- Failed tasks trigger retries, causing duplicate charges;
- Local memory keeps growing and eventually triggers swapping or a program crash;
- The processor remains fully loaded for a long time, and thermal throttling reduces actual speed.
Therefore, the right approach is not to pursue maximum concurrency directly, but to find a “stable concurrency range.” A common method is to increase concurrency step by step, for example from 2 to 4 to 8 concurrent requests, and let each level run continuously for 10–30 minutes while recording success rate, average latency, memory usage, and completed volume per unit time. When further increases in concurrency no longer improve effective throughput, or even cause it to decline, the system is close to the optimal operating point of the device or server.
3. Include Peak and Off-Peak Capacity in Scheduling
Some model services or compute resources have different concurrency limits, queue speeds, or pricing policies at different times of day. For batch tasks that do not require immediate completion, the day’s workload can be split into multiple time windows.
A practical arrangement is:
- Process tasks that need timely review or manual intervention during the day;
- Run large batch tasks during off-peak periods;
- Delay retries for failed tasks and low-priority tasks;
- Divide different resource pools according to stable concurrency rather than simply splitting them evenly.
For example, if one resource pool can maintain higher stable concurrency during off-peak hours, while another resource pool has steadier throughput throughout the day, the former is suitable for concentrating nighttime batch tasks and the latter is suitable for continuous daytime operation. The focus is not on chasing an instantaneous peak in a particular time window, but on increasing the total effective completed volume across the full day.
Note that pricing or concurrency policies may change over time, so temporary observations should not be treated as long-term fixed capacity. Production tasks should retain a safety margin and use monitoring to judge current queuing and failure conditions in real time.
4. Do Not Focus Only on Cache-Hit Pricing
In tasks where input content has a high degree of repetition, cache hits can usually reduce part of the input cost. However, over-focusing on cache pricing may cause two more important factors to be ignored: uncached input and output costs.
Total cost should be calculated using the following structure:
Total cost = cached input volume × cached input unit price
- uncached input volume × uncached input unit price
- output volume × output unit price
- additional cost from failed retries
For large-sample batch processing, the proportions of the three token categories may not be close. If every task requires a long explanation, structured results, or multiple rounds of correction, output volume can easily become the main cost driver. Conversely, if the input template is very long but the output is very short, the uncached input price may be more important.
During actual accounting, it is advisable to record at least the following fields:
Task IDInput characters or input tokensCache hit statusOutput tokensRequest latencyRetry flagFinal statusActual cost
Only with this data can you calculate the true average task cost, rather than making theoretical estimates based on a unit-price table.
5. Very High Concurrency Does Not Necessarily Improve Cost-Effectiveness
Some APIs may allow very high theoretical concurrency. But this only means that the platform has access capacity; it does not mean that a personal computer or business program can effectively use that concurrency.
Local limits mainly come from the following areas:
1. Memory Usage
Each concurrent request may need to store input text, request state, response buffers, retry information, and log objects. If the program does not release data from completed tasks in time, memory usage will continue to grow with runtime.
A rough model can be used for estimation:
Memory requirement ≈ base program usage + concurrency × average per-request usage + buffer and log headroom
In actual deployment, it is advisable to keep at least 20%–30% of memory free to prevent the system from entering swap due to unexpectedly long responses.
2. Processor Usage
A large number of concurrent requests increases pressure from serialization, encrypted connections, response parsing, format validation, and file writing. Even if model inference happens remotely, the local processor can still become a bottleneck.
3. Network Connections and Disk Writes
High concurrency creates more connections and generates large amounts of response data. If all results are written to a single file, disk lock contention and data flushing can also affect throughput. A safer approach is to write in shards and merge results periodically.
4. Cooling and Sustained Performance
A short stress test may show that a device can handle relatively high concurrency, but after several hours of operation, processor temperatures rise, fan speeds increase, and the device may throttle automatically. At that point, although the concurrency setting has not changed, actual completion speed will decline.
6. Use Dynamic Concurrency and Tiered Queues
Fixed concurrency is suitable for simple tests but not for long-running production tasks. A more reliable approach is dynamic scheduling:
- Start with relatively low concurrency;
- Increase gradually after a threshold of consecutive successes is reached;
- Reduce concurrency when timeouts, rate limiting, or elevated error rates appear;
- Use exponential backoff for failed requests;
- Set up separate queues for tasks with different priorities.
Example pseudocode:
concurrency = initial_valuewhile pending_tasks:results = run_batch(pending_tasks, concurrency)if success_rate_high and latency_stable:concurrency += stepelif error_rate_high or memory_pressure:concurrency = max(min_value, concurrency - step)save_success_results()retry_failed_tasks_after_delay()
In addition, infinite retries should be avoided. Each task should have a maximum retry count, and the last error reason should be recorded. For format errors, a lightweight repair can be attempted; for server rate limiting, retries should be delayed; for invalid input itself, the task should go directly to a manual review queue.
7. Select Models with a Quality Floor and Throughput Optimization
If tasks fall into relatively clear categories such as classification, extraction, rewriting, or format conversion, you can first define a quality floor and then choose, among models that meet that floor, the one with better throughput and cost.
A recommended process is:
- Extract a small batch of samples from real business data;
- Use different models to complete the same task;
- Check the results through manual sampling or automated rule checks;
- Measure the proportions of format errors, missing key information, and results that need to be rerun;
- Among candidate options that meet the quality requirement, compare total time and total cost;
- Run a sustained load test rather than testing only a few dozen requests.
The final comparison should be:
Cost per valid result = total cost ÷ number of qualified results
If a solution has a lower price but a high failure rate, many retries, or a clear increase in manual correction cost, its real cost may not be low.
8. Conclusion: Measure Effective Throughput First, Then Calculate Total Cost
For large-scale, low-interaction, splittable model tasks, what is usually most worth optimizing is not single-response speed but the effective throughput of the complete pipeline. Concurrency scheduling, time windows, cost breakdown, and local device capacity must all be considered within the same decision framework.
In practice, four principles can be followed:
- First use a small sample to confirm the quality floor;
- Then use stepwise load testing to determine stable concurrency;
- Account separately for cached input, uncached input, output, and retries;
- Use effective completed volume during sustained operation as the final metric.
Only when server resources, local hardware, and task scheduling match one another will multi-request concurrency truly translate into production efficiency. Blindly pursuing higher concurrency often turns the problem from “tasks complete slowly” into “too many tasks fail, devices become unstable, and costs become uncontrollable.”
