Lessons › From one user to millions
SQL that grows by itself
A bank-like app: 30,000 req/s and 30% are writes, 9,000 a second. Your orders need joins and real transactions, so NoSQL is out, and nobody wants to run sixteen shards by hand.
Play this levelFree with an account. It runs in your browser: build the design, press Run, and watch what breaks.
The lesson
Sharding works, but you own it: rebalancing, cross-shard joins, and a fresh plan each time you grow. NoSQL removes the work and gives up joins.
Distributed SQL such as Spanner or CockroachDB aims to keep both. Data splits across nodes by itself, and adding a node adds write capacity.
Each write waits for a majority of copies to agree, so writes are slower. Google's estimate is up to 22,500 reads or 3,500 writes a second per node, and they say not to size from it. Load test first.
What you have to achieve
30,000 requests a second at the busiest hour, 30% of them writes.
- No broken or illegal connections
- Use a Distributed SQL with at least 3 instances
- No component is overloaded
- Fewer than 0.1% of requests fail
- p99 response time under 200 ms
- Machines cost at most $6,000 / month
What you learn
You kept joins and transactions and dropped the shards. The price is a slower write and a bigger bill per node, and it's why plenty of big companies still run plain Postgres for as long as they can.
Check yourself
What does distributed SQL keep that NoSQL gives up?
- Low prices
- Fast writes
- Joins and real transactions
Show the answer
Joins and real transactions. It splits data across nodes by itself and still supports joins and transactions.
Why are its writes slower?
- Each write waits for a majority of copies to agree
- It runs on smaller machines
- It writes to disk twice
Show the answer
Each write waits for a majority of copies to agree. Agreement across copies keeps data safe and consistent, and it costs time on every write.