Summary#
A handful of approximate numbers lets you judge any design in seconds:
- Latency: RAM is about 100 ns; an NVMe SSD random read is about 100 µs, roughly 1,000x slower. A round trip inside a data center is about 0.5 ms, and one across a continent or ocean is 60-200 ms.
- Hardware: one modern server can have 100+ cores, terabytes of RAM, tens of terabytes of NVMe at several GB/s per drive, and a 25-100 Gbps network card.
- Component capacity: one stateless app server handles about 1,000-10,000 requests per second, one SQL primary about 5,000-20,000 write transactions per second, and one Redis node about 100,000+ operations per second. A Kafka broker moves hundreds of MB/s, and a tuned WebSocket host holds about 100,000+ connections.
- Availability: 99.9% allows about 43.8 minutes of downtime a month; 99.99% allows about 4.4 minutes.
The most important lesson is that one machine is enough far more often than people think. Many systems that "need" sharding or a cluster would fit on one large database server with replicas. Treat every number as an order of magnitude and benchmark your own workload before committing.
Why It Exists#
Back-of-the-Envelope Estimation needs reference points:
- You cannot decide whether 30,000 QPS needs sharding unless you know roughly what one database can do.
- You cannot tell whether a 200 ms latency target is realistic unless you know what a cross-region call costs.
- You cannot size a cache without knowing how much RAM a node has and how many operations it serves.
These numbers also prevent the most common modern mistake: using outdated limits. Textbooks and blog posts from ten years ago often assume spinning disks, 1 Gbps networks and servers with tens of gigabytes of RAM. Today's servers are vastly bigger:
- General-purpose cloud instances reach 128+ vCPUs and 512 GiB of RAM; AWS's m6i.32xlarge, for example, has 128 vCPUs and 512 GiB.
- Memory-optimised instances reach several terabytes of RAM, and AWS's largest high-memory instances offer 24 TB.
- Storage-optimised instances carry tens of terabytes of local NVMe; AWS's i3en.24xlarge has 60 TB.
A candidate or engineer who says "we must shard at 100 GB" is working from limits that stopped being true long ago. Knowing current numbers is one of the clearest signs of hands-on experience.
How It Works#
All values are approximate and vary by hardware generation, configuration and workload. Use them to judge orders of magnitude. This handbook uses these same values on every page (decision D17), so the estimates across pages agree.
Latency numbers#
The table below updates the classic list that Jeff Dean popularised in his talks at Google around 2009. Some rows have barely changed (memory, data center round trips, the speed of light). Others have improved by an order of magnitude (SSDs, networks).
| Operation | Approx. latency | Relative feel |
|---|---|---|
| L1 CPU cache reference | ~1 ns | Instant |
| Branch mispredict | ~3-5 ns | |
| L2 cache reference | ~4-7 ns | |
| Uncontended mutex lock/unlock | ~15-25 ns | |
| Main memory (RAM) reference | ~100 ns | ~100x L1 |
| Compress 1 KB (fast codec such as LZ4 or Snappy) | ~1-3 µs | |
| Send 1 KB over a 10 Gbps link (serialisation only) | ~1 µs | |
| Read 1 MB sequentially from RAM | ~50-100 µs (one core); faster with many cores | |
| NVMe SSD random read (4 KB) | ~100 µs (20-150 µs) | ~1,000x a RAM reference |
| Read 1 MB sequentially from NVMe SSD | ~0.2-0.5 ms | |
| Round trip within one data center (same zone) | ~0.5 ms (often 0.1-0.5 ms) | |
| Redis GET over the network (same zone) | ~0.5-1 ms | Mostly network |
| Round trip between availability zones | ~1-2 ms | |
| Network block storage (EBS-style) I/O | ~0.5-2 ms | |
| Indexed database read (data in cache) | ~1-5 ms end to end | |
| HDD seek | ~5-10 ms | Avoid on hot paths |
| Object storage first byte (S3-style GET) | ~10-100 ms | |
| Round trip US East to US West | ~60-70 ms | |
| Round trip US to Europe | ~80-100 ms | |
| Round trip US to Asia or Australia | ~150-200 ms | |
| TCP + TLS 1.3 connection setup, cross-continent | ~2 round trips, so ~200-300 ms | Reuse connections |
Three lessons stand out:
- Memory is far faster than disk, so hot data belongs in RAM.
- Network round trips within a data center are cheap, but across continents they dominate everything. A single synchronous cross-region call costs more than a hundred local database queries.
- Sequential access beats random access on every medium, which is why logs, LSM trees and columnar formats are built around sequential writes and scans.
One way to feel the scale is to multiply everything by a billion, so that 1 ns becomes 1 second:
- An L1 cache hit is 1 second.
- A RAM reference is about 1.5 minutes.
- An SSD random read is about a day.
- A same-zone round trip is about 6 days.
- A US-Europe round trip is about 3 years.
Seen that way, a "quick" cross-region call is an eternity for a CPU.
How the classic list has aged#
The famous list of latency numbers was assembled around 2009-2012, and versions of it still circulate unchanged. Comparing it with today's hardware shows which intuitions still hold and which now mislead.
| Operation | Classic list (around 2010) | Today (typical) | What changed |
|---|---|---|---|
| Main memory reference | 100 ns | ~80-120 ns | Almost nothing; DRAM latency is stuck |
| Compress 1 KB with a fast codec | 10 µs (Snappy, then called Zippy) | ~1-3 µs (LZ4, Snappy, Zstd at fast levels) | Faster codecs and CPUs |
| Send 1 KB over the network | 10 µs on 1 Gbps | ~1 µs on 10 Gbps, ~0.1 µs on 100 Gbps | Networks are 10-100x faster |
| Random 4 KB read from SSD | 150 µs (SATA-era SSD) | ~20-100 µs (NVMe) | Several times faster, far more IOPS |
| Read 1 MB sequentially from SSD | 1 ms (about 1 GB/s) | ~0.1-0.2 ms (5-7 GB/s for PCIe 4.0) | 5-10x faster |
| Read 1 MB sequentially from memory | 250 µs | ~50-100 µs per core | Faster, and many cores read in parallel |
| Round trip within a data center | 500 µs | ~100-500 µs | Similar; software stacks dominate |
| Read 1 MB sequentially from HDD | 30 ms (about 30 MB/s) | ~4-5 ms (about 200-250 MB/s) | The old figure was pessimistic even then; seeks are still ~5-10 ms |
| Read 1 MB over a 1 Gbps network | 10 ms | ~0.1-0.4 ms on 25-100 Gbps | 1 Gbps is now a laptop link, not a server link |
| Packet California to the Netherlands and back | 150 ms | ~140-150 ms | Physics: unchanged |
Three conclusions follow:
- Anything bounded by physics or DRAM has not moved. Memory latency and long-distance round trips are the same as in 2010, so locality and geography still dominate design.
- Storage and networks became much faster. Advice like "avoid the network, it is slower than disk" or "a disk read costs 10 ms" now produces bad designs. An NVMe read and a same-zone network round trip are both about a tenth of a millisecond.
- The handy rates from the classic list need updating. They were: HDD sequential at 30 MB/s, a 1 Gbps link at 100 MB/s, SSD at 1 GB/s, memory at 4 GB/s, about 2,000 round trips a second inside a data center and 6-7 worldwide. Today: an HDD streams about 200 MB/s, a 25 Gbps link about 3 GB/s, NVMe 5-14 GB/s, and a server's memory system 100+ GB/s in aggregate. The round-trip counts are unchanged, because they come from distance.
Throughput numbers#
Latency tells you how long one operation takes. Throughput tells you how much data or how many operations per second a resource can sustain.
| Resource | Approx. sustained throughput |
|---|---|
| RAM bandwidth, one core | ~10-20 GB/s |
| RAM bandwidth, whole modern server socket (many channels) | ~100-300+ GB/s |
| NVMe SSD (PCIe 4.0), sequential | ~5-7 GB/s per drive |
| NVMe SSD (PCIe 5.0), sequential | ~10-14 GB/s per drive |
| NVMe SSD random IOPS (4 KB) | ~500k-1M+ per drive at high queue depth |
| Cloud network block volume (e.g. general-purpose SSD) | ~thousands to tens of thousands of IOPS; ~hundreds of MB/s to a few GB/s, by tier |
| HDD sequential | ~150-250 MB/s; ~100-200 random IOPS |
| 10 Gbps NIC | ~1.25 GB/s |
| 25 Gbps NIC | ~3 GB/s |
| 100 Gbps NIC | ~12.5 GB/s |
| Round trips per second, same data center, one sequential client | ~2,000-10,000 |
| Round trips per second, worldwide, one sequential client | ~5-15 |
The last two rows are worth memorising. A loop that makes one synchronous call at a time can do only a few thousand calls per second inside a data center, and only a handful across the world. Throughput then has to come from parallelism (many calls in flight) and batching (more work per call), not from a faster loop.
What one CPU core does per second#
App-server capacity ultimately comes down to how much CPU work each request needs. These rough per-core figures, for one modern server core using optimised libraries, help you see where the CPU goes:
| Work | Approx. per core | Design consequence |
|---|---|---|
| Simple function call, hash-map lookup | ~10-100 million per second | Pure in-memory logic is almost never the bottleneck |
| System call (simple) | ~0.1-1 µs each | Batch small reads and writes |
| Thread context switch | ~1-5 µs, plus lost cache warmth | Thousands of busy threads waste CPU; use pools or async I/O |
| JSON parse or serialise | ~0.2-1 GB/s with fast libraries (several GB/s with SIMD parsers) | A 100 KB response at 10,000 RPS is 1 GB/s of JSON: one or more cores just for encoding |
| Protobuf encode or decode | Often several times faster than JSON, with smaller payloads | Good for high-volume internal calls |
| AES-GCM encryption (with hardware AES) | ~several GB/s | Encrypting traffic in transit costs little CPU |
| TLS handshake, full (ECDHE + RSA-2048 signature) | ~1,000-2,000 per second | New connections are expensive: reuse connections, resume sessions |
| TLS handshake with an ECDSA P-256 certificate | ~10,000+ per second | ECDSA certificates cut handshake CPU sharply |
| SHA-256 (with CPU SHA extensions) | ~1-2 GB/s | Content hashing for deduplication is cheap |
| gzip at default level | ~20-100 MB/s compressing | Expensive for high-volume responses; precompress static files |
| Zstd (fast levels) / LZ4 | ~300-800 MB/s / ~500 MB/s-1 GB/s | Better for logs, Kafka batches and storage |
| bcrypt at cost 10-12 | ~5-20 hashes per second (about 50-250 ms each) | Deliberately slow: login endpoints need rate limits and their own capacity plan |
| Regex on text | Highly variable; pathological patterns can take seconds | Bound input sizes and avoid back-tracking patterns on user input |
A worked example. An API serves 20,000 requests per second, each returning 20 KB of JSON over TLS on reused connections.
- JSON encoding is 20,000 × 20 KB = 400 MB/s, about 1 core at 0.5 GB/s.
- Encryption at a few GB/s per core is a fraction of a core.
- If clients did not reuse connections, 20,000 full RSA handshakes per second would need 10-20 cores on their own.
The difference between connection reuse and new connections per request is larger than the whole cost of the application logic.
Password hashing is the opposite case. It is slow on purpose, so that stolen hashes are expensive to crack. A login service handling 1,000 logins per second at about 100 ms of CPU each needs about 100 cores for hashing alone. Size it separately, protect it with rate limiting, and never put password hashing on a path that bots can call freely.
Modern hardware limits#
| Resource | Typical cloud server | High end (2020s) |
|---|---|---|
| CPU cores / vCPUs | 16-64 | 128-192+ vCPUs per instance |
| RAM | 64-512 GB | Several TB (memory-optimised instances up to ~24 TB) |
| Local NVMe capacity | 1-8 TB | Tens of TB per instance (e.g. 60 TB) |
| NVMe throughput | ~2-3 GB/s per drive | ~7-14 GB/s per drive; tens of GB/s with several drives |
| NVMe random IOPS | ~100k-500k | ~1M+ per drive |
| HDD-heavy storage instances | - | Hundreds of TB per instance |
| Network | 10-25 Gbps | 100-200 Gbps (some instances more) |
| Object storage | Effectively unlimited | Petabytes are routine |
What this means in practice:
- RAM: a working set of hundreds of gigabytes fits in one server's memory. A cache or an in-memory index of 200 GB is a single-machine problem.
- Storage: a database of a few terabytes fits comfortably on one server's local or attached SSDs. The practical limits on a single database are usually write throughput, backup and restore time, schema-change time and blast radius, not raw capacity.
- Network: a single instance can push several GB/s. Cross-zone bandwidth within a region is limited mainly by instance network capacity. Cross-zone and cross-region transfer is often billed per GB, which matters more than the speed.
Per-component capacity#
These are rough figures for one node with reasonable tuning and simple operations. Complex queries, large values, heavy contention or poor indexing can cut them by 10x or more.
| Component | Approx. capacity per node | Notes |
|---|---|---|
| Stateless app server | ~1,000-10,000 RPS | Depends heavily on work per request and language runtime |
| PostgreSQL / MySQL primary | ~5,000-20,000 write TPS; 10k-100k+ simple reads/s | Reads scale with replicas and cache hit ratio |
| SQL database size, one node | Comfortable to a few TB; tens of TB possible | Backups, restores and migrations get slow first |
| SQL connections | Hundreds to a few thousand | Use a pooler (PgBouncer, RDS Proxy) |
| Redis | ~100,000-200,000 simple ops/s per instance; more with pipelining | Commands run on one main thread; sub-ms latency |
| Redis memory per node | Tens to hundreds of GB | Keep headroom for forks during snapshots |
| Memcached | Hundreds of thousands of ops/s or more | Multi-threaded; scales with cores |
| Kafka broker | ~Hundreds of MB/s up to ~1 GB/s; ~100k-1M small msgs/s | Scales by partitions and brokers; ms-level latency |
| Kafka partition | ~Up to tens of MB/s | Parallelism is capped by partition count |
| Cassandra / ScyllaDB node | ~Thousands to tens of thousands of writes/s (ScyllaDB higher) | Scale by adding nodes and spreading keys |
| DynamoDB partition | 1,000 write units and 3,000 read units per second (AWS documented limits) | Avoid hot partition keys |
| Amazon S3 per prefix | 3,500 PUT/POST/DELETE and 5,500 GET/HEAD per second (AWS documented) | Spread keys across prefixes for more |
| Elasticsearch / OpenSearch node | ~Hundreds to thousands of searches/s | Depends on query and index size |
| WebSocket server | ~100,000 concurrent connections (1M+ with heavy tuning) | Memory per connection and message rate are the limits |
| Load balancer (managed) | Scales to very high RPS | May need pre-warming for sudden huge spikes |
Here is how to apply them component by component.
Caching. One Redis node serves around 100,000 simple operations per second with sub-millisecond latency, and holds tens to hundreds of gigabytes. So:
- A 50 GB hot set at 80,000 reads per second is a single primary (plus a replica for availability).
- A 500 GB hot set at 1 million reads per second needs a cluster of perhaps 10-20 shards.
- Big values change the maths. A 100 KB value at 50,000 reads per second is 5 GB/s, more than many NICs can carry.
Databases. A well-tuned PostgreSQL or MySQL primary on a large instance handles:
- thousands to tens of thousands of simple write transactions per second;
- many more reads, especially with replicas;
- several terabytes of data.
Before sharding, check the alternatives: indexes, query fixes, connection pooling, a cache, read replicas, a larger instance, and partitioned tables. Sharding is justified when sustained writes or data size clearly exceed one primary with headroom, or when the blast radius of one database is unacceptable.
Application servers. Simple stateless services in efficient runtimes (Go, Java, Rust, Node.js for I/O-bound work) often handle thousands of requests per second per instance. Heavy rendering, encryption or serialisation of large payloads lowers this. Memory is usually 1-8 GB per instance for typical services. The usual scaling limit is not the app tier itself, because you can add instances, but what it calls: database connections, downstream rate limits, and caches.
Message queues and logs. A Kafka cluster with a few brokers easily moves hundreds of thousands to millions of small messages per second, with end-to-end latency typically in the low milliseconds to tens of milliseconds. Each partition is consumed by one consumer per group at a time, so partition count, not broker capacity, often limits consumer parallelism. Managed queues such as SQS scale throughput nearly without limit for standard queues, while FIFO queues have lower per-group throughput.
Real-time connections. Holding a WebSocket is cheap in CPU and costs memory: tens of KB per connection, depending on buffers and per-connection state. 100,000 connections at 20 KB each is 2 GB of RAM. The harder limits are the message rate, broadcast fan-out and the kernel's file descriptor and port settings.
See Distributed Caching, Partitioning and Sharding and Pub/Sub and Event Streaming.
Sizing a Kafka topic: brokers, partitions and retention#
Kafka comes up in many designs, and the sizing questions are always the same. Ask them in this order:
- Do we need to scale it at all? As a very rough rule, a well-provisioned broker stores around 1 TB and handles up to about 1 million small messages per second; real figures depend on message size, replication and hardware. If the whole workload is below that, the conversation is about fault tolerance (three brokers, replication factor 3), not scaling.
- How big are the messages? Keep them small, well under the default limit of about 1 MB. Large payloads go to object storage, and the message carries a pointer.
- How many partitions? A partition is the unit of parallelism: within a consumer group, each partition is read by one consumer at a time. A common starting formula is: partitions ≥ max(target throughput ÷ per-partition producer throughput, target throughput ÷ per-partition consumer throughput). If consumers each handle 5 MB/s and the topic needs 100 MB/s, you need at least 20 partitions. Round up for growth, because adding partitions later changes which partition each key maps to, and so breaks per-key ordering during the change.
- How much storage? Retention (7 days by default) × ingest rate × replication factor. 100 MB/s for 7 days at replication factor 3 is about 180 TB, which means many brokers or tiered storage that moves older segments to object storage.
- Is any key hot? Kafka picks a partition by hashing the key (murmur2 by default) modulo the partition count. If one key, such as one viral ad, carries a large share of traffic, its partition becomes the bottleneck. There are four options:
- send without a key, so the producer spreads messages evenly, giving up per-key ordering;
- salt the key with a small random suffix and merge in the consumer;
- use a compound key such as ad ID plus region;
- apply back pressure, slowing producers when partition lag grows.
Hard limits that shape designs#
Besides speed, many systems have hard limits: sizes and rates that cannot be exceeded, however much hardware you add. These often decide a design more than raw speed, because hitting one means a redesign. Values below are documented defaults or limits at the time of writing; check current documentation before relying on them.
| System | Limit | Design consequence |
|---|---|---|
| DynamoDB | Item size 400 KB; one partition serves about 3,000 read units and 1,000 write units per second | Store large attributes in S3 with a pointer; spread hot keys |
| DynamoDB | A transaction covers up to 100 items | Large multi-item updates need sagas or batching |
| Amazon S3 | Objects up to 5 TB; a single PUT up to 5 GB; about 3,500 writes and 5,500 reads per second per prefix | Multipart upload for large files; spread keys across prefixes |
| Kafka | Default maximum message size about 1 MB (configurable) | Put payloads in object storage and send a pointer |
| Amazon SQS | Small maximum message size (256 KB for many years, raised to 1 MiB in 2025); messages retained up to 14 days | Same pointer pattern; not a long-term store |
| Redis | A single string value up to 512 MB; commands on one key are served by one shard | Big values block the single thread; one hot key cannot exceed one node |
| PostgreSQL | Default max_connections of 100; each connection is a separate process using megabytes of memory | Connection poolers in front of large app fleets |
| MySQL | Default max_connections of 151 | Same: pool connections |
| AWS Lambda | Maximum run time 15 minutes; synchronous request and response payloads up to 6 MB | Long jobs go to containers or step workflows; big payloads go to S3 |
| Linux TCP | Default ephemeral port range of about 28,000 ports per source IP to one destination IP and port | Proxies opening many outbound connections need wider ranges, more IPs or connection reuse |
| Single TCP flow across an ocean | Limited by window size ÷ RTT (for example 64 KB ÷ 150 ms ≈ 3.5 Mbps without window scaling) | Window scaling, parallel streams, BBR |
The pointer pattern comes up so often that it deserves a name. Queues, logs and key-value stores are built for many small messages. When the payload is large, such as a video to transcode, a large document or a model file, store it in object storage and send only its location and metadata, a few hundred bytes. For a video upload pipeline, putting the video itself in Kafka would make every broker, replica and consumer copy gigabytes. Putting s3://bucket/videos/123.mp4 in Kafka makes the message tiny, and workers fetch the video directly from storage.
Sharding is usually built in#
You will rarely implement sharding by hand. Most modern data stores partition data automatically once you choose a key, though they do it differently, and the differences explain their limits:
| Store | How it distributes data | What you choose | What to watch |
|---|---|---|---|
| Cassandra | A partitioner (Murmur3 by default) hashes the partition key onto a token ring; each node owns many token ranges through virtual nodes | Partition key and clustering columns | Very large partitions (aim for well under about 100 MB per partition); hot keys |
| DynamoDB | Hashes the partition key to internal partitions, which split automatically as data or traffic grows | Partition key (and sort key) | Per-partition throughput; a single hot key cannot be split |
| MongoDB | Splits data into range-based chunks on the shard key, or on a hash of it; a balancer migrates chunks between shards | Shard key, ranged or hashed | Monotonic keys (timestamps, ObjectIds) on a ranged key send every insert to one shard |
| Vitess (MySQL), Citus (PostgreSQL) | A sharding layer in front of ordinary database servers routes queries and supports online resharding | Sharding key per table | Cross-shard joins and transactions are slower |
| Spanner, CockroachDB | Split the key space into ranges that split and move automatically, with consensus replication per range | Primary key design | Sequential keys create a hot range at the end |
| Aurora (single writer) | Storage is distributed and grows automatically into the hundred-terabyte range; writes still go through one writer instance | Instance size, replicas | Write throughput is capped by one writer |
In a design discussion it is enough to say "DynamoDB with user_id as the partition key" or "PostgreSQL with Vitess-style sharding on user_id, with online resharding run by operators". Explain the internals only if asked. What matters is that the numbers show sharding is needed, and that the key spreads load and keeps most queries on one partition.
Typical data sizes#
Capacity numbers need sizes to become useful. These are typical, not exact:
| Item | Approx. size |
|---|---|
| Integer / timestamp | 4-8 bytes |
| UUID (binary / text) | 16 bytes / 36 bytes |
| Short text record (tweet-like post with metadata) | ~300 bytes - 1 KB |
| User profile row | ~0.5-2 KB |
| Index entry (key + pointer) | ~20-100 bytes, plus B-tree overhead |
| Web page (HTML) | ~50-100 KB compressed transfer; a few MB with all assets |
| Thumbnail / profile photo | ~10-50 KB |
| Phone photo (compressed JPEG/HEIC) | ~1-5 MB |
| 1 minute of 1080p video (streaming bitrate) | ~30-60 MB |
| 1 minute of compressed audio | ~1 MB |
| Log line / metrics event | ~100 bytes - 1 KB |
Two quick consequences:
- Metadata is small, media is huge. A billion 1 KB rows is 1 TB and fits on one server. A billion photos at 2 MB each is 2 PB and belongs in object storage behind a CDN. Most designs split the two: metadata in a database, blobs in Object Storage.
- Overheads multiply raw sizes. Indexes, replication (usually 3x), row headers, fragmentation and free space for compaction often turn 1 TB of raw data into 3-6 TB of provisioned storage.
Cheat sheet#
If you remember only one block, remember this one:
| Thing | Number to use | What it tells you |
|---|---|---|
| RAM reference / SSD read / same-zone RTT | 100 ns / 100 µs / 0.5 ms | Keep hot data in memory; local network ≈ local disk |
| Cross-zone / cross-region RTT | 1-2 ms / 50-150 ms | Synchronous cross-region calls do not belong on the hot path |
| One server | 64-128 vCPU, 0.5-4 TB RAM, tens of TB NVMe, 25-100 Gbps | Most datasets under a few TB fit on one box |
| Cache node (Redis) | ~100k ops/s, under 1 ms, tens-hundreds of GB | Shard only past ~100 GB-1 TB hot set or ~100k+ ops/s |
| SQL primary | ~5k-20k writes/s, several TB | Shard writes only well past ~10k/s or multi-TB with slow restores |
| App server | ~1k-10k RPS | Divide peak RPS by this, add 30-50% headroom and N+1 |
| Kafka broker | ~hundreds of MB/s, up to ~1M small msgs/s | Partition count, not broker speed, usually caps consumers |
| WebSocket host | ~100k connections | 10M concurrent users ≈ 100+ connection servers |
| 99.9% / 99.99% | 43.8 min / 4.4 min per month | Four nines needs automated recovery |
Large objects are not scary either. A 1 MB value in RAM is fine; it becomes a problem only when it is read 10,000 times per second (10 GB/s) or blocks a single-threaded server while it is copied. Large blobs still belong in object storage, but because of cost and bandwidth, not because memory cannot hold them. Very large bulk datasets also have homes: HDD-dense storage instances (for example AWS's d3en.12xlarge with about 336 TB of HDD) serve sequential, cold data cheaply.
Availability: nines to downtime#
| Availability | Downtime per year | Downtime per 30-day month | Downtime per week |
|---|---|---|---|
| 99% ("two nines") | ~3.65 days | ~7.2 hours | ~1.7 hours |
| 99.5% | ~1.8 days | ~3.6 hours | ~50 minutes |
| 99.9% | ~8.8 hours | ~43.8 minutes | ~10 minutes |
| 99.95% | ~4.4 hours | ~21.9 minutes | ~5 minutes |
| 99.99% | ~52.6 minutes | ~4.4 minutes | ~1 minute |
| 99.999% | ~5.3 minutes | ~26 seconds | ~6 seconds |
Each extra nine cuts allowed downtime by 10x, and it usually costs much more than 10x in engineering:
- Three nines: one region with multiple zones, automated failover and careful deploys.
- Four nines: no human in the loop for common failures, fast automated rollback, and redundancy for every critical dependency.
- Five nines: usually multi-region active-active designs, extremely careful change management, and dependencies that are themselves better than five nines.
Two quick rules of thumb:
- Serial dependencies multiply: three services at 99.9% in a chain give about 99.7%.
- A human-driven recovery that takes 20-30 minutes uses up a 99.95% monthly budget in a single incident.
See Availability and Reliability.
When one machine is enough#
A single modern database server, with replicas for failover, comfortably handles:
- data up to a few terabytes, and often far more;
- a working set (hot data) that fits in RAM, which can be hundreds of gigabytes;
- thousands of writes per second and tens of thousands of reads per second.
That covers most business applications: SaaS products with thousands of customers, internal platforms, many e-commerce sites, and most startups for years. Some quick arithmetic shows why:
- Users: 10 million user rows at 1 KB each is 10 GB, which fits in RAM.
- Orders: 1 billion order rows at 500 bytes each is 500 GB, which fits on one NVMe server with room for indexes.
- Writes: 2,000 writes per second at peak is well within one primary.
Distribute when a number clearly exceeds these limits, or when availability or geography demands it:
- Sustained write load beyond what one primary handles with headroom (tens of thousands per second).
- Data size where backups, restores, index builds or schema migrations take too long. "Restore takes 18 hours" is often the real trigger.
- Blast radius: one database outage taking down every customer may be unacceptable, so you split by tenant or region.
- Geography: users on several continents who need low-latency writes, or laws requiring data to stay in a region.
- Isolation: noisy tenants or workloads (analytics against OLTP) that should not share hardware.
Rough cost anchors#
Prices change and differ by provider and region, so treat these as relative guides rather than quotes. On public clouds, at list prices:
- Object storage, standard class: roughly a couple of cents per GB per month. Archive classes are an order of magnitude cheaper still.
- Block SSD storage: several times the price of object storage per GB.
- RAM in a running instance: works out to dollars per GB per month, so caching 1 TB in memory costs far more than storing 1 TB on disk.
- Data transfer out to the internet and between regions: typically billed per GB, often a few cents to around ten cents per GB. At petabyte scale this is a major line item, which is why CDNs, compression and keeping traffic within a region matter.
The design consequences:
- Keep cold data in object storage.
- Cache only the hot set.
- Watch egress.
- Remember that an engineer's time often costs more than the servers they would save.
Worked examples: numbers making decisions#
The point of these numbers is to settle design questions quickly. Each example below takes a realistic requirement, applies the numbers and reaches a decision.
1. Do short-URL lookups need a cache, and how big?
- 1 billion short URLs, each mapping about 100 bytes of key and URL plus overhead, roughly 500 bytes per entry in a database: 500 GB. One database server stores it easily.
- Redirects: 100M daily users, 10 redirects each, is 1 billion a day, about 11,500 per second on average and perhaps 100,000 per second at peak.
- Serving from disk: an indexed lookup costs about 1-5 ms. With RAM about 1,000 times faster than SSD and SSD roughly 100 times faster than HDD for random reads, the gap is large. A few replicas could handle 100,000 reads per second, but an in-memory cache is the natural fit: memory serves millions of reads per second, and Redis around 100,000 operations per second per node.
- The hot set is much smaller than 500 GB, since most clicks go to recent or popular links. Caching the top 20%, about 100 GB with Redis overhead, fits a small cluster of 2-4 nodes with replicas.
- The decision: one primary database, a Redis cache of about 100 GB, and optionally a CDN or edge function for the most popular codes.
2. How many WebSocket servers for a chat app?
- 50 million concurrent connections at peak.
- At about 100,000 connections per tuned server: 500 gateway servers, plus headroom for losing a zone, so about 750.
- Memory: 100,000 × 20 KB per connection = 2 GB per server, which is easy. The real limits are the message rate per server and the reconnection storm after a failure.
3. Does a click stream at 10,000 events per second need a big Kafka cluster?
- 10,000 clicks per second × 500 bytes = 5 MB/s. One broker handles hundreds of MB/s.
- A day of clicks: about 1 billion events at peak rates, or 100 million at the average of 1,000 per second, which is 50 GB a day at 500 bytes. Seven days of retention with replication factor 3 is about 1 TB in total.
- A good broker holds around 1 TB and, very roughly, up to 1 million small messages per second. So the volume needs only the minimum cluster of three brokers, used for fault tolerance, not capacity.
- What matters is partitions: enough for consumer parallelism. If each consumer processes 2,000 events per second, 10,000 per second needs at least 5 partitions. Choose 12-24 for growth.
4. Can a leaderboard for 10 million players live in one Redis instance?
- A sorted-set entry costs about 100 bytes with overhead, so 10M players take about 1 GB.
- Score updates at 20,000 per second and rank queries at 50,000 per second are within one Redis node's ~100,000 operations per second, though close enough to plan a read replica for the queries.
- The decision: one Redis primary with a replica; no sharding.
5. How long does it take to make 100 image thumbnails?
- Reading 100 photos of 3 MB each, 300 MB, from NVMe at about 3 GB/s takes about 0.1 s.
- Decoding and resizing a 12-megapixel JPEG takes roughly 20-50 ms of CPU, so 100 images take 2-5 s on one core, or about 0.2-0.3 s across 16 cores.
- The decision: thumbnailing is CPU-bound, not I/O-bound. Scale it with parallel workers, not faster disks.
6. Can typeahead suggestions be served from memory?
- 10 million distinct popular queries, averaging 30 bytes, plus scores and structure overhead: about 1-2 GB as an in-memory trie or sorted prefix table.
- The decision: every typeahead server can hold the whole index in RAM and answer in well under a millisecond, so the index is rebuilt offline and shipped to servers, not queried from a database.
Hot keys: when one key outgrows one node#
Per-node capacity numbers assume load is spread across keys. A single hot key cannot be spread by ordinary sharding, because every request for that key goes to the node that owns it. The numbers make the problem concrete:
- One Redis node serves about 100,000 simple operations per second. A celebrity profile, a viral post or a flash-sale product read 1 million times per second needs ten times what its owning node can give.
- A DynamoDB partition serves about 3,000 strongly consistent reads per second for small items. A single hot item gets no help from adding partitions.
- A Kafka partition is consumed by one consumer in a group. If a large share of all events carries the same key, one consumer must process all of them.
The standard remedies, with their numbers:
- In-process cache with a short TTL. If 200 app servers each cache the hot key for 1 second, the backing store sees about 200 reads per second for that key instead of 1 million. Staleness is bounded at 1 second.
- Replicate the hot key. Store N copies under
key#0…key#N-1on different shards and read a random one. With 10 copies, each node serves about 100,000 reads per second. Writes must update all copies. - Read replicas of the owning node. Redis replicas or DynamoDB accelerators (DAX) absorb reads for the hot shard.
- Split hot write keys. A counter updated 50,000 times per second becomes 50 sub-counters updated 1,000 times each and summed on read, or summed periodically.
- Salting partition keys in a log. Append a random suffix to the hot key (such as
adId-7) to spread its events over several partitions, and merge in the consumer. This sacrifices per-key ordering. - Request coalescing. When a hot entry expires, let one request rebuild it while the others wait for that result, instead of all hitting the database at once (a cache stampede).
Numbers at the edge: users, devices and the last mile#
Data center numbers describe the server side. Users experience the whole path, and the last mile often dominates:
| Path segment | Typical latency | Notes |
|---|---|---|
| Wi-Fi or wired broadband to the internet | ~5-20 ms | Higher on congested home Wi-Fi |
| 4G mobile radio | ~30-100 ms round trip | Plus a wake-up delay when the radio has been idle |
| 5G mobile | ~10-30 ms round trip | Varies widely by network and coverage |
| 3G or poor mobile coverage | ~100-500 ms round trip | Still common in some regions and indoors |
| DNS lookup (uncached) | ~20-120 ms | Cached lookups are near zero |
| User to a nearby CDN edge | ~10-40 ms | Why CDNs help so much |
| User in India to an origin in US East | ~250-300 ms per round trip | A request served from a nearby CDN edge takes about 20-40 ms instead |
Each new connection costs several round trips: a DNS lookup, the TCP handshake, then TLS (one round trip with TLS 1.3, two with TLS 1.2), and only then the request itself. On a 100 ms mobile link, a cold HTTPS request can take 300-500 ms before the server does any work. That is why connection reuse, HTTP/2 and HTTP/3, edge termination and prefetching matter so much for mobile users.
Bandwidth on the last mile is far below data center speeds. A user on a 5 Mbps connection downloads 1 MB in about 1.6 seconds. A 3 MB page takes about 5 seconds before rendering finishes, whatever the server does. Page weight, image formats and lazy loading are performance features.
Battery and radio. Each time a phone wakes its cellular radio, the radio stays in a high-power state for several seconds after the transfer. Many small requests spread over time cost far more battery than the same bytes sent in one batch. This is why mobile apps batch analytics, rely on platform push services instead of polling, and sync in the background at intervals.
When to Use It#
- During estimation, to turn QPS and storage into a number of nodes.
- When checking a latency budget: add up the hops on the request path.
- When someone proposes sharding or a new datastore: check whether one node would do.
- When choosing between memory, SSD, network-attached and object storage.
- When reviewing a design for hidden cross-region calls, sequential fan-out or chatty protocols.
- When judging vendor or benchmark claims: a number far outside these ranges deserves scrutiny.
When NOT to Use It#
- As a replacement for benchmarks. For a real launch, load-test your own workload; it can be 10x away from these figures in either direction.
- To argue over small differences. If two options are within 2x of each other, decide on other grounds such as simplicity, cost or team familiarity.
- To quote precise prices or limits in contracts; check the provider's current documentation.
How to Implement It#
- Memorise the anchors: RAM ~100 ns, SSD ~100 µs, same-zone round trip ~0.5 ms, cross-zone ~1-2 ms, cross-continent ~100 ms.
- Memorise capacities: app server ~thousands RPS, SQL primary ~10k writes/s, Redis ~100k ops/s, Kafka broker ~hundreds of MB/s.
- Build a latency budget for the main request by summing the hops, and check that it fits the SLO with headroom for the tail.
- Divide peak load by per-node capacity, then add headroom (run at 50-70%) and redundancy (N+1 zones).
- Benchmark the components that the decision hinges on, using your own data shapes and request mix.
- Update your numbers every few years, or when you move to new hardware generations.
Latency budget: user in Europe, servers in Europe, p99 target 200 ms
TLS + request round trip (user to region) : ~40 ms
Load balancer + app logic : ~10 ms
2 cache lookups (~1 ms each) : ~2 ms
1 indexed DB query : ~5 ms
Call to another service in same region : ~5 ms
Total ~62 ms -> headroom for p99 spikes.
A synchronous call to a US service (+~90 ms) still fits, barely; two do not.
30 sequential 5 ms calls = 150 ms -> parallelise or batch them.| Technology | Fits when |
|---|---|
fio | Measuring disk throughput, IOPS and latency percentiles |
iperf3 | Measuring network bandwidth between hosts |
ping, mtr | Measuring round-trip times and paths |
redis-benchmark, pgbench, sysbench | Measuring datastore capacity on your hardware |
kafka-producer-perf-test, kafka-consumer-perf-test | Measuring Kafka throughput |
| k6, Locust, wrk2, Gatling | Measuring app server RPS and latency (wrk2 corrects coordinated omission) |
Trade-offs#
| Storage tier | Pros | Cons | Pick when |
|---|---|---|---|
| RAM (cache) | Fastest (~100 ns local, ~0.5 ms over network) | Expensive per GB, volatile | Hot data, sessions, counters |
| Local NVMe SSD | Very fast, cheap per IOPS | Lost if the host dies, unless replicated | Databases with replication, caches, scratch space |
| Network block storage | Survives host failure, resizable, snapshots | Higher latency (~0.5-2 ms), IOPS tiers cost more | General-purpose databases in the cloud |
| Object storage | Cheapest, extremely durable, unlimited | ~10-100 ms per request; not a filesystem | Media, backups, data lakes, logs |
| HDD | Cheapest per TB for local bulk | Slow random access (~10 ms seeks) | Archival, sequential bulk data |
| Decision | Option A | Option B | Rule of thumb from the numbers |
|---|---|---|---|
| Hot key at 1M reads/s | Bigger Redis node | In-process cache with 1 s TTL + key copies | One node tops out near ~100k ops/s; spread or absorb the key |
| Large payloads in a queue | Raise the message size limit | Pointer to object storage | Keep messages small; copy bytes once |
| Durable writes | fsync per transaction | Group commit | 1 ms per flush caps you near 1,000 commits/s per log without batching |
| Cache sizing | Raw item size × count | Measured size with overhead | Real memory is often 2-10x the raw data |
| Kafka partitions | Few now, add later | Enough for 2-3 years of growth | Adding partitions remaps keys and breaks ordering during the change |
| Mobile chatty API | Many small calls | One batched call | Each round trip on 4G costs 30-100 ms plus radio wake-up |
Common Pitfalls#
- Treating numbers as exact. They are orders of magnitude.
- Using decade-old numbers (spinning disks, 1 Gbps networks, 32 GB servers) and over-distributing as a result.
- Premature sharding: splitting a 200 GB database that does 1,000 writes per second, adding months of complexity for no benefit.
- Overestimating latency: assuming a cache or database read takes 10-50 ms, when it is under 1-5 ms in the same zone. This leads to unnecessary caching layers.
- Over-engineering for writes: reaching for Kafka and Cassandra at a few thousand writes per second, which one SQL primary handles.
- Forgetting fan-out: a page making 30 sequential 5 ms calls is already 150 ms.
- Ignoring cross-region hops hidden inside "just call that service".
- Ignoring value size: ops/s numbers assume small values; large values hit network limits first.
- Ignoring contention: 20k writes per second on independent rows can become a few hundred per second on one hot row.
- Quoting the classic 2010 list unchanged: SATA-era SSDs, 1 Gbps links and 30 MB/s disks make modern designs look far more constrained than they are.
- Sizing caches from raw bytes and forgetting per-key overhead, replication and snapshot headroom.
- Putting large payloads in Kafka, SQS or DynamoDB items instead of storing them in object storage and passing a pointer.
- Assuming sharding fixes a hot key; a single key lives on a single partition whatever the cluster size.
- Benchmarking writes with durability turned off, or disks without bypassing the page cache.
- Forgetting the last mile: a fast backend does not help a user on a 100 ms mobile link who needs four round trips per request.
- Hitting hard limits late, such as item sizes, connection caps, ephemeral ports and function time limits, because nobody checked them during design.
Real-World Examples#
Jeff Dean of Google popularised a list of "latency numbers every programmer should know" in talks such as his 2009 LADIS keynote. This page follows the same idea, with values updated for current hardware.
Stack Overflow's engineers have described running one of the web's busiest sites on a small number of large SQL Server machines and a handful of web servers. It is a well-known example of how far single large machines go.
Frank McSherry, Michael Isard and Derek Murray's paper "Scalability! But at what COST?" (HotOS, 2015) showed that single-threaded implementations on a laptop could beat several published distributed graph-processing systems running on many machines. It is a reminder that distribution has a large overhead that must be repaid.
Typical scenario: a team plans to shard a 400 GB PostgreSQL database doing 2,000 writes per second. These numbers show that one primary handles it. They add read replicas and a cache instead, and save months of work.
The Instagram team's 2012 engineering post on sharding described running thousands of logical shards on far fewer PostgreSQL servers. It is a reminder that one server, properly used, holds a lot of data, and that splitting into many logical shards early keeps later growth cheap.
WhatsApp's engineering blog reported in 2012 that one server held more than 2 million concurrent TCP connections. That is an upper-end data point that shows the 100,000-connections figure on this page is conservative for well-tuned systems.
Amazon publishes concrete per-partition and per-prefix limits for DynamoDB and S3. Designs at large companies routinely start from these documented numbers, for example by spreading S3 keys across prefixes or choosing DynamoDB partition keys so that no single key exceeds per-partition throughput.
In the Interview#
Deep Dive: Why ratios matter more than valuesShow
Hardware gets faster every year, but the ratios between tiers stay roughly stable, and design decisions follow the ratios:
- RAM is about three orders of magnitude faster than SSD for random access.
- An SSD random read is about the same order as a same-zone network round trip, a few hundred microseconds. That is why remote memory (a Redis GET) and local SSD are competitive, and why network-attached storage became practical.
- A cross-region round trip is two orders of magnitude slower than a same-zone one.
If a design is right for today's ratios, it will usually stay right as hardware improves.
The speed of light is a hard floor. Light in optical fibre travels at about 200,000 km/s, roughly two-thirds of its speed in a vacuum. New York to London is about 5,600 km, so the trip takes about 28 ms one way and about 56 ms for a round trip, before any routing, queuing or processing. Real paths are longer than great circles, so measured round trips are typically 70-80 ms. No technology removes this floor, which is why global systems put data near users and avoid synchronous cross-region calls on the hot path.
Some numbers have stopped improving.
- RAM latency has stayed near 100 ns for two decades. Capacity and bandwidth grew, but each random access still costs about the same.
- Single-core clock speeds plateaued in the mid-2000s, when Dennard scaling (shrinking transistors used less power per area) ended, so CPUs grew more cores instead.
Performance now comes from parallelism and locality, meaning keeping data in caches and accessing it sequentially, rather than from faster single operations.
Throughput and latency of a device are linked. An SSD that does 1 million IOPS at a high queue depth may show a p99 latency of milliseconds under mixed reads and writes or during internal garbage collection. The tail latency (p99.9) of disks, networks and language runtimes (GC pauses) is often 10-100x the median. Design for the tail.
Capacity numbers hide contention. A database that does 20,000 writes per second on independent rows may do a few hundred per second when every write updates the same counter row, because each one waits for the previous row lock and log flush. Always ask what the hottest key is, not just what the total throughput is.
Deep Dive: The COST of scaling out, and when distribution paysShow
McSherry, Isard and Murray defined COST (Configuration that Outperforms a Single Thread) as the number of cores a distributed system needs before it beats a competent single-threaded implementation. For several published graph-processing systems they measured COSTs in the hundreds of cores, and in some cases the distributed system never beat the laptop at all. The overheads come from three sources:
- Coordination: every node must agree on progress, which adds barriers and round trips.
- Serialisation and network: data that moves between machines must be encoded, sent and decoded; a RAM access is about 100 ns, a network round trip about 500,000 ns.
- Generality: frameworks built for any job cannot use the tight, cache-friendly loops that a specialised program uses.
The lesson for system design is not "never distribute". It is to know what you pay:
- Distribute for capacity only when one machine cannot hold the data or sustain the throughput, with headroom.
- Distribute for availability, using replicas and zones, almost always for production systems. This kind of distribution is cheap, because replicas mostly sit idle or serve reads.
- Distribute for geography when users are far apart and latency or residency matters.
- Do not distribute for fashion. A sharded cluster for a dataset that fits in one server's RAM adds latency, cost and failure modes.
A rough checklist before scaling out a data store:
- Measure the bottleneck (CPU, I/O, locks, network) on the current node.
- Fix queries and indexes, and add caching and connection pooling.
- Scale up to the next instance size and check the cost curve.
- Add read replicas for read load.
- Only then partition, and partition by the key that keeps most operations on one node.
The Universal Scalability Law (see Scaling from Zero to Millions) explains why the last step must keep cross-node coordination rare: coherency costs grow with the square of the node count.
Deep Dive: Tail latency, fan-out and the bandwidth-delay productShow
Medians lie; tails decide user experience. Suppose each backend server answers in 10 ms at the median but 1 second at the 99th percentile (a GC pause, a compaction, a noisy neighbour). One request that touches one server sees the slow case 1% of the time. A request that fans out to 100 servers and waits for all of them sees at least one slow reply with probability 1 - 0.99^100 ≈ 63%. Dean and Barroso made this point in "The Tail at Scale" (2013): at scale, rare per-server hiccups become the common case for the overall request.
Useful mitigations, each with a cost:
- Hedged requests: send a second copy to another replica if the first has not answered within, say, the p95 latency; take whichever returns first. Extra load is small (a few percent) because only slow requests are hedged.
- Tied requests: send to two replicas at once and let the one that starts first cancel the other.
- Partial results: return what arrived within the deadline (common in search and feeds), with a flag that results may be incomplete.
- Fewer, larger hops: batching and denormalising reduce how many servers a single request must touch.
Coordinated omission. Many load tools wait for each response before sending the next request. When the server stalls, the tool also stalls and records only one slow sample instead of the hundreds that real users would have suffered. Gil Tene popularised this term; tools such as wrk2 and HdrHistogram correct for it. If your p99 looks suspiciously good, check how it was measured.
Bandwidth-delay product. To keep a link full, the sender must have bandwidth × round-trip time bytes in flight. At 10 Gbps and 100 ms cross-continent, that is 10^10 / 8 × 0.1 ≈ 125 MB. Default TCP buffers are far smaller, so a single cross-region transfer often reaches only a fraction of link speed. Fixes are larger socket buffers (window scaling), parallel streams, or modern congestion control such as BBR. Inside one data center (0.5 ms), the same 10 Gbps needs only about 0.6 MB in flight, which is why local transfers saturate links easily.
Queueing near saturation. For a simple single-server queue, the average wait grows roughly as utilisation / (1 - utilisation). At 50% load the wait equals about one service time; at 90% it is about nine; at 99% it is about ninety-nine. That is why every capacity number on this page should be used at 50-70% utilisation, not 100%. See Latency, Throughput and Performance.
Deep Dive: Turning numbers into cost decisionsShow
Performance numbers decide whether a design works; cost numbers decide whether it is worth building. Three comparisons come up again and again.
RAM versus disk for the same data. Keeping 1 TB in a cache cluster means buying perhaps 1.5-2 TB of RAM once overhead and replicas are included, at dollars per GB per month. Keeping the same 1 TB on SSD costs roughly an order of magnitude less, and in object storage less again. So cache the hot set only. With Zipf-like popularity, caching the top 10-20% of items often captures 80-90%+ of reads (see Back-of-the-Envelope Estimation).
Compute versus egress. A video service serving 10 PB a month to the internet pays for that transfer per GB. Even at a few cents per GB, egress can exceed the entire compute bill. This drives CDNs, regional caches and better codecs. A 20% bitrate saving from a newer codec can be worth more than any server optimisation.
Engineers versus servers. A larger database instance that costs a few thousand dollars a month more than a smaller one is often cheaper than a sharding project that occupies two engineers for six months and adds permanent operational load. Conversely, at very large scale (thousands of servers), a 10% efficiency gain pays for a whole team. The break-even point depends on fleet size, which is why small companies should buy bigger machines and large companies invest in efficiency.
A practical habit: next to every capacity estimate, write the monthly cost of the main resources (compute, RAM, storage tiers, egress). Designs that look equivalent in performance often differ by 5-10x in cost.
Deep Dive: What actually fits in memory (overheads)Show
Estimates like "10 million items × 100 bytes = 1 GB" are useful, but real memory use is often 2-10 times the raw data size. Knowing where the overhead comes from keeps cache and index sizing honest.
Redis. Every key carries bookkeeping beyond its raw bytes:
- a hash-table entry;
- an object header;
- string headers for the key and value;
- allocator rounding to size classes;
- expiry metadata if a TTL is set.
For small strings, expect very roughly 50-100 bytes of overhead per key. One billion keys with 20-byte keys and 30-byte values is not 50 GB but more like 100-150 GB. Ways to reduce it:
- Group small items into hashes. Instead of a billion top-level keys
url:abc123, store them in buckets such asurl:abcwith field123. Small hashes use a compact encoding (listpack) that removes most per-key overhead, often cutting memory by half or more. - Use compact types. Integers stored as integers, bitmaps for flags (one bit per user: 100 million users fit in 12.5 MB), and HyperLogLog for approximate unique counts (about 12 KB per counter, whatever the cardinality).
- Leave headroom for snapshots. A background save forks the process. With copy-on-write, pages that change during the save are duplicated, so a write-heavy instance can briefly need much more memory. Plan for 25-50% free memory on persistent instances.
Relational databases. In PostgreSQL:
- every row has a header of about 23 bytes, padded to 24, plus a 4-byte pointer in its page;
- columns are aligned to their type boundaries;
- pages are 8 KB and are rarely completely full.
A row with 40 bytes of real data occupies about 70-80 bytes. Each B-tree index adds an entry per row of roughly 16-40 bytes plus page overhead. A table of 1 billion such rows with three indexes is about 150-200 GB, not 40 GB. To keep queries fast, the working set (the hot rows and the upper levels of the indexes) should fit in the buffer pool and OS page cache.
Language runtimes. In-process caches in managed languages pay for object headers and pointers:
- JVM: with compressed pointers, every object has a 12-byte header and is padded to a multiple of 8 bytes. A Java
HashMap<Long, Long>entry costs about 70-80 bytes (the entry object, two boxed Longs and a table slot) to store 16 bytes of data, about 5 times the raw size. Primitive-specialised collections or off-heap stores bring it close to raw. - Go: maps cost roughly tens of bytes per entry beyond the key and value.
- Python: small objects cost tens of bytes each.
A practical method. Load a realistic sample of 1 million items into the actual store and measure memory before and after. For Redis, MEMORY USAGE reports a key's cost and INFO memory the instance's. Multiply by your item count, then add replication and headroom. This takes ten minutes and is far more reliable than any table.
Deep Dive: Measuring your own numbers without fooling yourselfShow
Every number on this page is a starting point. For a decision that matters, measure, and avoid the traps that make benchmarks lie.
Durable writes cost more than writes. A write that sits in the OS page cache returns in microseconds. A write followed by fsync must reach stable storage, and its cost varies enormously:
| Device | Typical fsync latency |
|---|---|
| Enterprise NVMe with power-loss protection | ~tens of µs; the protected write cache can acknowledge safely |
| Consumer SSD without power-loss protection | ~1-10 ms; it must flush its volatile cache |
| Cloud network block storage | ~0.5-2+ ms; the write crosses the network to replicated storage |
| HDD | ~several ms or more, bounded by rotation |
This is why databases use group commit. If one fsync costs 1 ms, a database that flushes once per transaction can commit about 1,000 transactions per second per log. One that flushes 50 transactions at a time can commit 50,000. When you measure database write throughput, always check the durability settings, such as synchronous_commit in PostgreSQL or innodb_flush_log_at_trx_commit in MySQL. "100,000 writes per second" with durability turned off is a different system.
Disk benchmarks. With fio:
- Use
--direct=1to bypass the page cache, or you are measuring RAM. - Choose the queue depth (
--iodepth) to match the application. A database issuing one synchronous read at a time sees latency at queue depth 1, not the headline IOPS at 32 or more. - Run long enough to fill the drive's spare area. SSDs slow down once internal garbage collection starts, often after writing an amount comparable to their capacity.
- Report percentiles, not averages.
Network benchmarks. iperf3 measures bandwidth between two hosts. Run several parallel streams (-P) to see the link capacity; a single stream may be limited by its TCP window. For latency, measure the application's real request-response pattern, not just ping, since ICMP may be handled differently from your traffic.
Service benchmarks.
- Warm up first. JIT compilation, connection pools and caches all need time, so discard the first minutes.
- Use an open-model load generator (wrk2, or k6 with arrival-rate executors) so latency under load includes queueing.
- Use production-shaped data: realistic sizes, key distributions such as a Zipf-like skew, and the real mix of reads and writes.
- Watch the machine during the test. If CPU frequency scaling, a noisy neighbour on shared cloud hardware or a throttled burst-credit volume changes results between runs, the benchmark is measuring the environment.
Find the knee, not the maximum. Increase load step by step and plot p50 and p99 latency against throughput. The useful capacity is where p99 starts to bend upward, usually well before maximum throughput. That knee, divided by your headroom target, is the per-node number to put into your capacity plan.
Deep Dive: Little's law turns latency numbers into pool sizesShow
Latency and throughput numbers become concrete capacity limits through Little's law. In a stable system, the average number of requests in progress equals the arrival rate times the average time each spends inside: L = λ × W. It holds for any queueing system, whatever the distribution of arrivals, which makes it the most useful single formula in capacity planning.
Database connection pools. Suppose an API makes 10,000 database queries per second, each holding a connection for 5 ms on average. The number of connections busy at any moment is 10,000 × 0.005 = 50. A pool of 60-80 connections is enough, and a pool of 1,000 would not make anything faster. The database would just juggle more concurrent work on the same cores and disks. A widely quoted starting point from the PostgreSQL community is about cores × 2 + effective disk spindles active connections per database server. Beyond that, extra concurrency mostly adds lock and CPU contention.
Thread pools. An app server with 200 worker threads, where each request takes 50 ms, can complete at most 200 ÷ 0.05 = 4,000 requests per second, however fast the CPU is. If a downstream dependency slows down from 50 ms to 2 s, the same 200 threads can complete only 200 ÷ 2 = 100 requests per second. Requests then queue, time out and are retried, and the server effectively goes down even though its own CPU is idle. This is the mechanism behind many cascading failures. The defences come straight from the formula:
- Timeouts cap W, so a slow dependency cannot hold threads forever.
- Bulkheads give each dependency its own small pool, so one slow dependency cannot take all the threads.
- Circuit breakers stop calling a dependency that is failing, which brings W back down to nearly zero for those calls.
- Asynchronous I/O makes waiting cheap, so L can be in the tens of thousands without a thread per request. The cost of each request moves to memory instead.
Connection-holding tiers. A WebSocket gateway with 100,000 connected users, each sending a message every 30 seconds, receives 100,000 ÷ 30 ≈ 3,300 messages per second. If each message takes 2 ms to process, the average work in progress is 3,300 × 0.002 ≈ 7 messages, about 7 busy cores' worth at full utilisation, before headroom. Connections are cheap to hold; their message rate is what costs CPU.
Queue backlogs. A queue receiving 2,000 jobs per second, with jobs that take 3 s each, needs 2,000 × 3 = 6,000 jobs in progress to keep up: for example, 600 workers each running 10 jobs concurrently. With only 500 workers, the backlog grows by about 330 jobs every second, and after a 10-minute spike it holds about 200,000 jobs. Drained at the 1,000-jobs-per-second spare capacity of a larger fleet, that backlog takes over 3 minutes to clear.
The general habit: whenever you see a latency number and a rate together, multiply them. The product tells you how many connections, threads, workers or in-flight requests the design must hold, and whether a slow dependency will exhaust them.
Key Takeaways#
- RAM is roughly 1,000x faster than an SSD random read; a same-zone round trip is about 0.5 ms and a cross-continent one about 100 ms.
- Modern servers have 100+ cores, terabytes of RAM, tens of terabytes of NVMe and 25-100 Gbps networks, so many workloads fit on one machine.
- One SQL primary handles thousands to tens of thousands of writes per second, one Redis node about 100k ops/s, one app server thousands of RPS, and one Kafka broker hundreds of MB/s.
- Each extra nine of availability cuts downtime by 10x: 99.9% is about 43.8 minutes a month, 99.99% about 4.4 minutes.
- Distribute for capacity only when numbers clearly exceed one node; distribute for availability and geography when requirements demand it.
- Avoid premature sharding, overestimated latencies and over-engineering for modest write rates.
- Ratios between tiers matter more than exact values; the speed of light sets a hard floor on global latency.
- Use these as orders of magnitude, and benchmark your own workload before committing.
- Physics-bound numbers (DRAM latency, long-distance RTT) have not changed since the classic list; storage and network speeds have improved 5-100x.
- Hard limits (item sizes, message sizes, connection caps, per-partition throughput) often decide designs before speed does; use the pointer pattern for large payloads.
- A hot key cannot be sharded away: absorb it with short-TTL local caches, key copies, replicas or split counters.
- Real memory use is often several times the raw data size; measure a sample before sizing caches and indexes.
- Durable writes are bounded by flush latency, so batching and group commit multiply write throughput.
- Multiply rate by latency (Little's law) to size pools, threads and workers, and use timeouts and bulkheads so a slow dependency cannot exhaust them.
- Per-core CPU costs matter: TLS handshakes, JSON encoding and password hashing often dominate app-server capacity.