Part 5 of 8 · 3 min read
How far one node goes
Vertical scaling, read copies, and the point where data must be spread over machines.
Think of a bakery oven. A bigger oven makes more bread, up to the size of the kitchen. After that the bakery needs a second kitchen. The second kitchen costs far more effort than the bigger oven.
The book "System Design Interview" separates two ways to grow.
Vertical and horizontal scaling
Vertical scaling ("scale up") adds power to one machine: more CPU, more memory, faster disks. Horizontal scaling ("scale out") adds more machines to the pool.
Example: moving a database from 16 to 64 gigabytes of memory is vertical. Splitting its data over four servers is horizontal.
Vertical scaling is simple and works well while traffic is low. The book names its limits: there is a hard ceiling on the size of one machine, and a single machine has no failover or redundancy. If it goes down, the service goes down.
The usual steps for a relational database, in the order that effort grows:
- A bigger machine. More memory, so more data fits in memory. Cheap in effort.
- Indexes and better queries. Often a large gain at no cost (module 3).
- A cache in front for frequent reads (Level 3).
- Read copies. One main database takes the writes, and several copies take the reads. The book describes this as the main and replica pattern, which improves read speed and also gives redundancy. Level 4 covers it.
- Partitioning. The data is split over several machines (Level 4). This is the big step: joins and transactions across partitions become hard.
A worked example. A feature needs 4,000 writes and 36,000 reads per second (made up). One node handles 8,000 writes or 20,000 reads per second.
- Writes: 4,000 is half of the capacity. One node is enough for writes.
- Reads: 36,000 is above 20,000. One node is not enough for reads.
- With a cache hit ratio of 80 percent (page 4 of Level 1 defined hit ratio), reads reaching the database are 20 percent of 36,000 = 7,200, which is below 20,000.
- Or with 2 read copies, reads spread over 3 nodes at 12,000 each (36,000 ÷ 3), which is below 20,000.
So a relational store suffices here. No move to NoSQL is forced by the scale.
When is scale a real reason to leave the single relational node? When writes outgrow one machine. In the example, if writes were 40,000 per second, five times the node's capacity, reads and caching would not help. Then the data must be partitioned, and a store built for that, such as a wide-column or a partitioned key-value store, saves the work of doing it by hand.
The book "Designing Data-Intensive Applications" reminds the reader of both sides. Building for a scale that is not needed is wasted effort and may lock a design into inflexibility. But the right tool still matters, and relational databases are not the final word.
Read it as
Do the arithmetic first. If one node can do the job with a cache and read copies, the scale is not an argument against relational.
Check yourself:
- Which grows by adding machines, vertical or horizontal scaling?
- In the worked example, what brings 36,000 reads under the capacity of one node?