Forward Deployed EngineeringAI EngineeringCapacity Planning
Estimate the capacity and cost of an app with 50k DAU making 10 LLM calls each. What do you provision for?
Question 31 of 73 · Updated
On this page
- Interview-ready answer
- 1. State the assumptions and units
- 2. Calculate requests and peak demand
- 3. Calculate token throughput
- 4. Estimate concurrent requests with Little's Law
- 5. Estimate inference cost
- 6. Sensitivity analysis and caching
- 7. A production architecture
- 8. What to provision when using hosted model APIs
- 9. What changes when hosting the model yourself?
- 10. Tested Python capacity and cost model
- 11. Failure handling and operational safeguards
- 12. Monitoring, load tests and rollout
- Likely interviewer follow-ups
Interview-ready answer#
I would begin with the workload rather than guess a number of servers. Fifty thousand daily active users making ten LLM calls each gives 500,000 logical LLM calls per day, or approximately 5.79 calls per second averaged across 24 hours. But I would provision for peak traffic, concurrent requests, token throughput, provider quotas and failures, not the daily average.
For an illustrative first estimate, assume a peak-to-average traffic ratio of 4, a 30% planning reserve, 1,000 input tokens and 300 output tokens per provider call, and a mean in-flight service time of three seconds during the design workload. That produces about 23.15 logical calls per second at peak and a rounded planning target of 31 attempts per second. At that planning rate, I would check capacity for 1,860 requests per minute, approximately 1.86 million input tokens per minute and 558,000 output tokens per minute, with around 93 concurrent in-flight calls on average under the assumed steady-state conditions.
At hypothetical prices of $1 per million input tokens and $4 per million output tokens, the baseline inference bill is $1,100 per day or $33,000 per 30-day month before caching, additional attempts, infrastructure and other costs. These are illustrative rates, not current vendor prices.
I would use a measured traffic profile and token-length distribution to refine the estimate, enforce tenant and provider budgets, load-test the architecture, and explicitly plan for rate limits, retry amplification, provider outages and demand growth. If we host the model ourselves, I would size accelerators using measured prefill and decode throughput, memory use and latency under representative concurrency rather than estimate GPU count from DAU alone.
1. State the assumptions and units#
The question supplies daily active users (DAU) and LLM calls per active user. Everything else below is an explicit planning assumption. Replace these assumptions with customer usage and measured performance before making a provisioning commitment.
| Input | Illustrative value |
|---|---|
| Daily active users | 50,000 |
| Logical LLM calls per active user per day | 10 |
| Seconds per day | 86,400 |
| Peak-to-average rate multiplier | 4 |
| Additional peak planning multiplier | 1.30 |
| Mean billable input tokens per call | 1,000 |
| Mean billable output tokens per call | 300 |
| Mean in-flight duration at design load | 3 seconds |
| Input price | $1 per million tokens |
| Output price | $4 per million tokens |
| Billing period for estimate | 30 days |
A user interaction can trigger several model calls in a multi-step workflow. Here the ten calls are assumed to be logical LLM calls, not ten chat messages that each trigger an unknown number of model invocations. The baseline assumes each logical call produces one provider attempt. Cache hits, retries, auxiliary model calls, tool loops and background workloads must be modeled separately if present.
Input tokens include applicable system instructions, conversation history, retrieved passages, tool schemas, tool results and user input. Billable output may include provider-specific reasoning or other generated tokens in addition to visible text. The actual tokenizer, model and billing contract determine usage.
2. Calculate requests and peak demand#
Daily logical calls:
50,000 × 10 = 500,000 calls/day.
Thirty-day logical calls:
500,000 × 30 = 15,000,000 calls.
Average calls per second:
500,000 / 86,400 ≈ 5.79 RPS.
Illustrative peak:
5.787 × 4 ≈ 23.15 RPS.
Planning target:
ceil(23.148 × 1.30) = 31 RPS.
This rounds up the assumed peak with reserve. Treat 31 RPS as a first planning target for total provider attempts, with the reserve intended to accommodate some variability and extra attempts. It is not a measured maximum or a guarantee that every burst fits.
| Rate | Estimate |
|---|---|
| Average across day | 5.79 RPS |
| Average per minute | 347.22 RPM |
| Assumed peak | 23.15 RPS |
| Rounded design target | 31 RPS |
| Design RPM | 1,860 |
The planning reserve is a capacity allowance, not automatically extra daily usage or a 30% increase in the invoice. If measured peak retry amplification, fan-out and growth exceed the allowance, recompute the target explicitly.
A uniform 24-hour average can be misleading. A consumer application may have time-zone-dependent peaks, and an enterprise customer may concentrate nearly all requests into business hours. If the same 500,000 calls arrive uniformly during eight hours, the average within those hours is approximately 17.36 RPS even before intra-hour bursts. Use real minute-level and shorter-interval traffic distributions, segment by geography and tenant, and consider campaigns, synchronized batch jobs and failure recovery.
3. Calculate token throughput#
Daily input tokens:
500,000 × 1,000 = 500,000,000.
Daily output tokens:
500,000 × 300 = 150,000,000.
| Volume | Input tokens | Output tokens |
|---|---|---|
| Per logical call | 1,000 | 300 |
| Per day | 500 million | 150 million |
| Per 30 days | 15 billion | 4.5 billion |
| Per second at 31 RPS | 31,000 | 9,300 |
| Per minute at 31 RPS | 1,860,000 | 558,000 |
The combined illustrative design throughput is 2,418,000 tokens per minute. Keep the input and output dimensions separate because models and providers may have different prefill and decoding constraints, quota definitions and prices.
Do not provision solely from mean sequence lengths. A mixture of short classification requests, long RAG prompts and multi-thousand-token completions can create very different instantaneous throughput and concurrency. Model the joint distribution of request rate, input length, output length and latency. Reserve capacity for realistic burst cohorts and enforce context/output limits.
Provider token-per-minute accounting can depend on requested maximum output, estimated token counts, cached inputs or actual usage, depending on the product and configuration. Billing and admission-quota accounting are not necessarily the same. Validate both against the contracted model, account, region and deployment type.
4. Estimate concurrent requests with Little's Law#
For a stable system observed over an appropriate period:
Average number in system = arrival rate × average time in system.
With 31 attempts per second and a mean in-flight duration of three seconds at that operating point:
31 × 3 = 93 average in-flight attempts.
At the unreserved average rate, approximately 17.36 attempts would be in flight under the same latency assumption. At the unreserved peak of 23.15 RPS, approximately 69.44 would be in flight.
These are steady-state mean occupancy estimates, not maximum concurrency or a tail-latency guarantee. If arrival rate temporarily exceeds service capacity, queue depth grows and the steady-state assumptions no longer describe the transient backlog. The three-second assumption must also be measured at relevant load: service time can increase when the system saturates.
Distinguish provider in-flight calls, gateway requests, asynchronous jobs, database transactions, streaming connections and background tool executions. They have different residence times. For a streaming endpoint, time to first token can be low while a connection remains occupied for many seconds. Measure time to first token, generation throughput, completion time, disconnects and cancellation separately.
5. Estimate inference cost#
Use the model's actual billing units. For the illustrative per-million-token prices:
Daily input cost = 500 million / 1 million × $1 = $500.
Daily output cost = 150 million / 1 million × $4 = $600.
Total daily inference cost = $1,100.
| Cost component | Per call | Per day | Per 30 days |
|---|---|---|---|
| Input | $0.0010 | $500 | $15,000 |
| Output | $0.0012 | $600 | $18,000 |
| Total | $0.0022 | $1,100 | $33,000 |
The implied inference cost per active user-day is ten calls × $0.0022 = $0.022. Fifteen million calls is the 30-day volume under constant daily activity, not the number of unique monthly users. Do not multiply DAU by days and label the result monthly active users.
All dollar figures use hypothetical USD prices. No current model pricing, vendor quota or negotiated discount has been verified. Real charges may include cached-token tiers, reasoning tokens, tool execution, embeddings, storage, batch discounts, dedicated capacity, minimum commitments and taxes. Obtain current official pricing and the customer contract before using this estimate in a proposal.
6. Sensitivity analysis and caching#
Treat the base estimate as a scenario rather than a prediction.
| Scenario | Billable calls per day | Approximate inference cost per 30 days |
|---|---|---|
| Baseline | 500,000 | $33,000 |
| Output length doubles to 600 tokens | 500,000 | $51,000 |
| 20% full-response cache hit rate | 400,000 | $26,400 |
| 5% additional equally billable attempts, no cache | 525,000 | $34,650 |
| 20% full-response hits and 5% extra attempts on misses | 420,000 | $27,720 |
The table holds the stated input/output prices and other assumptions constant, except for the named change. Real retry costs can differ because failed attempts may consume fewer or more tokens, and cache hits may cluster outside peak periods.
A full-response cache can avoid a model call entirely when the response is reusable and the application permits reuse. A provider prompt cache generally reduces the cost or compute of matching input prefixes but does not necessarily eliminate output generation or consume no quota. A retrieval cache can reduce vector searches or repeated document processing without avoiding inference. Track each cache separately.
Cache keys must include the relevant model/configuration, prompt version, source version, tenant and access scope where required. Never serve one tenant's confidential content to another. Do not cache side-effecting agent actions as though they were harmless deterministic responses. Revalidate authorization and freshness on cache hits, and handle invalidation, deletion, policy changes and cache stampedes.
Other cost levers include shortening retrieved context without dropping evidence, setting sensible output limits, routing simple tasks to evaluated lower-cost models, avoiding unnecessary agent steps, using asynchronous batch processing when latency allows and reducing failed attempts. Evaluate task success and safety for each optimization; a cheaper model that triggers many retries or human escalations may increase cost per successful task.
7. A production architecture#
The application must derive tenant identity from trusted authentication. Apply authorization at retrieval and cache access, enforce per-tenant and shared resource budgets, and store only necessary sensitive data. Model instructions cannot change tenant scope, authorize additional spending or bypass the admission policy.
Use a quota-aware router and connection pooling. Maintain explicit deadlines and a bounded queue for work that can wait. Interactive traffic should usually have a low queue-wait budget, while asynchronous batch jobs may tolerate delayed processing. Apply separate priorities and budgets so bulk jobs cannot starve interactive users.
A provider fallback must satisfy the same privacy, data-residency, tool and output-contract requirements. Capacity at a second provider is not useful if the application cannot safely or correctly use it. Prevent retries from switching providers repeatedly without a bounded global attempt budget.
8. What to provision when using hosted model APIs#
For the 31 RPS design target, check contractual or configured capacity for at least the illustrative 1,860 RPM and the estimated token throughput under a no-full-response-cache planning case. Confirm request and token limits at the relevant time granularities, model and regional scopes. Also validate concurrent connections, burst enforcement, maximum context and output length, and actual tail latency. A minute-level quota alone cannot guarantee admission during a concentrated one-second burst.
An illustrative application-tier sizing calculation:
Suppose a representative load test shows that one gateway worker can safely handle 25 simultaneous streaming calls under the latency and memory requirements. If we target no more than 70% of those slots, we conservatively budget floor(25 × 0.70) = 17 slots per worker.
ceil(93 / 17) = 6 workers.
Adding one worker for a single-worker-loss scenario gives seven workers in this simplified model: six remaining workers offer 102 planned slots. The result is not a production recommendation. It uses mean occupancy, an assumed benchmark and a narrow failure model. Size against measured high-percentile concurrency, arrival bursts, CPU, memory, sockets, network limits, and availability-zone failure capacity. Test autoscaling lag and whether the remaining workers can actually sustain the design rate.
The rest of the system also needs capacity:
| Component | Main sizing input |
|---|---|
| API gateway and streaming tier | Peak RPS, open connections, network bandwidth, CPU and memory |
| Provider client pools | Concurrent attempts, connection lifetimes, timeouts |
| Retrieval service and vector index | Query rate, corpus size, index recall, search/filter cost |
| Database and cache | Read/write throughput, working set, pool occupancy and hot keys |
| Queue and background workers | Arrival and processing rates, queue age, deadlines |
| Observability | Event volume, cardinality, trace sampling and retention |
| Durable usage ledger | Billable attempts, reconciliation, tenant and project dimensions |
Do not provision GPUs locally just because the application uses a hosted LLM API. The provider handles model serving; the application still needs infrastructure, quota access and failure mitigation.
9. What changes when hosting the model yourself?#
Self-hosting changes the calculation from per-token API pricing to accelerator serving capacity and total cost of ownership.
Separate prefill, which processes input context, from decode, which generates output tokens. Throughput depends on architecture, parameter count, precision/quantization, prompt length, output length, batch composition, KV cache, interconnect and serving engine.
Benchmark the intended model and hardware at the target request mix and latency SLO. Compare supported input tokens per second, output tokens per second, achieved requests per second, time to first token, inter-token latency, memory headroom and maximum feasible concurrency. Continuous batching can improve accelerator utilization but changes queueing and latency. Independent prefill/decode throughput measurements cannot simply be combined as if both workloads had separate dedicated hardware unless the deployment actually does.
For example, if a tested serving replica can sustainably handle 4 RPS of the exact representative workload within the target latency constraints and a chosen 75% planning utilization, the illustrative per-replica planning rate is 3 RPS. A first throughput estimate is ceil(31 / 3) = 11 replicas before failure reserve. If each replica requires multiple GPUs to fit the model and KV cache, GPU count is replica count multiplied by GPUs per replica. Neither the benchmark nor any GPU model is supplied by the question; the numbers here are hypothetical. Verify memory, token-throughput and concurrency limits independently.
Compare self-hosted and hosted costs using actual GPU-hour prices, uptime, spare capacity, storage, networking, operations and utilization. A replica available around the clock incurs cost even when traffic is low. A meaningful comparison uses cost per successful workload, not just a theoretical maximum tokens-per-second benchmark.
10. Tested Python capacity and cost model#
The following dependency-free example reproduces the baseline estimates. Prices are expressed in USD per million tokens. Fraction preserves exact rational arithmetic for decimal assumptions supplied as strings or ordinary decimal-valued numbers, and ceiling rounds the planning capacity upward.
PYTHONfrom fractions import Fraction from math import ceil def plan(dau, calls, input_tokens, output_tokens, *, peak_factor, reserve, latency_s, input_price, output_price, days=30): counts = (dau, calls, input_tokens, output_tokens, days) if any(type(x) is not int or x < 0 for x in counts) or days == 0: raise ValueError('nonnegative integer counts and positive days required') peak, head, latency, pi, po = map( lambda x: Fraction(str(x)), (peak_factor, reserve, latency_s, input_price, output_price)) if peak < 1 or head < 1 or min(latency, pi, po) < 0: raise ValueError('invalid workload or pricing assumptions') daily = dau * calls avg = Fraction(daily, 86400) design_rps = ceil(avg * peak * head) rpm = design_rps * 60 daily_cost = Fraction(daily, 1_000_000) * (input_tokens*pi + output_tokens*po) return dict(daily_calls=daily, avg_rps=avg, peak_rps=avg*peak, design_rps=design_rps, rpm=rpm, input_tpm=rpm*input_tokens, output_tpm=rpm*output_tokens, concurrency=ceil(design_rps*latency), daily_cost=daily_cost, period_cost=daily_cost*days)
Example:
PYTHONp = plan(50000, 10, 1000, 300, peak_factor=4, reserve=1.3, latency_s=3, input_price=1, output_price=4) assert p['daily_calls'] == 500000 assert p['design_rps'] == 31 assert p['rpm'] == 1860 assert p['input_tpm'] == 1860000 assert p['output_tpm'] == 558000 assert p['concurrency'] == 93 assert p['daily_cost'] == 1100 assert p['period_cost'] == 33000
The function accepts nonnegative integer counts, a positive integer period, peak and reserve multipliers of at least one, and nonnegative finite numeric assumptions representable by Fraction. Its concurrency result is a rounded steady-state average occupancy estimate, not a safe hard concurrency limit. The daily bill uses logical calls with no cache or retry adjustments; the reserve affects only planning capacity. Apply explicit adjusted call volumes or an attempt-distribution model for alternative billing scenarios. The computation is a constant number of arithmetic operations, excluding the bit complexity of arbitrary-precision integers and rational arithmetic.
Local verification: Python 3.13.5 executed the exact function. All 2,312 checks passed: 2,304 parameter combinations over user counts, calls, input/output lengths, peak multipliers, reserves, latency, prices and billing periods, compared against independent integer-ceiling and rational cost calculations, plus eight invalid-input checks. The baseline example was executed separately and matched the displayed values. Tests verify the mathematical model under its assumptions; they do not validate traffic forecasts, provider quotas, real-world GPU performance or vendor invoices.
11. Failure handling and operational safeguards#
| Failure or risk | Engineering response |
|---|---|
| Provider returns rate-limit errors | Enforce a coordinated local admission policy, honor retry guidance, bound retries |
| Provider latency rises | Apply deadlines, cap in-flight work, avoid unbounded queues |
| Token use exceeds estimates | Reserve conservatively, enforce context limits, reconcile actual usage |
| Cost spike from agent loops | Bound steps, tool calls, token budget and spending per logical operation |
| Cache outage or cold start | Test cache-miss traffic and use load shedding if required |
| One tenant dominates | Apply fair per-tenant quotas and shared global budgets |
| Provider or regional outage | Activate approved failover or degrade safely; test independent capacity |
| Application crash after a write | Preserve idempotency and reconcile uncertain outcomes |
| Queue backlog grows | Monitor oldest job age, stop admission or increase capacity within downstream limits |
Separate retryable transient errors from permanent errors. A retry may be billable even if the original response was lost. A model-generated action can have external effects; use stable operation IDs, enforce permissions and prevent duplicate business effects independently of model-call accounting.
Implement a budget ledger that records actual provider usage, model, operation, tenant, attempt ID and cost basis. Estimate/reserve usage before admission when necessary, reconcile with authoritative usage afterward, and resolve ambiguous outcomes without double-charging. Define a hard spending-control policy separately from forecasting dashboards.
12. Monitoring, load tests and rollout#
Track:
- Logical calls, actual provider attempts, cache hits, fallback and retry rates.
- Input/output tokens per request and per time interval, including high-percentile lengths.
- Client-visible latency, time to first token, completion latency, error rates and concurrent streams.
- Provider quota utilization, 429s, queue delay, rejected work and pool saturation.
- Cost per active user-day, successful task, tenant and model; daily/monthly forecast error.
- Task quality, safety and customer acceptance before and after cost-saving changes.
Load-test an arrival distribution derived from actual customer usage, including bursts, long contexts and mixed workloads. Include no-cache scenarios, partial failures and representative concurrency. Measure scheduled arrivals, dropped or rejected work and timeouts; do not let a load generator conceal tail latency by waiting for slow responses before sending the next arrival when that does not model the intended workload.
Set measurable launch gates with the customer: successful-task rate, latency SLO, token-budget compliance, maximum queue age and cost envelope. Start with a controlled rollout, compare estimates to actual usage, and adjust quotas and capacity based on data. Reserve additional capacity or pre-warm before predictable demand events; autoscaling does not instantly create provider quota or accelerator capacity.
Likely interviewer follow-ups#
Why is 5.79 RPS not the provisioning answer? It is a 24-hour average. Peak arrival rate, bursts, token lengths, retries and service-time variability determine actual demand.
Why calculate both RPM and TPM? The same request rate can produce dramatically different token throughput depending on context and generation length, and providers may enforce multiple quota dimensions.
Does 93 concurrent requests mean 93 threads or GPUs? No. It is an estimate of mean in-flight occupancy under the assumed design workload. Runtime architecture, model throughput and tail behavior determine resources.
How would you reduce the $33,000 estimate? Measure actual usage, evaluate prompt shortening, scoped caching, model routing and output budgets, and compare cost per successful task while preserving quality and safety.
Can I guarantee the provider will support 1,860 RPM? Not from this calculation. Confirm current model-specific account and regional quotas, contractual capacity and burst behavior, then test the integration.
What if 50,000 DAU grows to 100,000? With unchanged call frequency, token lengths and prices, baseline volume and inference cost double. Peak capacity needs recalculation with the new traffic profile; shared bottlenecks may not scale linearly.
What is the FDE takeaway? Convert product usage into measurable workload and cost units, make assumptions explicit, verify the customer-facing SLO and provision against tested demand rather than an unsupported infrastructure guess.
References
- 1.OpenAI API pricing (not live-verified)openai.com
- 2.OpenAI API rate limits guide (not live-verified)platform.openai.com
- 3.Anthropic pricing documentation (not live-verified)docs.anthropic.com
- 4.
- 5.
- 6.vLLM documentation (not live-verified)docs.vllm.ai
- 7.Python fractions documentation (not live-verified)docs.python.org
Related questions
Explore other topics:AI AgentsAI System DesignLarge Language Models