System design concepts
The ideas interviewers expect you to reach for, explained for the interview: how each one works, the trade-offs to say out loud, the mistakes that cost points, and the questions where it comes up.
Scaling out
- Load balancingLoad balancing distributes incoming connections or requests across multiple servers.
- Database shardingDatabase sharding splits a dataset across multiple database instances, with each shard owning a subset of the data.
- Consistent hashingConsistent hashing assigns keys to servers while limiting how many assignments change when servers join or leave.
- Database replicationDatabase replication keeps copies of the same data on multiple database nodes.
- Hot keys and hot partitionsA hot key receives more traffic than its serving node can handle; a hot partition concentrates too much work on one shard, even if individual keys are not unusually busy.
- Content delivery networks (CDN)A content delivery network (CDN) serves content through geographically distributed edge servers, often caching copies closer to users.
Storage and caching
- SQL vs NoSQLSQL vs NoSQL is a choice about data models, query capabilities, and operational guarantees, not simply tables versus documents.
- Caching strategiesCaching strategies define which data to keep near readers, how to populate it, and how to keep it fresh when the source changes.
- Write-ahead logA write-ahead log (WAL) records database changes durably before the corresponding data pages are written to storage.
- Bloom filtersA Bloom filter is a compact data structure that answers whether a key is definitely absent or might be present in a set.
Consistency and transactions
- CAP theoremThe CAP theorem says that during a network partition, a distributed data system cannot guarantee both linearizable consistency and availability for every request.
- Eventual consistencyEventual consistency means replicas or derived views may temporarily disagree, but converge if updates stop and propagation and conflict resolution complete.
- Idempotency and idempotency keysIdempotency means repeating the same operation has the same intended effect as performing it once.
- Two-phase commitTwo-phase commit (2PC) coordinates one atomic transaction across multiple databases or other transactional participants: everyone commits, or everyone aborts.
- Saga patternThe saga pattern coordinates a business operation across services using a sequence of local transactions.
- Transactional outbox patternThe transactional outbox pattern saves a business change and its outgoing event in the same database transaction, then publishes the event asynchronously.
- Distributed locks and fencing tokensA distributed lock coordinates exclusive access to a resource across processes, usually through a time-limited lease.
Messaging and events
- Message queuesA message queue holds work until a consumer is ready to process it, letting producers and workers run independently.
- Kafka vs RabbitMQKafka is usually a fit for retained event streams that multiple applications read independently; RabbitMQ queues are usually a fit for routing and distributing work to workers.
- Event sourcingEvent sourcing stores accepted changes as an ordered history of events, then derives current state from that history.
- CQRSCQRS stands for command query responsibility segregation: separating the model that handles changes from the model that answers reads.
- WebSockets, SSE and long pollingWebSockets, Server-Sent Events (SSE), and long polling let clients receive updates without repeatedly asking whether anything changed.
Location
Traffic and estimation
- Rate limiting algorithmsRate limiting algorithms decide whether to admit a request based on a configured traffic budget, such as requests per second per account.
- Back-of-the-envelope estimationBack-of-the-envelope estimation uses simple arithmetic and explicit assumptions to approximate a system's resource needs.