AI apps · Staff · Scatter-gather retrieval in region cells, one crawl feeding every index
AI answer engine system design, running live
An answer engine across five regions with different jobs. N. Virginia and Frankfurt are cores: they serve their own traffic and also run the crawler, usage rollups and billing. Oregon, Mumbai and Singapore are edges that only serve, each sized for its own traffic and its partner's, with fewer search groups and GPUs where traffic is lighter. A question checks an answer cache, then searches the region's web and semantic indexes, adds live web results for recent events, reranks on GPUs and streams a cited answer. At peak no part runs above 31%.
A teaching design of a system like Perplexity, not Perplexity's real architecture. Traffic, capacity and cost are simulator estimates. Model and assumptions.
- Traffic
- 102,005 req/sHuge scale
- AWS bill
- $21.9M/mo
- p99
- 6.2 s
- Components
- 221
100,000 requests a second at the daily peak, plus 2,000 pages a second from the crawler: about 41,000 suggestion calls as people type, 30,000 library calls, 19,400 web app hits and 9,300 questions. If someone asks a question every two minutes, that is about 1.1 million people asking at once. The numbers are an assumption for a large answer engine, not a published figure.
How it works
- Route 53 sends each person to the nearest of five regions and fails over to a partner: N. Virginia and Oregon cover each other, Frankfurt falls back to N. Virginia, and Mumbai and Singapore cover each other.
- The two cores do the write and batch work. N. Virginia runs the crawler, the accounts writer and billing, next to the usage data billing reads. Frankfurt runs the usage rollups for Europe and Asia, so usage records from Mumbai and Singapore travel to Frankfurt, not across two oceans.
- Every region serves questions the same way, but sized to its load: N. Virginia has four search groups and 16 reranker hosts, Singapore two groups and seven hosts. A question first hits the answer cache; popular questions asked within the hour, about 35% of the total, stream a finished answer straight back.
- On a miss the answer server has the query planner rewrite the question, embeds it, and sends it through the search load balancer to one search group. The group's coordinator searches both partitions of the web index and a semantic index copy, then merges the hits.
- About a quarter of questions are about something recent, so the live web search API adds fresh results, and for one in ten the page fetcher pulls a page the crawler hasn't stored yet. GPU rerankers keep the best passages, the model writes an answer that cites them, and the thread and a usage record are written.
- In N. Virginia the crawler fetches 2,000 pages a second, archives them as WARC files, splits and embeds the passages, and a Flink job batches the index updates. Each region's Lambda loader reads that stream and writes the batches into its own indexes.
What each part does
- Web app assets
- Origin bucket for the web app behind every CloudFront edge.
- Accounts writer
- Aurora Global Database writer. Every region reads locally and sends its rare account writes here.
- Hourly billing run
- Starts the hourly billing job, in the same region as the usage data it reads.
- Billing sync
- Reads the usage table in N. Virginia, where the global table already holds both cores' totals, and reports it to Stripe. Three workers, so losing an AZ only slows the run.
- Stripe
- Subscriptions and invoices.
- Recrawl scheduler
- 2,000 pages a second due for a crawl, picked by how often each page changes and how often it is cited.
- URL frontier
- URLs waiting to be fetched, so fetchers pull work at a polite, steady rate.
- Async fetchers
- Async fetchers that keep thousands of downloads open per host and respect robots.txt and per-site rate limits. CPU is the limit; it is a custom part because the palette's worker holds a thread per job.
- Websites
- The open web, about 400 ms per page.
- Fetched pages
- Every fetched page, 12 shards, read by the archive writer and the parsers.
- WARC writer
- Packs pages into large WARC files, so the archive takes one write per hundred pages.
- Raw page archive
- Raw page archive, kept so the index can be rebuilt with a new parser or embedding model.
- Parse and chunk
- Lambda that strips boilerplate, splits the page into passages and embeds them. Runs across every AZ, and Kinesis retries a failed batch.
- Chunk embeddings
- Titan embeddings for new passages. The simulator sends one call per page; a real page is several chunks, so the real token bill is a few times this.
- Page records
- One record per URL: content hash, last crawl, how often it changes.
- Parsed pages
- Parsed passages and their vectors, 12 shards.
- Index batcher
- Flink job that groups updates by partition into bulk requests of about a hundred documents.
- Index updates
- Bulk index updates. Every region's index loader reads all of them.
- People · N. Virginia
- 30,000 requests a second from the apps and the website near N. Virginia.
- Route 53 · N. Virginia
- Latency routing keeps N. Virginia in this region and sends it to Oregon when this region's health checks fail.
- CloudFront edge
- Serves the web app's scripts and images; 98% never reach the origin bucket.
- Answer streaming
- Takes each question and streams the answer back over one open connection for the 3 seconds the model writes. It runs the retrieval steps, then the model call. 8 hosts, sized for this region plus anything that fails over to it. Async servers hold a connection, not a thread, so CPU is the limit; it is a custom part because the palette's API server blocks a thread per request.
- Answer cache
- Finished answers to popular questions, keyed by the normalised question and the hour. About 35% of questions hit, and a hit skips retrieval and the model entirely. Follow-ups never hit, because they depend on the thread.
- Plan limits
- Checks the plan's daily allowance before any answer is generated. Cached answers cost nothing and skip the check.
- Limits and sessions
- Allowance counters and session lookups, three shards across three AZs, 98% hits.
- Accounts reader
- Aurora Global Database reader in this region for plan and account lookups the cache misses.
- Query planner
- Turns a follow-up into a standalone search query and decides whether the question needs live results from the web.
- Query embeddings
- Titan embeddings for the rewritten query, about 50 tokens each, on a 30M tokens-per-minute quota.
- Semantic index A
- Copy A of the semantic passage index, ten nodes, shared by half of this region's search groups.
- Semantic index B
- Copy B of the semantic passage index, ten nodes, shared by half of this region's search groups.
- Web index 1A
- Partition 1 of the keyword web index in search group A, ten nodes. This region runs 4 groups, so each sees 1 in 4 of its questions.
- Web index 2A
- Partition 2 of the keyword web index in search group A, ten nodes. This region runs 4 groups, so each sees 1 in 4 of its questions.
- Web index 1B
- Partition 1 of the keyword web index in search group B, ten nodes. This region runs 4 groups, so each sees 1 in 4 of its questions.
- Web index 2B
- Partition 2 of the keyword web index in search group B, ten nodes. This region runs 4 groups, so each sees 1 in 4 of its questions.
- Web index 1C
- Partition 1 of the keyword web index in search group C, ten nodes. This region runs 4 groups, so each sees 1 in 4 of its questions.
- Web index 2C
- Partition 2 of the keyword web index in search group C, ten nodes. This region runs 4 groups, so each sees 1 in 4 of its questions.
- Web index 1D
- Partition 1 of the keyword web index in search group D, ten nodes. This region runs 4 groups, so each sees 1 in 4 of its questions.
- Web index 2D
- Partition 2 of the keyword web index in search group D, ten nodes. This region runs 4 groups, so each sees 1 in 4 of its questions.
- Search group A
- Coordinator for search group A: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Search group B
- Coordinator for search group B: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Search group C
- Coordinator for search group C: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Search group D
- Coordinator for search group D: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Reranker GPUs
- Scores the top passages against the question and keeps the best few for the model. 16 self-hosted g6.12xlarge hosts with four NVIDIA L4 GPUs each, sized for this region plus its failover load. Assumes 500 questions a second per host, each scoring about 20 short passages; load-test your own model.
- Live web search
- A paid web search API for what the index hasn't crawled yet, about a quarter of questions. Assumes a 2,500 requests-a-second limit per regional key.
- Page fetcher
- Fetches the full text of a top result the crawler hasn't stored yet, for about one question in ten. Behind its own load balancer, so losing an AZ only takes away capacity.
- Publisher sites
- The websites behind those results, about half a second per page.
- Model quota A
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota B
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota C
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota D
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Threads API
- The library: past threads, shared thread pages, renames and deletes.
- Thread cache
- Recently opened threads and shared thread pages, 80% hits. Writes go straight to the table.
- Threads
- Every question, answer and citation list, a DynamoDB global table replicated to every region.
- Suggest API
- Query suggestions as people type, about four calls for every question asked.
- Suggestion cache
- Suggestions for common prefixes, 97% hits.
- Prefix table
- DynamoDB table of the top suggestions for each prefix, rebuilt daily from popular questions. Serves the cache misses.
- Usage events
- One usage record per generated answer from N. Virginia and Oregon, 16 shards. The other regions write here across the ocean.
- Usage rollups
- Flink job that sums answers and tokens per account per minute for allowances and billing.
- Usage per account
- Per-account usage, a DynamoDB global table, so the billing job in N. Virginia reads both cores' totals locally.
- Index loader
- Lambda that reads index updates from N. Virginia and bulk-writes them into this region's web and semantic indexes.
- People · Oregon
- 18,000 requests a second from the apps and the website near Oregon.
- Route 53 · Oregon
- Latency routing keeps Oregon in this region and sends it to N. Virginia when this region's health checks fail.
- CloudFront edge
- Serves the web app's scripts and images; 98% never reach the origin bucket.
- Answer streaming
- Takes each question and streams the answer back over one open connection for the 3 seconds the model writes. It runs the retrieval steps, then the model call. 6 hosts, sized for this region plus anything that fails over to it. Async servers hold a connection, not a thread, so CPU is the limit; it is a custom part because the palette's API server blocks a thread per request.
- Answer cache
- Finished answers to popular questions, keyed by the normalised question and the hour. About 35% of questions hit, and a hit skips retrieval and the model entirely. Follow-ups never hit, because they depend on the thread.
- Plan limits
- Checks the plan's daily allowance before any answer is generated. Cached answers cost nothing and skip the check.
- Limits and sessions
- Allowance counters and session lookups, three shards across three AZs, 98% hits.
- Accounts reader
- Aurora Global Database reader in this region for plan and account lookups the cache misses.
- Query planner
- Turns a follow-up into a standalone search query and decides whether the question needs live results from the web.
- Query embeddings
- Titan embeddings for the rewritten query, about 50 tokens each, on a 30M tokens-per-minute quota.
- Semantic index A
- Copy A of the semantic passage index, ten nodes, shared by half of this region's search groups.
- Semantic index B
- Copy B of the semantic passage index, ten nodes, shared by half of this region's search groups.
- Web index 1A
- Partition 1 of the keyword web index in search group A, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 2A
- Partition 2 of the keyword web index in search group A, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 1B
- Partition 1 of the keyword web index in search group B, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 2B
- Partition 2 of the keyword web index in search group B, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 1C
- Partition 1 of the keyword web index in search group C, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 2C
- Partition 2 of the keyword web index in search group C, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Search group A
- Coordinator for search group A: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Search group B
- Coordinator for search group B: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Search group C
- Coordinator for search group C: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Reranker GPUs
- Scores the top passages against the question and keeps the best few for the model. 10 self-hosted g6.12xlarge hosts with four NVIDIA L4 GPUs each, sized for this region plus its failover load. Assumes 500 questions a second per host, each scoring about 20 short passages; load-test your own model.
- Live web search
- A paid web search API for what the index hasn't crawled yet, about a quarter of questions. Assumes a 2,500 requests-a-second limit per regional key.
- Page fetcher
- Fetches the full text of a top result the crawler hasn't stored yet, for about one question in ten. Behind its own load balancer, so losing an AZ only takes away capacity.
- Publisher sites
- The websites behind those results, about half a second per page.
- Model quota A
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota B
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota C
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota D
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Threads API
- The library: past threads, shared thread pages, renames and deletes.
- Thread cache
- Recently opened threads and shared thread pages, 80% hits. Writes go straight to the table.
- Threads
- Every question, answer and citation list, a DynamoDB global table replicated to every region.
- Suggest API
- Query suggestions as people type, about four calls for every question asked.
- Suggestion cache
- Suggestions for common prefixes, 97% hits.
- Prefix table
- DynamoDB table of the top suggestions for each prefix, rebuilt daily from popular questions. Serves the cache misses.
- Index loader
- Lambda that reads index updates from N. Virginia and bulk-writes them into this region's web and semantic indexes. Usage records from this edge go to N. Virginia.
- People · Frankfurt
- 20,000 requests a second from the apps and the website near Frankfurt.
- Route 53 · Frankfurt
- Latency routing keeps Frankfurt in this region and sends it to N. Virginia when this region's health checks fail.
- CloudFront edge
- Serves the web app's scripts and images; 98% never reach the origin bucket.
- Answer streaming
- Takes each question and streams the answer back over one open connection for the 3 seconds the model writes. It runs the retrieval steps, then the model call. 5 hosts, sized for this region plus anything that fails over to it. Async servers hold a connection, not a thread, so CPU is the limit; it is a custom part because the palette's API server blocks a thread per request.
- Answer cache
- Finished answers to popular questions, keyed by the normalised question and the hour. About 35% of questions hit, and a hit skips retrieval and the model entirely. Follow-ups never hit, because they depend on the thread.
- Plan limits
- Checks the plan's daily allowance before any answer is generated. Cached answers cost nothing and skip the check.
- Limits and sessions
- Allowance counters and session lookups, three shards across three AZs, 98% hits.
- Accounts reader
- Aurora Global Database reader in this region for plan and account lookups the cache misses.
- Query planner
- Turns a follow-up into a standalone search query and decides whether the question needs live results from the web.
- Query embeddings
- Titan embeddings for the rewritten query, about 50 tokens each, on a 30M tokens-per-minute quota.
- Semantic index A
- Copy A of the semantic passage index, ten nodes, shared by half of this region's search groups.
- Semantic index B
- Copy B of the semantic passage index, ten nodes, shared by half of this region's search groups.
- Web index 1A
- Partition 1 of the keyword web index in search group A, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 2A
- Partition 2 of the keyword web index in search group A, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 1B
- Partition 1 of the keyword web index in search group B, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 2B
- Partition 2 of the keyword web index in search group B, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 1C
- Partition 1 of the keyword web index in search group C, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 2C
- Partition 2 of the keyword web index in search group C, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Search group A
- Coordinator for search group A: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Search group B
- Coordinator for search group B: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Search group C
- Coordinator for search group C: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Reranker GPUs
- Scores the top passages against the question and keeps the best few for the model. 10 self-hosted g6.12xlarge hosts with four NVIDIA L4 GPUs each, sized for this region plus its failover load. Assumes 500 questions a second per host, each scoring about 20 short passages; load-test your own model.
- Live web search
- A paid web search API for what the index hasn't crawled yet, about a quarter of questions. Assumes a 2,500 requests-a-second limit per regional key.
- Page fetcher
- Fetches the full text of a top result the crawler hasn't stored yet, for about one question in ten. Behind its own load balancer, so losing an AZ only takes away capacity.
- Publisher sites
- The websites behind those results, about half a second per page.
- Model quota A
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota B
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota C
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota D
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Threads API
- The library: past threads, shared thread pages, renames and deletes.
- Thread cache
- Recently opened threads and shared thread pages, 80% hits. Writes go straight to the table.
- Threads
- Every question, answer and citation list, a DynamoDB global table replicated to every region.
- Suggest API
- Query suggestions as people type, about four calls for every question asked.
- Suggestion cache
- Suggestions for common prefixes, 97% hits.
- Prefix table
- DynamoDB table of the top suggestions for each prefix, rebuilt daily from popular questions. Serves the cache misses.
- Usage events
- One usage record per generated answer from Frankfurt, Mumbai and Singapore, 16 shards. The other regions write here across the ocean.
- Usage rollups
- Flink job that sums answers and tokens per account per minute for allowances and billing.
- Usage per account
- Per-account usage, a DynamoDB global table, so the billing job in N. Virginia reads both cores' totals locally.
- Index loader
- Lambda that reads index updates from N. Virginia and bulk-writes them into this region's web and semantic indexes.
- People · Mumbai
- 20,000 requests a second from the apps and the website near Mumbai.
- Route 53 · Mumbai
- Latency routing keeps Mumbai in this region and sends it to Singapore when this region's health checks fail.
- CloudFront edge
- Serves the web app's scripts and images; 98% never reach the origin bucket.
- Answer streaming
- Takes each question and streams the answer back over one open connection for the 3 seconds the model writes. It runs the retrieval steps, then the model call. 5 hosts, sized for this region plus anything that fails over to it. Async servers hold a connection, not a thread, so CPU is the limit; it is a custom part because the palette's API server blocks a thread per request.
- Answer cache
- Finished answers to popular questions, keyed by the normalised question and the hour. About 35% of questions hit, and a hit skips retrieval and the model entirely. Follow-ups never hit, because they depend on the thread.
- Plan limits
- Checks the plan's daily allowance before any answer is generated. Cached answers cost nothing and skip the check.
- Limits and sessions
- Allowance counters and session lookups, three shards across three AZs, 98% hits.
- Accounts reader
- Aurora Global Database reader in this region for plan and account lookups the cache misses.
- Query planner
- Turns a follow-up into a standalone search query and decides whether the question needs live results from the web.
- Query embeddings
- Titan embeddings for the rewritten query, about 50 tokens each, on a 30M tokens-per-minute quota.
- Semantic index A
- Copy A of the semantic passage index, ten nodes, shared by half of this region's search groups.
- Semantic index B
- Copy B of the semantic passage index, ten nodes, shared by half of this region's search groups.
- Web index 1A
- Partition 1 of the keyword web index in search group A, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 2A
- Partition 2 of the keyword web index in search group A, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 1B
- Partition 1 of the keyword web index in search group B, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 2B
- Partition 2 of the keyword web index in search group B, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 1C
- Partition 1 of the keyword web index in search group C, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Web index 2C
- Partition 2 of the keyword web index in search group C, ten nodes. This region runs 3 groups, so each sees 1 in 3 of its questions.
- Search group A
- Coordinator for search group A: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Search group B
- Coordinator for search group B: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Search group C
- Coordinator for search group C: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Reranker GPUs
- Scores the top passages against the question and keeps the best few for the model. 10 self-hosted g6.12xlarge hosts with four NVIDIA L4 GPUs each, sized for this region plus its failover load. Assumes 500 questions a second per host, each scoring about 20 short passages; load-test your own model.
- Live web search
- A paid web search API for what the index hasn't crawled yet, about a quarter of questions. Assumes a 2,500 requests-a-second limit per regional key.
- Page fetcher
- Fetches the full text of a top result the crawler hasn't stored yet, for about one question in ten. Behind its own load balancer, so losing an AZ only takes away capacity.
- Publisher sites
- The websites behind those results, about half a second per page.
- Model quota A
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota B
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota C
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota D
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Threads API
- The library: past threads, shared thread pages, renames and deletes.
- Thread cache
- Recently opened threads and shared thread pages, 80% hits. Writes go straight to the table.
- Threads
- Every question, answer and citation list, a DynamoDB global table replicated to every region.
- Suggest API
- Query suggestions as people type, about four calls for every question asked.
- Suggestion cache
- Suggestions for common prefixes, 97% hits.
- Prefix table
- DynamoDB table of the top suggestions for each prefix, rebuilt daily from popular questions. Serves the cache misses.
- Index loader
- Lambda that reads index updates from N. Virginia and bulk-writes them into this region's web and semantic indexes. Usage records from this edge go to Frankfurt.
- People · Singapore
- 12,000 requests a second from the apps and the website near Singapore.
- Route 53 · Singapore
- Latency routing keeps Singapore in this region and sends it to Mumbai when this region's health checks fail.
- CloudFront edge
- Serves the web app's scripts and images; 98% never reach the origin bucket.
- Answer streaming
- Takes each question and streams the answer back over one open connection for the 3 seconds the model writes. It runs the retrieval steps, then the model call. 4 hosts, sized for this region plus anything that fails over to it. Async servers hold a connection, not a thread, so CPU is the limit; it is a custom part because the palette's API server blocks a thread per request.
- Answer cache
- Finished answers to popular questions, keyed by the normalised question and the hour. About 35% of questions hit, and a hit skips retrieval and the model entirely. Follow-ups never hit, because they depend on the thread.
- Plan limits
- Checks the plan's daily allowance before any answer is generated. Cached answers cost nothing and skip the check.
- Limits and sessions
- Allowance counters and session lookups, three shards across three AZs, 98% hits.
- Accounts reader
- Aurora Global Database reader in this region for plan and account lookups the cache misses.
- Query planner
- Turns a follow-up into a standalone search query and decides whether the question needs live results from the web.
- Query embeddings
- Titan embeddings for the rewritten query, about 50 tokens each, on a 30M tokens-per-minute quota.
- Semantic index A
- The region's one copy of the semantic passage index, ten nodes spread over three AZs, used by both search groups.
- Web index 1A
- Partition 1 of the keyword web index in search group A, ten nodes. This region runs 2 groups, so each sees 1 in 2 of its questions.
- Web index 2A
- Partition 2 of the keyword web index in search group A, ten nodes. This region runs 2 groups, so each sees 1 in 2 of its questions.
- Web index 1B
- Partition 1 of the keyword web index in search group B, ten nodes. This region runs 2 groups, so each sees 1 in 2 of its questions.
- Web index 2B
- Partition 2 of the keyword web index in search group B, ten nodes. This region runs 2 groups, so each sees 1 in 2 of its questions.
- Search group A
- Coordinator for search group A: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Search group B
- Coordinator for search group B: sends the query to both web index partitions and a semantic index copy, then merges the hits. Assumes 1,000 merges a second per c7g.large, like a light API call.
- Reranker GPUs
- Scores the top passages against the question and keeps the best few for the model. 7 self-hosted g6.12xlarge hosts with four NVIDIA L4 GPUs each, sized for this region plus its failover load. Assumes 500 questions a second per host, each scoring about 20 short passages; load-test your own model.
- Live web search
- A paid web search API for what the index hasn't crawled yet, about a quarter of questions. Assumes a 2,500 requests-a-second limit per regional key.
- Page fetcher
- Fetches the full text of a top result the crawler hasn't stored yet, for about one question in ten. Behind its own load balancer, so losing an AZ only takes away capacity.
- Publisher sites
- The websites behind those results, about half a second per page.
- Model quota A
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota B
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota C
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Model quota D
- One of 4 quotas sharing this region's answers, 200M tokens per minute each: about 2,000 tokens of question and passages in, 300 out. Quota is paid per token used, so the spare room for failover costs nothing.
- Threads API
- The library: past threads, shared thread pages, renames and deletes.
- Thread cache
- Recently opened threads and shared thread pages, 80% hits. Writes go straight to the table.
- Threads
- Every question, answer and citation list, a DynamoDB global table replicated to every region.
- Suggest API
- Query suggestions as people type, about four calls for every question asked.
- Suggestion cache
- Suggestions for common prefixes, 97% hits.
- Prefix table
- DynamoDB table of the top suggestions for each prefix, rebuilt daily from popular questions. Serves the cache misses.
- Index loader
- Lambda that reads index updates from N. Virginia and bulk-writes them into this region's web and semantic indexes. Usage records from this edge go to Frankfurt.
What breaks first
The four model quotas in N. Virginia, at about 3.2x. The suggest API there follows at about 3.8x, then the reranker GPUs in Frankfurt and Mumbai at about 4x.
At 6x N. Virginia's quotas reject nearly half of its answers. The rerankers and search groups are past their limits too, because they don't autoscale, and the server tiers can't add instances as fast as the traffic climbs. Raising a quota takes a request to the provider, so plan ahead: more quotas, which cost nothing until used; cross-region inference to borrow another region's capacity; a higher cache hit ratio and fewer passages per prompt to cut tokens; then more search groups and GPU hosts before traffic reaches 3.5x.
The simulator checks this every build: it runs the design at 102,005 req/s, then ramps traffic to 6x (612,030 req/s) and records which part fails first. In the playground, press Break it to watch the same thing happen.
Trade-offs
What it gets right
- A failed region moves to its partner with no errors. With N. Virginia down, Oregon's busiest part, the suggest API, runs at 62% while it scales out; with Frankfurt down, N. Virginia's model quotas run at 52%.
- Edges cost what their traffic needs: Before tokens, Singapore's stack costs about $47,000 a month against N. Virginia's $104,000, yet still carries Mumbai's load at no more than 60%.
- The answer cache serves about 3,300 questions a second with no retrieval and no model call, which takes roughly a third off the token bill.
- Losing an availability zone causes no errors at peak. The busiest parts, plan limits and the query planner in N. Virginia, rise to 45%.
What it costs you
- Tokens are 98% of the roughly $21.9 million monthly bill. Everything else costs about $420,000, and more than 40% of that is the reranker GPUs.
- Edge usage records cross regions to reach a core's stream. Each crossing adds a round trip and is billed as transfer, about $360 a month here, small because each record is tiny; sending raw request logs the same way would cost far more.
- A page crawled in N. Virginia reaches the other regions only after the batcher and each loader, so the index is a little staler far from the crawler. The live search API covers the gap, and it is a dependency you don't control.
- Two kinds of region means two runbooks: a core going down also pauses the crawl or the usage rollups it hosts, and account writes from every region still cross to N. Virginia.
In the real world
- Perplexity's answers carry numbered citations that link to the pages they came from.
- Perplexity documents its crawler, PerplexityBot, and says site owners can control it with robots.txt.
- Perplexity sells search-grounded answers to developers through its Sonar API.
- Common Crawl publishes its crawl as WARC files, many pages per file, which is why archive writes are batched here.
- Amazon Bedrock's cross-region inference sends requests to other regions when one region's capacity is busy.
In the interview
- Do the retrieval arithmetic out loud: a search node takes a fixed number of queries a second, so partitions multiply the load per question and replica groups divide it.
- Lead with the cache hit ratio and the token bill. Every point of hit ratio is model quota and money you don't spend.
- Give regions jobs: put batch work and schedulers next to the data they read, keep edges serving-only, and size each edge for its own traffic plus its partner's.
- Separate coverage from freshness: the crawl gives coverage, a live search API gives freshness, and each fails in its own way.
Run it yourself
The playground opens this design with 102,005 requests a second already flowing. Press Break it, or change one part yourself, and watch which number goes first.
Read the walkthrough: Design a RAG Pipeline
Questions people ask
How does AI answer engine work at the system design level?
Route 53 sends each person to the nearest of five regions and fails over to a partner: N. Virginia and Oregon cover each other, Frankfurt falls back to N. Virginia, and Mumbai and Singapore cover each other. The two cores do the write and batch work. N. Virginia runs the crawler, the accounts writer and billing, next to the usage data billing reads. Frankfurt runs the usage rollups for Europe and Asia, so usage records from Mumbai and Singapore travel to Frankfurt, not across two oceans. Every region serves questions the same way, but sized to its load: N. Virginia has four search groups and 16 reranker hosts, Singapore two groups and seven hosts. A question first hits the answer cache; popular questions asked within the hour, about 35% of the total, stream a finished answer straight back. On a miss the answer server has the query planner rewrite the question, embeds it, and sends it through the search load balancer to one search group. The group's coordinator searches both partitions of the web index and a semantic index copy, then merges the hits. About a quarter of questions are about something recent, so the live web search API adds fresh results, and for one in ten the page fetcher pulls a page the crawler hasn't stored yet. GPU rerankers keep the best passages, the model writes an answer that cites them, and the thread and a usage record are written. In N. Virginia the crawler fetches 2,000 pages a second, archives them as WARC files, splits and embeds the passages, and a Flink job batches the index updates. Each region's Lambda loader reads that stream and writes the batches into its own indexes.
What breaks first in a AI answer engine design?
The four model quotas in N. Virginia, at about 3.2x. The suggest API there follows at about 3.8x, then the reranker GPUs in Frankfurt and Mumbai at about 4x. At 6x N. Virginia's quotas reject nearly half of its answers. The rerankers and search groups are past their limits too, because they don't autoscale, and the server tiers can't add instances as fast as the traffic climbs. Raising a quota takes a request to the provider, so plan ahead: more quotas, which cost nothing until used; cross-region inference to borrow another region's capacity; a higher cache hit ratio and fewer passages per prompt to cut tokens; then more search groups and GPU hosts before traffic reaches 3.5x.
What are the trade-offs of this AI answer engine architecture?
A failed region moves to its partner with no errors. With N. Virginia down, Oregon's busiest part, the suggest API, runs at 62% while it scales out; with Frankfurt down, N. Virginia's model quotas run at 52%. Edges cost what their traffic needs: Before tokens, Singapore's stack costs about $47,000 a month against N. Virginia's $104,000, yet still carries Mumbai's load at no more than 60%. The answer cache serves about 3,300 questions a second with no retrieval and no model call, which takes roughly a third off the token bill. Losing an availability zone causes no errors at peak. The busiest parts, plan limits and the query planner in N. Virginia, rise to 45%. Tokens are 98% of the roughly $21.9 million monthly bill. Everything else costs about $420,000, and more than 40% of that is the reranker GPUs. Edge usage records cross regions to reach a core's stream. Each crossing adds a round trip and is billed as transfer, about $360 a month here, small because each record is tiny; sending raw request logs the same way would cost far more. A page crawled in N. Virginia reaches the other regions only after the batcher and each loader, so the index is a little staler far from the crawler. The live search API covers the gap, and it is a dependency you don't control. Two kinds of region means two runbooks: a core going down also pauses the crawl or the usage rollups it hosts, and account writes from every region still cross to N. Virginia.
What do interviewers look for in a AI answer engine system design answer?
Do the retrieval arithmetic out loud: a search node takes a fixed number of queries a second, so partitions multiply the load per question and replica groups divide it. Lead with the cache hit ratio and the token bill. Every point of hit ratio is model quota and money you don't spend. Give regions jobs: put batch work and schedulers next to the data they read, keep edges serving-only, and size each edge for its own traffic plus its partner's. Separate coverage from freshness: the crawl gives coverage, a live search API gives freshness, and each fails in its own way.