Module 11 · ML System Design · Lesson 23 of 34
Designing an AI feature for production
From requirements to architecture: latency, cost, scale and quality targets, and the levers that move them.
In this lesson · about 22 minutes
- Turn a feature idea into measurable requirements
- Sketch the standard architecture of an LLM feature
- Use model choice, routing, caching and streaming to meet cost and latency targets
1. Requirements first
- Quality: which eval, which pass rate, which must-pass cases.
- Latency: e.g. first words within 1 s, full answer within 5 s for 95% of requests (p95).
- Scale: requests per day and at peak; tokens per request.
- Cost: a budget per request or per month.
- Risk and compliance: personal data, where data may be stored, what must be logged, who reviews what.
2. The usual architecture
Client → API gateway (auth, rate limits) → orchestration service (builds the prompt, calls tools and retrieval, applies guardrails) → model provider (or your own hosted model). Around it: a vector store and databases, a cache, a queue for slow or batch work, and logging, tracing and evals watching everything.
3. Where time and money go
- Latency ≈ time to first token + output tokens ÷ generation speed. Output length usually dominates. Shorter answers and streaming help most.
- Cost ≈ input tokens × input price + output tokens × output price. Long prompts (history, retrieved chunks) usually dominate.
Try it · simulator
Production sizing: cost, latency and scale
Size an AI feature for production. Pick a model, set the traffic and token counts, then use routing and caching to hit your latency target and budget.
Cost per month
$24,750
Average latency
4.3s
p95 latency (est.)
7.8s
Peak tokens / minute
447,917
Cost per request
$0.0165
Peak requests / s
1.7
Quality score (eval)
88%
Meets latency target
No
Illustrative prices and speeds for three generic model sizes. Peak traffic is assumed to be 3× the daily average; p95 ≈ 1.8 × average. The quality score stands in for your own eval results.
Check your understanding0 of 3 correct
Quiz score: 0 of 3
Written by Noviq Academy in its own words. The simulators are small teaching models that keep the real idea and leave out the scale; their numbers (prices, speeds, scores) are illustrative. Model names, prices and features change quickly, so check your provider's current documentation before you build. Read-aloud uses your device's built-in voices.