LLM Routing for High-Throughput Scheduled Jobs
High-volume scheduled jobs rarely need the most capable LLM for every record. This article explains how to route work by complexity and failure impact, validate structured outputs, and build recoverable batches. It also covers how to measure quality and cost per usable result, plan capacity, and protect sensitive inputs.
Scheduled jobs are production pipelines that need to finish reliably every day. Report summarization, log categorization, support ticket triage, field extraction, content tagging, and incremental knowledge base maintenance are typical examples. Each record may be straightforward, but the volume of data and model calls adds up. Sending everything to the most capable model can raise costs and queueing delays for only a modest quality gain. Sending everything to the cheapest model can lead to inconsistent results when inputs are ambiguous, context is long, or output formats are strict. A better approach is to route work by risk.
Classify tasks using measurable criteria
Before assigning model tiers, describe each task along four dimensions rather than relying on a sense of how difficult it is.
- Reasoning depth: Does the task involve classification, rewriting, or extraction under clear rules, or does it require multistep reasoning, cross-document comparison, or open-ended judgment?
- Output constraints: Must the result conform to a parseable structure with fixed fields and allowed values? The more explicit the constraints, the easier it is to use prompt templates and automated validation.
- Impact of failure: Would an incorrect result only affect what users see, or could it trigger a notification, change a charge or permission, or publish content externally?
- Latency and volume: Does the task need a response within minutes, or can it run as an hourly batch? Could peak traffic exhaust a shared quota?
High-volume, low-complexity tasks usually have rules you can write down and outputs you can validate. Individual failures can be retried, and results can be spot-checked. Throughput and unit cost matter more than squeezing extra reasoning out of every call. Use a lightweight model for these tasks by default. If any of those conditions does not hold, route the higher-risk subset separately rather than moving the entire batch to a lighter tier.
Route records instead of picking one model for everything
In practice, a routing policy can use two or three tiers:
- Lightweight tier: Handles most routine batch traffic with short prompts, trimmed context, and a small set of output fields.
- Standard tier: Handles borderline cases, such as longer inputs, ambiguous category boundaries, or repeated validation failures at the lightweight tier.
- High-capability tier: Handles exceptions, such as records that fail quality spot checks, cases with conflicting business rules, or outputs that need a rationale or final wording for external publication.
Put routing criteria in configuration, not in scattered code comments. For example, escalate a record when it exceeds a text-length threshold, matches a sensitive category, fails schema validation, carries a low-confidence flag, or exceeds the daily retry limit for the same record key. Calibrate thresholds against historical examples and review them regularly so that a one-time tuning decision does not become a permanent default.
The case for a lightweight model should be explainable: the default path has few steps, the prompt is stable, and the output can be checked programmatically. Lower cost is a consequence, not the only criterion. If the lightweight tier generates enough escalations and manual corrections, it may cost more than using a more reliable model from the start.
Build batches that can recover from partial failure
Model inference is only one part of the pipeline. Duplicate execution, partial completion, and silently skipped records are common failure modes in high-throughput jobs. Structure the batch around recovery:
- Define the batch. Use a business date, partition, or watermark to determine the input range, and record a batch ID.
- Make writes idempotent. Key each result by the business record key and batch ID so that rerunning the batch does not create a second valid result.
- Process chunks with bounded concurrency. Split the work into fixed-size chunks and cap in-flight requests to avoid overwhelming inference capacity or downstream storage.
- Isolate failures. Send individual failures to a retry queue without rolling back records that have already succeeded.
- Reconcile counts. Compare the number of inputs with the counts of successful, retryable, and permanently failed records.
The following pseudocode illustrates the control flow without relying on a specific platform API:
for batch in pending_batches:mark_running(batch)for item in load_items(batch):if already_succeeded(item):continueresult = call_model(route(item), prompt(item))if validate(result):save(item, result)else:enqueue_retry_or_upgrade(item, result)reconcile(batch)
Match the retry strategy to the failure. Timeouts, rate limits, and temporary service outages are good candidates for exponential backoff. Missing fields, invalid enum values, and implausible numbers generally call for a stricter prompt or a model upgrade, not an identical retry. For permanent failures, retain the original input, model output, and validation error for review, subject to the data handling controls below.
Control costs with focused prompts and automated validation
Even with the same lightweight model, prompt design can materially affect both success rates and cost.
- Include only the fields needed for the decision. Omit unrelated history and full-page text when an excerpt is enough. Long context is an easy-to-miss source of batch costs.
- Use stable instructions that specify the model’s role, allowed categories, what it must not invent, and the fallback value to return when it cannot decide.
- Require compact, structured output and parse it in application code. Treat a parse error as a failed result rather than displaying the model’s prose as a substitute.
- Keep rules that change frequently in configuration or examples rather than hard-coding the same policy in multiple prompts.
- Preserve an
uncertainoption for classification. Forcing a choice can pass errors downstream.
At a minimum, validate required fields, data types, allowed values, length limits, echoed record keys, and numeric ranges. If a deterministic rule can check something, do not ask the model to check it again. Let the model turn unstructured input into structured data, and let application rules enforce the output contract.
Measure quality before and after rollout
Before rollout, compare the lightweight and high-capability tiers on a fixed evaluation set. Measure agreement, structured-output success rate, manual correction rate, and per-record latency. After rollout, track escalation rates, retry rates, batch timeouts, and reconciliation discrepancies daily. If escalations keep rising, check for shifts in the input distribution or changes to the prompts before switching the default tier.
Stratify your spot checks. Sample high-risk categories, new input sources, unusually long records, and escalated cases more heavily. Sample stable categories less often. Turn the findings into regression examples or validation rules rather than leaving them in a spreadsheet. For externally published content, keep a human approval step or a second validation check instead of treating scheduled output as final.
Plan for cost, capacity, and data protection
Measure cost per usable result, not per model call. A cheap first call is not cheap if it leads to two escalations and a manual correction. Reserve enough capacity for batch work: do not let peak batch traffic compete with interactive requests without concurrency limits, and make sure queues, object storage, and log retention can support reruns.
Inputs may contain account identifiers, phone numbers, internal addresses, or original customer text. Minimize the fields sent in prompts and redact sensitive values when necessary. Keep routine logs to batch IDs, record keys, error codes, and summaries rather than retaining full sensitive inputs long term. Apply access controls to stored results and grant the job’s service identity only the permissions it needs to process the batch.
If you run the pipeline on a cloud platform such as Baidu AI Cloud, use standard building blocks: object storage for inputs and outputs, a message queue to absorb traffic spikes, containers or a job scheduler to process chunks, and logging and monitoring to track failures, latency, and backlog. Check the documentation for the services you have enabled to confirm quotas, pricing, and interfaces. Do not design around unverified performance figures.
Start with one task you can reconcile
Choose a pilot task with clear rules and inputs and outputs you can reconcile. Freeze the input sample, define when a record qualifies for the lightweight tier and when it should be escalated, and implement the validator. Then run the pipeline for one full business day. Once the counts reconcile, increase concurrency gradually and keep the high-capability tier available for exceptions. Reassess the impact of failure for each new task instead of copying the tier assignment from the previous one.
The goal of model tiering is to make daily work reliable, recoverable, and easy to explain while reserving more capable models for the records that need them. As task complexity, input data, and risk change, adjust the routing thresholds. Over time, keeping those thresholds aligned with the workload matters more than swapping one model for another.
