AI & Technical question
Design an in-memory cache system.
- Meta
- AI & Technical
- Hard
Practice this question out loud. An AI interviewer asks it, follows up like a real interviewer would, and scores your answer. Type or speak.
Start a mock interview on this question · Mock interview from a job description
What this question tests
Tests systems design fundamentals: eviction policy, consistency trade-offs, and how you'd measure cache effectiveness.
How to approach it
- Clarify use case and scale: a read-heavy lookup cache, confirm expected QPS and data size.
- Choose the data structure: a hash map for O(1) lookup, backed by a doubly linked list for LRU eviction.
- Decide the eviction policy: LRU by default, note LFU if access is skewed toward a few hot keys.
- Address consistency: a TTL plus write-through or write-invalidate so the cache doesn't serve stale data.
- Address scale: sharding across cache nodes with consistent hashing if one node isn't enough.
- Define measurement: cache hit rate and p99 latency, with a target hit rate stated as an assumption.
What a strong answer includes
- Picks a specific eviction policy and justifies it against the stated access pattern.
- Explicitly addresses cache invalidation and staleness, the hardest real part of cache design.
- Names hit rate and p99 latency as concrete success metrics, with an assumption-labeled target.
Common mistakes
- Describing 'a cache' with no eviction policy or invalidation strategy.
- Ignoring scale or sharding considerations entirely.
Likely follow-up questions
- How would you handle a hot key that gets disproportionate traffic?
- How would you keep the cache consistent across multiple nodes?
- What would you monitor to catch a falling hit rate early?
More ai & technical questions
- What happens when you enter a URL in your browser?Google · AI & Technical · Easy
- How would you implement Facebook Reactions?Meta · AI & Technical · Medium
- How would you design an experiment to evaluate a generative AI feature when outputs are non-deterministic?OpenAI · AI & Technical · Hard
- Design a RAG-based system to support content moderation at scale, specifically for identifying misinformation.Google · AI & Technical · Hard
- Describe what happens when you send a picture using a messaging app like WhatsApp or MessengerMeta · AI & Technical · Hard
- Design a simple load balancer for Google.com. What data structures would you use?Google · AI & Technical · Hard
More questions from Meta
Learn the skill behind it
Chapters of the AI PM course that teach what this question tests.
- Chapter 1: Foundations: the model and the decisions it forces on you
- Chapter 8: Evals: define good and make the number defensible
- Chapter 6: Agents and agentic architecture