# Read/Write Ratio and Fan-out — Cost & Capacity Estimation

Source: https://www.skillbyai.com/en/capacity-estimation/ce-read-write-ratio

> Separate reads from writes, estimate fan-out, and see how both shape the architecture.

## Reads and writes scale differently

Most consumer systems are **read-heavy**: a post is written once and read many times, so read-to-write ratios of 10:1 or 100:1 are common assumptions. Reads can be scaled with caches, read replicas and CDNs. Writes are harder, because every write must eventually reach the source of truth and its replicas; scaling them usually means partitioning (sharding). Some systems are **write-heavy** instead, such as logging, metrics and IoT ingestion, where append-friendly storage matters more than caching. **Fan-out** multiplies load: in a social feed, one post by an account with a million followers means a million feed inserts if you push to followers on write; if you pull on read instead, the cost moves to read time, where every feed load must look up and merge posts from all the accounts that user follows. Estimating the ratio and the fan-out early tells you which side of the system deserves the engineering effort.

## Fan-out on write vs on read

Compare internal operations per second for a feed with two strategies, using illustrative numbers.

```python
posts_per_sec = 2_000
avg_followers = 200
feed_reads_per_sec = 100_000
followees_per_user = 150

push_writes = posts_per_sec * avg_followers      # write into each follower's feed
pull_reads = feed_reads_per_sec * followees_per_user  # merge followees at read time
print(f"fan-out on write: {push_writes:,} feed inserts/s")
print(f"fan-out on read : {pull_reads:,} timeline lookups/s")
```

Output:

```
fan-out on write: 400,000 feed inserts/s
fan-out on read : 15,000,000 timeline lookups/s
```

## Celebrities break averages

An average follower count hides a long tail. Many real feed designs push for normal accounts and pull for very large ones; mention this hybrid when an interviewer asks about skew.

**Quiz:** Which component is usually the first choice for scaling a read-heavy workload?

- [ ] Adding more write shards
- [x] Caching and read replicas
- [ ] Increasing the replication factor of writes
- [ ] Switching to a message queue

*Answer:* Caching and read replicas. Reads that repeat can be served from caches and replicas, which take load off the primary. Sharding is mainly for scaling writes and data size.
