aws
What Happens When 50,000 Products Hit Your LLM Queue?
At 9 p.m. a supplier sends 50,000 product revisions for an overnight catalog refresh. At 9:15 it sends the same file again. The merchandising team still needs 50,000 descriptions. The queue now holds enough messages for 100,000 attempts, even before the first timeout.
The morning report needs three numbers: unique products finished, model calls attempted, and budget remaining. Queue depth alone answers none of them. This fictional batch illustrates OWASP’s LLM10 Unbounded Consumption in an ordinary back-office workload. OWASP Top 10 for LLM Applications
Decide what counts as one piece of work
Store the supplier file in S3. Before fan-out, validate its size, record count, and per-field lengths. For each accepted row, enqueue a reference. Derive its logical job key from customer, product, product revision or content digest, and enrichment configuration version. Pin the prompt and model in that configuration. Identical rows from a second upload then describe the same job. A genuine change in material or dimensions creates a new revision.
A Lambda worker uses a conditional DynamoDB write to claim the job before calling Bedrock. A completed job returns its stored result. A job with an active lease belongs to its current worker. Record an attempt number and expiry so a crashed worker can be recovered. On completion, condition the write on that attempt still owning the job. This prevents a late result replacing newer work. A crash after inference can still cause an extra paid call, so account for each attempt separately. Lambda with SQS · DynamoDB transactions
Give each call a ceiling and each customer a budget
The worker asks Bedrock to turn approved product attributes into one short description. Bound the input field lengths before constructing the prompt. For a model supporting Bedrock CountTokens, count the complete request against that model and set an explicit output limit in Converse. A small output limit still permits a large input bill. Bedrock CountTokens · Converse inference configuration
Suppose one request has 620 input tokens and allows up to 180 output tokens. A simple token policy reserves 800 tokens for the attempt. If the response reports 120 output tokens, settle 740 and return 60 to the budget. This example measures tokens. For a monetary limit, reserve input and output separately at the applicable model rates. Keep the model and rates attached to the reservation.
In one conditional transaction, record an attempt reservation and decrement that customer’s available budget only if enough remains. When capacity runs out, persist a deferred job and acknowledge the queue message after that write succeeds. A scheduled release can requeue it when budget becomes available. Repeatedly failing the same message would turn a planned pause into a retry storm.
Slow the callers when Bedrock throttles
On a standard-mode SQS event source mapping, set maximum concurrency to bound active Lambda invocations. Also bound calls made inside each invocation. Apply backoff with jitter to retryable throttles, cap attempts across both SDK retries and queue redeliveries, and return partial batch failures so finished records stay finished. Reserve for each potentially billable call. Where a timed-out call’s usage is unknown, retain its reservation for reconciliation. Stop retrying permanent input errors. SQS scaling controls · Partial batch handling
Can another product enter inference?
- Job state
Skip completed revisions. Only the current owner can submit this attempt.
- Customer budget
Reserve input and output allowance. Persist a deferred job when funds run short.
- Bedrock → catalog
Validate the description against permitted fields, save it against the source revision, and settle usage.
Read the overnight timeline
The cover chart uses an illustrative run in thousands. At 9:15, 10,000 products have completed, the duplicate file has arrived, and 90,000 messages await handling. By 10 p.m., duplicate checks have drained many of those messages. There are 25,000 unique completions and 27,000 model attempts. The gap prompts a specific investigation: which 2,000 attempts retried, timed out, or failed validation? By close, 52,000 calls for 50,000 completed products is 1.04 calls per completion.
Publish low-cardinality CloudWatch metrics for admitted jobs, completed revisions, model attempts, throttles, and deferred work. Track queue age alongside them. Keep per-customer budget balances and attempt details in the application ledger. A dashboard explains the shape of the night. The ledger tells an operator which products can safely resume.
For a release test, replay an identical file, inject a throttle, and exhaust a small test budget halfway through. Assert that duplicates create no second completed record, that deferred jobs make zero calls while funds are unavailable, and that an unknown attempt retains its reservation. Refill the test budget and rerun. The morning handoff should name every unfinished revision and the reason it is waiting.
How DigitalCoding Can Help
What does it cost to finish one product description by your overnight deadline? DigitalCoding can help you measure that on a representative slice of your catalog. We can replay a duplicate supplier file, measure model calls per completed product, and show which items would pause under the budget you set.
Our AWS infrastructure services include workload assessment and cost controls. To plan a catalog pilot, share your typical batch size, completion deadline, and the budget you want to test. Start a Project.