HLD-134·Caching & Edge
Easy · 500 ptsLLM Semantic Prompt Cache & Cost-Saving AI Gateway
Design an AI gateway caching tier that serves exact prompt-hash and high-similarity semantic hits in milliseconds to avoid redundant GPU inference calls across FAQ, support, and coding assistants.
Max p99
≤ 35 ms
Availability
≥ 99.5%
Budget
≤ $3,050
Functional Requirements
- FR-1POST /v1/prompt-cache/lookup — Computes normalized prompt hash + embedding lookup and returns cached completion when similarity >= threshold.
- FR-2PUT /v1/prompt-cache/entries/{prompt_hash} — Stores verified model completion, token counts, and tenant-scoped TTL.
- FR-3DELETE /v1/prompt-cache/tenants/{tenant_id} — Purges stale cached completions when a tenant updates system prompts or knowledge docs.
- FR-4Must coalesce identical concurrent cache misses so viral prompts do not trigger duplicate upstream model calls.
Workload Profile
Steady Assistant Traffic20,000 Cache Lookup Read RPS / 2,000 Completion Store Write RPS
Product Launch FAQ Spike56,000 Lookup Read RPS / 5,200 Write RPS
Active Working Set16 GB hot prompt hashes, quantized embeddings & completions
Traffic DistributionHigh Zipfian skew on common onboarding & docs queries
Consistency Model
Bounded eventual invalidation (< 5s) on tenant prompt-version bumps; strict tenant_id namespace isolation.
Relevant practice for
Solutions Locked
Sign in and either achieve AC or complete 3 official submissions on this question to inspect community diagrams and writeups.
Loading solutions...
Submission History (0)Select to replay
No submissions yet
Click Submit in the top bar to evaluate against all 7 judge cases and save each run here.
Click an item in Inventory above, or press B to add a component, double-click to name, C to connect.
Design Write-up
Write under ### Architecture for Diagram to take that up directly
Compulsory section · if not written yet, Diagram reads from the start of your write-up.
Architecture: required·FRs mentioned: 0/4·0 boxes · 0 edges
0 words