Problems / AI systems, medium

Uploads starve questions

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

Unlock it once for 15 credits; everything inside it is free (runs, changes, Submit, results, hints). Sign in with Google to start; new accounts get free credits.

Your goals

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

Test cases

Like a coding problem, a solution has to pass every case, not just the one it was built for. Submit in the lab runs all 5; 1 of them are hidden until then.

  1. As given. The problem’s own traffic, scheduled failures and seed.
  2. Peak hour. 25% more traffic than the problem states, with the same failures.
  3. A slow dependency. The main data store or model answers twice as slowly for part of the run.
  4. A server dies. One replica of the service with the most replicas is killed for part of the run.

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

More ai systems problems