NoSQL Database
Umbrella for document, wide-column, and key-value stores optimized for horizontal scale over strict schema.
Why it exists
SQL databases scale vertically well but struggle horizontally at massive write throughput. NoSQL databases were built to trade some of SQL's guarantees (strict schema, cross-row transactions, complex JOINs) for horizontal scalability and specific workload optimizations. They come in four flavors: document (MongoDB), wide-column (Cassandra, DynamoDB), key-value (Redis-style but persistent), and graph (Neo4j) — each optimized for a different access pattern.
How it works
Document stores store JSON-like blobs with flexible schemas; queries navigate the document structure. Wide-column stores organize data as row keys → many columns, with each column optionally in a different family (physical disk layout); great for time-series and high-write workloads. Key-value stores are simple hashmaps at planetary scale. Underneath: LSM trees for write efficiency, consistent hashing for shard placement, and quorum reads/writes for tunable consistency.
Scaling characteristics
Wide-column and KV stores scale linearly by adding nodes; write throughput per node ~10K-100K ops/sec depending on payload. Read amplification (LSM compactions) can spike disk IOPS. Consistency is tunable: strong reads cost latency + coordination; eventual reads are cheap. Storage is often much cheaper per GB than SQL because there's no need for a page cache large enough to fit indexes.
When to use it
- High write throughput (>50K writes/sec sustained)
- Schemaless or rapidly-evolving data models
- Time-series, event ingestion, activity feeds
- Global distribution with eventual consistency being fine
- Simple lookup patterns (by key, by row-key range) — no ad-hoc JOINs needed
When NOT to use it
- Transactional workloads that need cross-row ACID (payments, inventory)
- Rich relational queries (JOINs across many tables)
- Small datasets where the operational cost of a distributed store isn't worth it
- Teams with no NoSQL experience — the learning curve on modeling and operations is real
Failure modes
- Hot partitions: a poorly-chosen partition key concentrates traffic on one node — throughput plateaus even though the cluster looks idle
- Silent data loss during quorum-write with insufficient replicas configured
- Read-after-write inconsistency confuses application logic — must design for eventual visibility
- LSM compaction storms cause read latency spikes; needs headroom in disk IOPS
- Schema migration is per-document (or per-row) — takes a long time on large datasets
Alternatives
- SQL DB with sharding (Vitess for MySQL, Citus for Postgres) — SQL semantics with horizontal write scale
- NewSQL (Spanner, CockroachDB) — SQL + horizontal scale, with the consistency trade-off
- Object storage (S3) for very large blob payloads — cheaper than any database
- Search engine (Elasticsearch) for full-text + faceted query patterns
Interview questions
- Choose a partition key for a chat app that stores 100K messages/sec. What's the risk?
- Explain quorum reads and writes. How would you tune R and W for a write-heavy vs read-heavy load?
- Your Cassandra cluster has one node at 90% disk usage while others are at 40%. Diagnosis?
- How do you do a schema evolution (add a new field) in DynamoDB?
- What are the trade-offs between DynamoDB provisioned and on-demand capacity?
- You need strong consistency on a write-then-read from the same client. How do you achieve it in Cassandra?
Systems that use this component
See how the real designs on this platform put nosql-db to work — concrete usage context per system.
Twitter/X timeline
Manhattan (Twitter's Cassandra fork) for tweets
Open systemCassandra for user timeline
Open systemNetflix
Cassandra + DynamoDB for viewing history
Open systemMnesia (Erlang's built-in) for chat metadata
Open systemRide Sharing
Cassandra for trip history and driver metadata
Open system2006, Google: Bigtable proves you can throw SQL away — if you know what you're doing
For 30 years, SQL was the only serious answer to "where do we store data?" Then Google hit a wall. In 2006, they had a petabyte-scale web index across thousands of machines, and no SQL DB could handle it. Their answer was Bigtable — a distributed, sparse, sorted map with millions of columns per row. It gave up joins, transactions, and SQL. It gained linear horizontal scale.
One year later, Amazon published the Dynamo paper (2007) — the shopping cart problem, solved by consistent hashing + vector clocks + eventual consistency. Facebook engineers read Bigtable + Dynamo, mashed them together, and released Cassandra (2008). 10gen released MongoDB (2009) — schemaless documents. LinkedIn released Voldemort. Twitter released FlockDB. Every big tech company had one.
"SQL is dead" declared the blogs of 2010. "NoSQL solves scale." The rebellion was on. Then the reality check: NoSQL trades away things you might actually need. Joins. Transactions. Consistency. Rich queries. Schema safety. Around 2014, the industry started adding SQL back — DynamoDB added transactions (2018), MongoDB added multi-document transactions (2018), Cassandra added lightweight transactions. Distributed SQL (Spanner, CockroachDB) proved you could have both. The rebellion morphed into a pluralism: pick the right tool for each shape.
The core insight: NoSQL is not one thing — it's four categories (KV, wide-column, document, graph) each optimized for a specific data shape and access pattern. Choose based on how you'll query, not on hype. If your data has strict relationships and you need joins, use SQL. If it's a huge stream of independent facts (user events, IoT), a wide-column NoSQL wins. If it's deeply nested and schema-flexible (product catalogs, user profiles), documents. If it's a network of relationships (fraud rings, social graphs), a graph DB.
Historical timeline
- 1979First KV store: dbmKen Thompson writes dbm for Unix. First key-value database. Simple hash-on-disk. Direct ancestor of every KV store.
- 1990Object databases emergeObjectStore, GemStone, and others try to escape relational rigidity. Never quite succeed. Set the ground for future rebellions.
- 2004Berkeley DB dominates embedded KVSleepycat's Berkeley DB (embedded KV) becomes the go-to for high-perf lookups. Later acquired by Oracle.
- 2006Google Bigtable paper"Bigtable: A Distributed Storage System for Structured Data." Sparse, sorted, distributed map. Powers Search, Maps, Gmail. Wide-column category is born.
- 2007Amazon Dynamo paper"Dynamo: Amazon's Highly Available Key-value Store." Consistent hashing + vector clocks + eventual consistency. The shopping cart problem, solved.
- 2008Cassandra open-sourced by FacebookAvinash Lakshman (co-author of Dynamo) fuses Bigtable + Dynamo at Facebook. Handles messages inbox. Apache project 2009.
- 2009MongoDB 1.010gen releases MongoDB — JSON documents, schemaless. "Web-scale" developer experience. Explodes in popularity.
- 2009Redis 1.0Salvatore Sanfilippo (antirez) releases Redis. In-memory KV store. Data structures beyond strings. Cache + queue + queue in one.
- 2012AWS DynamoDB launchesAmazon productizes Dynamo as a managed service. Predictable performance. Pay per capacity. Serverless NoSQL born.
- 2014The counter-revolution: distributed SQLCockroachDB starts. Spanner exits Google-internal. Distributed SQL proves NoSQL's scale story isn't exclusive to NoSQL.
- 2018NoSQL gets transactionsDynamoDB adds transactions. MongoDB adds multi-document transactions. Cassandra has LWT. NoSQL isn't as anti-ACID as it once claimed.
- 2020ScyllaDB maturesC++ Cassandra rewrite hits GA. 10x throughput on same hardware. Discord and others migrate massive workloads.
- 2023MongoDB 7.0 + Vector SearchMongoDB adds native vector indexes (Atlas). NoSQL becomes AI-native. Neo4j adds graph-based RAG patterns.
- 2024DuckDB reshapes analyticsOLAP in-process. Not classically NoSQL but redefines what a "non-relational" DB can look like at the analytics layer.
The four NoSQL data models — click to explore
NoSQL isn't one thing. Each of these four shapes is optimized for a specific data topology. Match the model to your access pattern:
Key-Value
{
"user:42": { "name": "Alice", "email": "a@x.com" },
"user:43": { "name": "Bob", ... },
"session:xyz": { "userId": 42, "exp": ... }
}GET user:42CAP theorem in practice — when the network splits
Brewer's CAP theorem says: in a distributed DB, when the network partitions, you can pick Consistency (reject writes to keep data correct) or Availability (accept writes at the cost of temporary inconsistency). You can't have both. Try it:
Tunable consistency — pick per-query, not per-database
Modern NoSQL (Cassandra, DynamoDB, MongoDB) lets you choose consistency per operation. Same DB, same table, different consistency levels for different queries. Compose freely:
ONE / eventual
QUORUM (majority)
ALL / strong
LOCAL_QUORUM (multi-DC)
SERIAL (LWT)
Partitioning: how NoSQL scales horizontally
Every NoSQL row lives on exactly one partition (with replicas). The partition key + hash function decides which node stores it. Type a key + change shard count:
user:42 = 1170328996 % 4 = 0Product comparison
| Product | Type | Model | Strength | Weakness |
|---|---|---|---|---|
| DynamoDB | KV / doc | Managed | Predictable p99 latency. Serverless. Auto-scale. Global tables. | Query patterns must be modeled up-front. Expensive at very high RCU/WCU. |
| Cassandra | Wide-column | OSS | Linear write scale. Multi-DC native. No masters. | JVM tuning nightmare. Repair pain. Steep learning curve. |
| ScyllaDB | Wide-column | OSS + Enterprise | C++ Cassandra rewrite — 10x throughput. Same API. | Younger ecosystem. Some Cassandra features lag. |
| MongoDB | Document | OSS + Atlas | Best DX for document data. Rich query language. Multi-doc transactions. | Historic reliability critiques (better now). Sharding UX complex. |
| HBase | Wide-column | OSS | Hadoop-native. Strong consistency (CP). Massive scale at Yahoo/Facebook. | Requires Hadoop + Zookeeper. Ops complexity. Declining momentum. |
| Redis | KV + data structs | OSS + Managed | Fastest KV. Streams, pub/sub, sorted sets — Swiss Army knife. | RAM-only for hot data. Persistence trade-offs. Single-writer per shard. |
| Riak KV | KV | OSS | Original Dynamo-style AP. Rock-solid replication. Was Basho's flagship. | Basho went bankrupt. Community small. Not recommended for new projects. |
| CouchDB | Document | OSS | MVCC + multi-master sync. Powers PouchDB (offline-first apps). | Older query experience. Less popular than MongoDB. |
| Neo4j | Graph | OSS + Enterprise | Best-in-class graph DB. Cypher query language. Rich tooling. | Enterprise features gated. Single-writer for OSS. Sharding via Fabric (Enterprise). |
| ArangoDB | Multi-model | OSS + Enterprise | Documents + graphs + KV in one engine. AQL is powerful. | Fewer users than specialized DBs. Not best-in-class at any one shape. |
| Bigtable | Wide-column | Managed (GCP) | Google's original wide-column. Ultra-low-latency at massive scale. | GCP-only. No transactions. Complex data modeling. |
| Firestore | Document | Managed (GCP) | Real-time subscriptions. Offline-first mobile. Perfect for Firebase apps. | Query limitations. Cost surprises. Vendor lock-in. |
How to choose: AWS + serverless → DynamoDB. Time-series or IoT → Cassandra/ScyllaDB. Nested docs → MongoDB. Real-time mobile → Firestore. Fraud/social graph → Neo4j. Ultra-low latency cache → Redis. Multi-DC without ops → managed (DynamoDB, Atlas, MongoDB Cloud).
12 real-world NoSQL deployments
DynamoDB serves the entire retail catalog
Amazon retail runs on DynamoDB for everything from the shopping cart to product catalog to Prime membership. >40M requests/sec at Prime Day peaks. Single-digit-millisecond p99. Each service owns its tables, uses single-table design for related entities. Zero operational overhead — no server admin.
Cassandra: 200 clusters, 30PB
Netflix runs 200+ Cassandra clusters serving user profiles, viewing history, personalization. ~30PB total. Multi-region active-active with LOCAL_QUORUM. Their custom Priam tool automates ops. When you press play, at least 5 Cassandra reads happen before the video starts.
ScyllaDB migration: from PB of Cassandra
Discord messages sit in ScyllaDB after migrating from Cassandra. Reason: 90% cost reduction + 10x throughput on same nodes. Their "How Discord Stores Trillions of Messages" blog is a NoSQL migration classic. Now serves 1T+ messages.
HBase for messages, Cassandra's birthplace
Facebook built Cassandra for the messages inbox in 2008, then replaced it with HBase because they wanted stronger consistency. Both invented at Facebook! Today HBase serves messages, insights. Cassandra thrives outside Facebook.
Cassandra for feed ranking data
Instagram uses Cassandra for user activity, feed candidate stores. Every action (like, follow, view) writes to Cassandra. The ranking service reads from it to build personalized feeds. Handles 10M writes/sec at peak.
Custom NoSQL (Schemaless) on MySQL
Uber's Schemaless is a NoSQL layer built on MySQL. Provides KV semantics with schema-less values. Handles trip data at massive scale. Combines MySQL's ops maturity with NoSQL's schema flexibility.
Vitess-backed MySQL + custom NoSQL
Slack runs channels + messages on Vitess (MySQL) but uses custom NoSQL sharding for very hot workloads. Learned from many years of Cassandra pain. Their conclusion: SQL when you can, NoSQL when you must.
Cassandra + PostgreSQL hybrid
Spotify stores user library and taste graph in Cassandra, while playlists, users, artists live in PostgreSQL. Cassandra for high-write user-events; PG for entities. Now migrating some to their own Bigtable-based store.
Bigtable for the vanishing-message model
Snapchat runs on Google Bigtable. Every snap = a row keyed by (user_id, timestamp). Trivial TTL for auto-deletion. Petabyte scale, sub-millisecond reads. Native GCP integration means minimal ops.
Espresso: document NoSQL for member data
LinkedIn built Espresso — a MySQL-based document store — for member profiles, activity, messaging. Custom because MongoDB wasn't reliable at their scale in 2013. Powers ~1B users' profile lookups.
Neo4j for real estate graph
Trulia uses Neo4j to model relationships between properties, neighborhoods, schools, agents. Complex "find homes near good schools in walkable areas" queries — traversals that would kill a relational join, run in ms on graph.
Cassandra + MongoDB for different shapes
eBay runs Cassandra for the seller catalog (high-write, time-partitioned) and MongoDB for user preferences (nested, schema-flexible). One team, two DBs, right tool per shape. A common enterprise pattern.
Key takeaways
- 1NoSQL isn't one thing — it's four categories (KV, wide-column, document, graph). Match model to access pattern.
- 2The Bigtable + Dynamo papers (2006-2007) started the movement. Every modern NoSQL is a descendant of one or both.
- 3CAP theorem in practice: during partition, choose CP (reject on minority) or AP (accept both, reconcile). No fifth option.
- 4Tunable consistency is your friend — 90% QUORUM, 10% ONE for analytics. Pick per-query, not per-database.
- 5Partition keys define scale. Model access patterns first, choose partition key to distribute load and enable your queries.
- 6The 2018 wave of transactions (DynamoDB, MongoDB) mostly closed the correctness gap. NoSQL isn't anti-ACID anymore.
- 7For most workloads, start with SQL. Reach for NoSQL when you have specific shape/scale needs SQL can't handle.
- 8Managed NoSQL (DynamoDB, Atlas, Firestore) removes 80% of the operational pain. Self-hosted Cassandra is a full-time job.
References & further reading
- • Chang, F. et al. (2006). "Bigtable: A Distributed Storage System for Structured Data." OSDI. The paper that launched wide-column.
- • DeCandia, G. et al. (2007). "Dynamo: Amazon's Highly Available Key-value Store." SOSP. The paper that launched AP NoSQL.
- • Brewer, E. (2000). "Towards Robust Distributed Systems." The CAP theorem talk. Read alongside Gilbert & Lynch (2002) formal proof.
- • Vogels, W. (2009). "Eventually Consistent." CACM. Amazon CTO's explanation of eventual consistency in production.
- • Kleppmann, M. (2017). Designing Data-Intensive Applications. Chapters 5-6 on replication + partitioning are canonical.
- • Sivasubramanian, S. et al. (2017). "Amazon Aurora" SIGMOD paper — for the counter-narrative.
- • Lakshman, A. & Malik, P. (2010). "Cassandra: A Decentralized Structured Storage System." The Cassandra paper.
- • MongoDB blog: "MongoDB's New Aggregation Framework" and the multi-doc transactions announcement.
- • Discord Engineering: "How Discord Stores Trillions of Messages" — ScyllaDB migration classic.
- • Netflix Tech Blog: "Cassandra Backups and Restores at Netflix" — operational reality of Cassandra at scale.
- • Uber Engineering: "Schemaless: Uber Engineering's Trip Datastore." Custom NoSQL on MySQL.