Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Appendix D: Network and System Design Quick Reference

D.1 Distributed Consistency Levels

LevelGuaranteesUse Case
LinearizabilityAll operations appear atomicFinancial transactions
SequentialOperations appear in orderInventory management
CausalCausally related operations in orderSocial feeds
EventualConvergence without guaranteesCaching, logging
Read-your-writesOwn writes visible immediatelyUser sessions

D.2 CAP and PACELC

CAP says that when a network partition occurs, a distributed system must sacrifice either consistency or availability. Partitions are not optional (they are a fact of networks)so the real choice is only ever between CP and AP:

ChoiceDuring a partitionExample
CPReject requests rather than serve stale or divergent dataZooKeeper, etcd, HBase, Spanner
APKeep serving; reconcile afterwardsCassandra, DynamoDB, Riak

“CA” is often listed as a third option with a single-node RDBMS as the example. That is a category error: a non-distributed system has no partitions to tolerate, so CAP does not classify it. There is no CA distributed system.

PACELC is the more useful formulation, because it also describes the normal case when nothing is broken: if Partition, then A or C; Else, then L (latency) or C:

SystemPartition behaviorNormal behaviorReads as
SpannerCPConsistency over latencyPC/EC
DynamoDBAPLatency over consistencyPA/EL
CassandraAPLatency over consistency (tunable)PA/EL
MongoDBCPConsistency over latencyPC/EC

The Else half is where most systems actually spend their time, and it is the half CAP says nothing about, which is why “we chose AP” explains far less about a system than people usually intend by it.

D.3 Caching Patterns

PatternDescriptionConsistency
Cache-asideApplication manages cacheStale reads possible
Read-throughCache fetches on missStale reads possible
Write-throughSynchronous cache + storeStrong
Write-backAsync cache to storeWeak until sync

D.4 Load Balancing Algorithms

AlgorithmState RequiredHot Spot RiskSession Affinity
Round RobinNoneYes (variable load)None
Least ConnectionsPer-node countLowerNone
IP HashNoneYes (skewed)Yes
Consistent HashRing stateLowestPartial
WeightedWeightsLowerNone

D.5 Data Structure → System Mapping

Data StructureSystem Application
Hash tableKey-value stores (Redis, Memcached)
B-treeRelational databases (PostgreSQL, InnoDB)
LSM treeTime-series, write-heavy (RocksDB, Cassandra)
TrieRouting tables, prefix matching
GraphSocial networks, recommendation systems
LogMessage queues (Kafka), event sourcing
Bloom filterCache, membership testing (web, CDNs)
Consistent hashDistributed caching, load balancing

Every system in Volume V reduces to the building blocks in Volumes I–IV. That is the argument the book makes, and this table is the short version of it.

Everything Data Structures: by Ngoc Anh Khoa Doan. Prose is CC BY 4.0; code is MIT.