Problems / AI systems, hard

Uploads starve questions

Questions and document ingestion share one embedding quota. Uploads double and both paths start failing.

Free to open. Runs in your browser, no sign-up.

Your goals

Success ≥ 99%, time to first token p99 ≤ 2 s.

The traffic

40 requests a second for 30 seconds: 70% ask (reads), 30% upload (writes).

The system

What each component does in this design, and what calls it. The simulator mimics each one from these settings.

ComponentIts job hereSettings
Load balancerLoad balancerTraffic enters here.Calls Q&A API.Layer 4 balancers route by IP and port; layer 7 balancers read HTTP and can route by path or header.–
Q&A APIApp serviceLoad balancer forwards to it.Calls Semantic cache (checked first), Embedding model, Vector DB, Reranker, Answer model, S3 (documents), Ingestion queue (SQS) (publishes).Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s.3 replicas × 300 slots · timeout 30 s
Semantic cacheSemantic cacheQ&A API checks it first for reads.A semantic cache matches questions by meaning using embeddings, not exact text.30% hit rate
Embedding modelEmbedding modelQ&A API calls it for reads. Ingestion workers (chunk + embed) calls it.Embeddings turn text into vectors where similar meanings sit close together.–
Vector DBVector DBQ&A API calls it for reads. Ingestion workers (chunk + embed) calls it.Approximate indexes like HNSW trade a little recall for much faster search.–
RerankerRerankerQ&A API calls it for reads.A reranker reads each retrieved passage together with the question and reorders by relevance.48 slots
Answer modelLLM endpointQ&A API calls it for reads.Latency has two parts: time to the first token, then a steady stream of tokens per second.300 streams · 20M input tokens/min
S3 (documents)Object storageQ&A API calls it for writes. Ingestion workers (chunk + embed) calls it.Object stores like S3 keep copies across devices and facilities for very high durability.5000 slots · 300,000 calls/min
Ingestion queue (SQS)Message queueQ&A API publishes to it for writes.Calls Ingestion workers (chunk + embed).If a consumer does not finish within the visibility timeout, the message is delivered again.–
Ingestion workers (chunk + embed)WorkerIngestion queue (SQS) consumes from it.Calls S3 (documents), Embedding model, Vector DB.Queues deliver at least once, so a worker can see the same message twice.16 concurrent jobs

Hints

Try it first. Open one hint at a time if you get stuck.

Hint 1

Find the 429s.

Hint 2

Fewer question embeddings leave quota for ingestion.

One way to solve it

Raise the semantic cache hit rate, or give ingestion its own quota.

More ai systems problems