LLM Batch Processing: Balancing Cost, Concurrency, and Device Load

    This article explains how to tune large language model (LLM) batch processing across three competing constraints: cost, concurrency, and local device load. It covers why throughput and scheduling often matter more than single-response quality, how multi-way concurrency reduces total runtime, how peak and off-peak rate limiting affects model choice, how to account for output and cache-miss costs, when to prefer subscription quotas versus pay-as-you-go billing, why local memory and cooling frequently set the real concurrency ceiling, and how to run a repeatable concurrency test to measure effective throughput and cost per valid result.

    1. From “Model Capability Competition” to “Output per Unit Time”

    As LLM capabilities keep improving, many tasks with clear structure, well-defined rules, and moderate fault tolerance no longer depend heavily on complex reasoning. Examples include batch text classification, format conversion, field extraction, data cleaning, templated summarization, rule-based review, and multi-sample generation. These tasks usually share the following traits:

    1. The input structure is relatively fixed;
    2. The output format can be constrained;
    3. Individual tasks are independent of one another;
    4. The total task volume is large;
    5. The extreme quality requirement for any single request is low, but sensitivity to overall completion time is high.

    In these scenarios, the difference in single-response quality between models may be smaller than the efficiency difference created by concurrency and scheduling strategy. Suppose the average time for a single request is (t), the total number of tasks is (N), and the concurrency is (C). Under ideal conditions, the total time can be approximated as:

    [
    T \approx \frac{N \times t}{C}
    ]

    But this is only an ideal model. In practice, it is also affected by rate limiting, queuing, network latency, failed retries, output length, and local resource usage. So what really needs optimizing is not the “theoretical concurrency” but the stable concurrency: the concurrency level that can run continuously over a long period, with an acceptable failure rate and high output per unit time.

    Put differently, when evaluating a model or service for batch tasks, you cannot look only at single-response speed. You also need to consider:

    • The number of valid tasks completed per hour;
    • The average cost per task;
    • The request failure rate and retry ratio;
    • Whether throughput drops noticeably during peak periods;
    • Whether throughput stays stable over long runs;
    • The impact of input caching and output content on cost;
    • The pressure on local network, memory, and processor.

    2. Multi-Way Concurrency Is the Key to Reducing Total Work Time

    For independent batch tasks, multi-way concurrency is usually more effective than sequential single-stream calls. Single-stream mode is simple to implement, but it accumulates network waiting, service queuing, and generation latency one request at a time, so a large amount of time is spent in waiting phases.

    A simple concurrency framework typically includes the following parts:

    1. task_queue = load_pending_data()
    2. concurrency_limit = set_based_on_service_limits_and_local_resources()
    3. while task_queue is not complete:
    4. batch = take_several_tasks_from(task_queue)
    5. results = submit_concurrently(batch, concurrency_limit)
    6. for item in results:
    7. if item.succeeded:
    8. save_result(item)
    9. else:
    10. log_failure(item)
    11. requeue_with_backoff(item)

    Here, the most important thing is not to set the concurrency as high as possible, but to find the balance point between throughput and stability. If concurrency is too low, the service capacity is underused; if concurrency is too high, the following problems may occur:

    • The server triggers rate limiting;
    • Local connection count rises quickly;
    • Request timeouts and retries increase;
    • Memory usage keeps climbing;
    • Result writing cannot keep up with request completion;
    • Many requests return at once, creating instantaneous processing pressure;
    • Failed retries further amplify concurrency, forming congestion.

    Therefore, it is recommended to test with a “gradual ramp-up” approach. Start at 2, 4, and 8 streams, run each level for a period of time, and record average throughput, P95 latency, failure rate, and resource usage before deciding whether to increase further.

    3. Peak and Off-Peak Rate Limiting Directly Changes Model Selection

    Many services apply different resource scheduling strategies at different times of day. When resources are relatively abundant at night, the concurrency limit may be higher; during working hours, as request volume rises, the server may actively lower per-user concurrency or limit overall throughput through queuing delays.

    Therefore, you cannot use short-term test results from a single period to represent all-day performance. A more reasonable evaluation approach is to build time-segmented baselines:

    Time Period Concurrency Limit Average Latency Valid Output per Hour Failure Rate
    Off-peak TBD TBD TBD TBD
    Normal TBD TBD TBD TBD
    Peak TBD TBD TBD TBD

    If a task is strongly time-sensitive, you can split it into two queues:

    • Urgent queue: runs during the day or peak hours to prioritize progress;
    • Normal queue: scheduled during off-peak hours to gain higher concurrency efficiency.

    This scheduling approach is usually more reasonable than using the same concurrency all day. For batch tasks without strict deadlines, concentrated overnight runs can significantly compress overall completion time; for online tasks that need continuous processing, you should reserve some concurrency capacity to avoid batch jobs crowding out real-time requests.

    4. Don’t Look Only at Cached Input Prices

    In cost analysis, input is usually split into three categories: cache-hit input, cache-miss input, and output. Many users over-focus on the cache-hit price while ignoring the impact of output volume and cache-miss input on total cost.

    Total cost can be abstracted as:

    [
    Cost = I_c \times P_c + I_u \times P_u + O \times P_o
    ]

    where:

    • (I_c): volume of cache-hit input;
    • (P_c): unit price of cache-hit input;
    • (I_u): volume of cache-miss input;
    • (P_u): unit price of cache-miss input;
    • (O): output volume;
    • (P_o): output unit price.

    If a task needs to generate long results, output cost may become the main cost source even when input largely hits the cache. This is especially true in batch generation, per-item explanation, structured reporting, and long-text rewriting scenarios, where output token count tends to grow faster than input.

    So cost accounting should at least track the following:

    1. Average input length;
    2. Average output length;
    3. Cache hit ratio;
    4. Average retries per task;
    5. Whether failed requests incur charges;
    6. Actual throughput at different times of day;
    7. Total cost per thousand tasks;
    8. Cost corresponding to valid output per hour.

    It is recommended not to compare only “price per million tokens,” but to run a small-scale sample with real tasks. For example, first run one thousand samples, record total consumption and the number of valid results, then extrapolate large-scale task cost based on the actual completion rate. This avoids misjudgment caused by long outputs, frequent retries, or unstable cache hit rates.

    5. Subscription Quotas and Pay-as-You-Go Should Be Evaluated Separately

    If you use a fixed-quota plan, the focus is on whether the daily task volume can be completed within the quota; if you use a pay-as-you-go API, the focus is on calculating the cost per unit of output. The two cannot be compared directly by list price.

    Fixed-quota plans are suitable for:

    • Stable daily task volume;
    • Tasks concentrated in a few time periods;
    • A need for high concurrency;
    • A desire to lock in the budget in advance.

    Pay-as-you-go plans are suitable for:

    • Highly variable task volume;
    • Occasional burst tasks;
    • A need for elastic scaling;
    • A stronger focus on paying for actual usage.

    In real workflows, you can also adopt a combined strategy: use fixed-quota resources for daily batch processing and the pay-as-you-go API for temporary large-scale tasks. This ensures the stability of routine tasks while avoiding buying an oversized plan long-term just for a few peak tasks.

    6. Local Hardware Is Often the Concurrency Ceiling, Not the Server

    Large-scale concurrent requests are not necessarily limited by the server; the local device can just as easily become the bottleneck. Each stream of requests consumes some memory, and a high connection count also increases the overhead of threads, coroutines, buffers, serialization, and result writing.

    Common resource consumption includes:

    • Memory used by request and response objects;
    • Network connections and connection pools;
    • The pending task queue;
    • Results not yet written to disk;
    • Logs and debug information;
    • Retry task caches;
    • Data parsing and format validation;
    • Local database or file write buffers.

    On devices with limited memory, a few dozen concurrent streams can already create noticeable pressure. At that point, even if processor usage is not at 100%, the system may slow down due to insufficient memory, frequent garbage collection, or disk swapping.

    During testing, it is recommended to monitor the following at the same time:

    1. Memory usage
    2. Average processor utilization
    3. System load
    4. Network throughput
    5. Disk write speed
    6. Connection count
    7. Task queue length
    8. Average latency and failure rate

    A practical principle: don’t run the device at its limit for long periods. If at a certain concurrency level memory is near full, the processor stays at high usage, and the fan runs at high speed for a long time, that level is not suitable as a stable production configuration. A more reasonable approach is to keep about 20% to 30% of resources in reserve to handle response bursts, failed retries, and background system tasks.

    7. Memory Capacity Matters More Than Frequency, but Higher Frequency Isn’t Always Better

    For network batch tasks, memory capacity usually has a more direct impact on the supportable concurrency than memory frequency. When capacity is insufficient, the system experiences swapping, cache eviction, and queue buildup; when capacity is sufficient, the gains from higher memory frequency are often limited.

    In addition, higher frequency may come with higher power consumption and heat. In multi-stream network request scenarios, the device stays under high load for a long time, and sustained temperature affects processor scheduling and overall stability. So the practical selection order should be:

    1. First ensure sufficient memory capacity;
    2. Then consider the processor’s sustained performance;
    3. Ensure the cooling system can work over long periods;
    4. Finally evaluate the marginal gains from higher memory frequency.

    If the device is mainly used for short-term testing, a higher load is acceptable; if it needs to run continuously for hours or longer, prioritize a stable, low-temperature, and sustainable configuration.

    8. Build a Complete Concurrency Testing Workflow

    A fairly reliable testing workflow can be divided into five steps.

    1. Fix the Input Sample

    Prepare representative real tasks covering short input, long input, short output, and long output. Avoid testing with only simple samples.

    2. Fix the Prompt and Output Format

    If the prompt and format keep changing, you cannot tell whether performance differences come from service capability or task variation. Structured output can also reduce result parsing costs.

    3. Test Concurrency in Levels

    Increase concurrency in steps, and run each level long enough. Don’t look only at peaks within a few minutes.

    4. Record Effective Throughput

    Don’t count only the number of returned requests; also count the number of successful, qualified results that have been written to disk. Requests generated by failed retries should not be counted as valid output.

    5. Calculate Composite Metrics

    You can use the following metrics for comparison:

    [
    \text{Effective Throughput} = \frac{\text{Qualified Results}}{\text{Run Time}}
    ]

    [
    \text{Cost per Result} = \frac{\text{Total Cost}}{\text{Qualified Results}}
    ]

    [
    \text{Composite Efficiency} = \frac{\text{Effective Throughput}}{\text{Cost per Result}}
    ]

    If the task has different levels of quality requirements, you should also add manual spot checks or automated validation to avoid sacrificing result usability for speed.

    9. Conclusion: Calculate the Task First, Then Choose the Model and Concurrency

    For tasks with clear rules and large scale, the optimal solution is usually not simply choosing the “most capable” model, but weighing the following factors together:

    • Whether a single result meets the minimum quality requirement;
    • The stable concurrency during off-peak and peak periods;
    • The actual output length;
    • The cache hit ratio;
    • The failure and retry ratio;
    • Subscription or pay-as-you-go costs;
    • The local device’s memory and cooling capacity;
    • Whether delayed task completion is acceptable.

    If the task emphasizes finishing as soon as possible, prioritize raising stable concurrency and handling failed retries; if the task is more budget-focused, strictly control output length and invalid requests; if the task needs to run all day, schedule dynamically according to peak and off-peak patterns.

    In the end, the core of LLM batch processing is not simply pursuing higher concurrency, but establishing a balance among service limits, billing structure, task quality, and local hardware. Only by using real samples to measure “how many qualified results are completed per unit time and how much each result actually costs” can you reach a reliable conclusion suited to your own workflow.