Problem Statement
A large enterprise (50,000 employees) needs an AI-powered knowledge assistant answering questions across 10 million internal documents (policies, technical docs, HR guides, training material), respecting document-level access controls, serving 200K+ queries/day.
Requirements Clarification (say this first in an interview)
- Scale: 50K users, 200K queries/day (~140 QPM avg, ~500 QPM peak), 10M documents
- Latency: P95 < 3 seconds for a streamed answer
- Access control: document-level ACLs must be enforced at retrieval time, not post-filtered
- Availability: 99.9% during business hours
- Compliance: audit trail of every query and every document retrieved
Architecture
USERS (50,000): Web App | Teams Bot | Slack Bot | Mobile | API
|
Front Door (CDN + WAF + Geo-routing)
|
API Management (rate limiting, auth, logging)
|
+-----------------------+-----------------------+
v v v
Chat Service RAG Service Admin Service
(session, history, (query, hybrid (upload, config,
streaming) search, generation) monitoring)
| | |
+-----------------------+-----------------------+
+-----------------------+-----------------------+
v v v
Azure OpenAI Azure AI Search Cosmos DB
(GPT-4o + embed) (vector + BM25 (sessions, history,
+ ACL filter) metadata)
|
+------------------------+
v v
Blob Storage Redis (semantic cache)
(source documents)
Key Design Decisions
| Decision | Choice | Rationale |
|---|---|---|
| LLM | Azure OpenAI GPT-4o (PTU) | Predictable latency, data stays in tenant, enterprise SLA |
| Embedding | text-embedding-3-large | Best quality/cost for enterprise document diversity |
| Vector store | Azure AI Search | Native hybrid search + integrated security trimming via ACL filters |
| Access control | Pre-filter at retrieval (OData filter on ACL field), never post-filter | Post-filtering leaks existence via embedding similarity scores |
| Cache | Redis semantic cache | 30-40% cost reduction on repeated/similar queries |
| Compute | Container Apps | Scale-to-zero off-peak; cost-efficient at variable QPS |
Access Control Implementation Pattern
Every chunk stored in the vector index carries acl_groups: string[] metadata (mapped from Entra ID security groups at ingestion time). Every query injects the requesting user’s group membership as a mandatory OData filter (acl_groups/any(g: search.in(g, 'HR', 'Finance'))) before the vector similarity search runs — this is non-negotiable: filtering after retrieval would let an unauthorized user infer the existence/content of a restricted document purely from which chunks got excluded.
Scalability & Cost Math
200K queries/day -> ~500 QPM peak
PTU: 100 PTU ~= 600 RPM capacity
With 35% semantic cache hit rate -> effective capacity ~= 920 RPM (84% headroom)
Storage: 10M docs x 20 chunks avg = 200M chunks
200M x 3072 dims x 4 bytes ~= 2.4 TB of vectors
-> Azure AI Search S3 tier, 2 partitions x 3 replicas
Monthly cost: Azure OpenAI ~$6,000 | AI Search ~$4,500 | Container Apps ~$800
Cosmos DB ~$400 | Redis/Blob/monitoring ~$800 -> ~$12,500/month (~$0.002/query)
Failure Modes Designed For
- LLM provider outage -> fallback to a secondary deployment/region, degrade to “search results only” mode if generation fails entirely.
- Retrieval returns nothing above confidence threshold -> respond “I don’t have information on this” rather than hallucinating; never silently pass an empty context to the LLM as if it were valid.
- Stale document versions -> superseded-by metadata field, event-driven re-indexing within 5 minutes of a document update (Blob change -> Event Grid -> re-embed -> upsert).