CAP Theorem 和 NoSQL Reference
Reference 为 CAP 定理, NoSQL 数据 models, 和一致性-可用性 tradeoffs.
CAP Theorem
The CAP theorem states distributed systems can provide at most two of: Consistency (all reads see latest write), Availability (every request gets a response), Partition tolerance (system works despite network partitions). Since partitions can happen, the real choice is CP (consistency + partition tolerance) or AP (availability + partition tolerance). CP systems (HBase, MongoDB strong) reject requests during partitions. AP systems (Cassandra, DynamoDB) may return stale data. Modern systems offer tunable consistency levels within these categories.
- Consistency
- Latest write visible
- Availability
- Always responds
- Partition
- Network splits
CP systems AP systems unavoidable NoSQL Data Models
Key-value stores (Redis, DynamoDB) map keys to opaque values, simplest model. Document stores (MongoDB, CouchDB) store JSON-like documents with flexible schemas. Column-family (Cassandra, HBase) store data in column groups, efficient for wide/sparse data. Graph databases (Neo4j) store nodes and relationships, optimized for traversal. Time-series (InfluxDB, TimescaleDB) optimize for timestamped data. Search (Elasticsearch) optimize for full-text search. Each model fits specific use cases; polyglot persistence uses multiple stores.
- key-value
- Redis, DynamoDB
- document
- MongoDB, CouchDB
- graph
- Neo4j
simplest flexible schema relationship traversal