Design a Chat Application with a Partitioned Cache
Company: Databricks
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Technical Screen
# Design a Chat Application with a Partitioned Cache
Design an end-to-end chat application that supports direct conversations and small group conversations. Cover client connectivity, message-send APIs, durable storage, delivery to online recipients, offline catch-up, ordering, and duplicate handling.
Spend additional time on caching: identify which data should be cached, compare process-local memory with a shared cache, choose partition keys, describe cache-miss behavior, and explain how cache invalidation or expiration preserves correctness.
### Clarifying Questions to Ask
- Is ordering required globally, per conversation, or only per sender?
- Are edits, deletes, read receipts, and attachments in scope?
- What acknowledgment means that a send succeeded?
- How long can clients be disconnected, and how do they resume?
- Which reads are latency-sensitive enough to justify caching?
### What a Strong Answer Covers
```premium-lock What a Strong Answer Covers
```
### Follow-up Questions
- How would you preserve order during a partition migration?
- When is an application-process cache preferable to a shared cache?
- How would you prevent a cache miss storm after a regional failure?
- What changes for very large broadcast channels?
Quick Answer: Design a direct and small-group chat application with durable messaging, online delivery, offline catch-up, ordering, and duplicate handling. Examine what belongs in local or shared caches, how keys are partitioned, and how misses, stale data, hot conversations, and outages affect correctness.