Storage & data
- ACID
- Atomicity, Consistency, Isolation, Durability — the four guarantees a "transactional" database promises. Chapter.
- BASE
- Basically Available, Soft-state, Eventually consistent — the trade NoSQL stores make in exchange for horizontal scale.
- MVCC
- Multi-Version Concurrency Control — keeping multiple row versions so readers don't block writers. Postgres + Oracle's secret sauce.
- B-tree
- Balanced tree of disk pages. The dominant index structure in OLTP databases. Optimised for reads. Chapter.
- LSM-tree
- Log-Structured Merge tree. Memtable + sorted SSTables, compacted in background. Write-heavy databases like Cassandra, RocksDB. Chapter.
- WAL
- Write-Ahead Log — sequential durability record written before in-place changes. Crash recovery foundation.
- Compaction
- Background process that merges LSM SSTables to reclaim space and bound read amplification. Tiered vs leveled is the choice.
- Bloom filter
- Tiny probabilistic structure that says "definitely not in this file" or "maybe in this file". Skips expensive disk reads.
- Tombstone
- A marker that says "this key was deleted". LSMs need them because they can't update in place.
- VACUUM
- Postgres's process for cleaning up dead MVCC tuples. Unattended VACUUM = bloat = pain.
Replication & partitioning
- Single-leader replication
- One node accepts writes, replicas follow. Simple consistency, single point of write failure. Chapter.
- Multi-leader
- Multiple nodes accept writes; conflicts must be resolved. Used in multi-region setups.
- Quorum (R + W > N)
- In Dynamo-style stores, ensuring enough overlap between read and write replicas guarantees a read sees the latest write.
- Consistent hashing
- Ring-based partitioning where adding/removing nodes only re-maps ~1/N of keys. Chapter.
- Virtual nodes
- Trick to even out load on a consistent hash ring — assign each physical node hundreds of positions instead of one.
- Hot key / hot partition
- One key (or partition) receiving disproportionate traffic. Symptom that breaks naive sharding.
- Resharding
- Adding/removing partitions without downtime. Vitess and Redis Cluster solve this with slot-based migration.
- Local vs global secondary index
- Local: each shard indexes its own data; reads fan out. Global: separate index sharded by index key; writes are 2-phase.
Consistency & transactions
- Strong consistency
- Every read returns the most recent write. Costly across regions.
- Eventual consistency
- Replicas converge over time; readers may see stale data briefly.
- Read-your-writes
- A user always sees their own most recent write, even if other users don't yet.
- Monotonic reads
- A user never sees data go backwards in time.
- 2PC (two-phase commit)
- Coordinator protocol for atomic commit across multiple participants. Slow, fragile under failure. Chapter.
- Saga
- Long-running business transaction expressed as local transactions + compensating actions. Used when 2PC is too expensive.
- Outbox pattern
- Write business state + event row in one DB transaction; a relay publishes events from the outbox. Fixes the dual-write problem. Chapter.
- CDC (Change Data Capture)
- Stream a database's transaction log as events. Debezium + Kafka is the dominant stack.
- Idempotency key
- Client-generated token attached to a request so retries are safe — server stores the response keyed by it. Stripe-style.
Caching
- Cache-aside
- App reads from cache; on miss, reads DB and fills cache. Most common pattern. Chapter.
- Write-through
- Writes go to cache first, which synchronously writes to DB. Simpler invalidation, slower writes.
- Write-back
- Writes to cache; DB updated asynchronously. Fastest writes, risk of loss.
- Refresh-ahead
- Cache proactively re-loads hot keys before TTL. Avoids stampede.
- Cache stampede
- When a hot key expires and 1000 clients miss simultaneously, all hitting the DB. Chapter.
- Singleflight
- Coalesce concurrent identical requests into one — only one rebuilds the cache entry.
- Negative caching
- Caching "this key doesn't exist" to prevent repeated DB lookups for missing data.
- TTL (time-to-live)
- How long a cache entry stays valid before being refreshed. Often tunable per key.
Reliability & failure handling
- Circuit breaker
- State machine that fails fast when a downstream is unhealthy. Recovers via a half-open probe.
- Bulkhead
- Partition resources (thread pools, connection pools) so a flood in one path can't drown the rest.
- Retry with jitter
- Exponential backoff with randomness. Prevents thundering-herd on retry storms.
- Hedged request
- Send the same request to two replicas; use whichever responds first. Tames p99 tail latency.
- Load shedding
- Drop low-priority traffic when overloaded — better than degraded service for everyone.
- Failover
- Promoting a replica to leader when the current leader fails. Risk: split-brain.
- Split-brain
- Two nodes both think they're the leader; accept conflicting writes. Requires fencing tokens or external coordinator.
Observability & SRE
- SLI
- Service Level Indicator — the measurement (e.g. "% of requests under 200ms").
- SLO
- Service Level Objective — the target (e.g. "99.9% under 200ms over 28 days").
- SLA
- Service Level Agreement — the contractual promise to customers (usually weaker than your internal SLO).
- Error budget
- How much unreliability you're allowed before slowing feature work. The social contract behind SLOs.
- Burn-rate alert
- Pages oncall when you're spending error budget too fast. Modern replacement for static threshold alerts.
- p50 / p95 / p99
- Percentile latency. p99 is what your worst-served users feel — the only one that matters for UX at scale.
- RED method
- Rate, Errors, Duration — the three signals every service should expose.
- USE method
- Utilization, Saturation, Errors — for resources (CPU, memory, disk, network).
- Cardinality
- Number of unique label/tag combinations on a metric. High cardinality = expensive observability bill.
Theory & protocols
- CAP theorem
- You can have any two of Consistency, Availability, Partition-tolerance — but under partition, you must choose between C and A.
- PACELC
- Extension of CAP: under Partition choose A/C, Else choose Latency/Consistency. More accurate framing for real systems.
- Little's Law
- L = λW. Throughput × latency = concurrent requests in flight. The most useful queueing equation.
- M/M/1 queue
- The "wait time blows up at 80% utilization" model. Why running near capacity hurts. Chapter.
- Tail latency amplification
- When 10 backends each have p99=100ms, the fan-out request's p99 is ~600ms — because at least one is slow.
- RUM conjecture
- Read, Update, Memory — pick at most two. You can't optimise for all three at once.
Design patterns (LLD)
- SOLID
- Single-responsibility, Open-closed, Liskov, Interface-segregation, Dependency-inversion. Chapter.
- Strategy
- Encapsulate an algorithm in a class; pick which to use at runtime. Replaces "if/else by type" chains.
- Observer (Pub-Sub)
- Subject notifies subscribed observers on state change. Loose coupling.
- Factory
- Creates objects without naming the concrete class. Useful when the type is runtime-determined.
- Composite
- Tree of objects where leaves and branches share an interface. Filesystems, menus.
- Decorator
- Add responsibilities to an object by wrapping it. Java I/O streams.
- State machine
- Object's behaviour changes based on internal state; transitions are explicit. ATM, elevator, order workflows. Chapter.
- Command
- Encapsulate a request as an object. Enables queueing, undo, logging.
- Chain of responsibility
- Pass a request through handlers; each decides whether to handle or forward. Logging filters, request middleware.