Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Storage Estimation
HLD

Storage Estimation

Record sizes, retention, and multipliers — projecting data growth year over year with the RideShare worked example.

The Formula

Every storage estimate is one multiplication with three honest add-ons:

 raw      = records/day × record size × days of retention
 +indexes ≈ ×1.2–2.0 depending on secondary indexes
 +replication ≈ ×3 (RF=3) or ×1.5 (erasure coding)
 +growth headroom ≈ keep ≤70% disk utilization
 
 usable capacity ≈ raw × index-factor × replication ÷ 0.7

Worked Example: RideShare Trips

Assumptions first (illustrative, stated):

 trip record:
   ids, geo endpoints, timestamps, fare, status, ratings refs
   ≈ 1 KB as a row (with overhead)
 
 20M trips/day, retained 5 years

Arithmetic:

 daily raw        = 20M × 1 KB              = 20 GB/day
 yearly           = 20 GB × 365             ≈ 7.3 TB/year
 5-year retention = 7.3 TB × 5              ≈ 36.5 TB raw
 + indexes ×1.5                             ≈ 55 TB
 + replication ×3                            ≈ 165 TB
 ÷ 0.7 max utilization                       ≈ 235 TB provisioned at steady state

One table, quarter-petabyte class when fully loaded — numbers like this decide whether trips stay in the transactional cluster forever or age out to object storage.

The Other Tables (fast pass)

DataRecordVolume/dayNotes
Users2 KBnegligible growth50M total ≈ 100 GB once
Location pings~200 B4B/day ≈ 800 GB/dayephemeral — TTL minutes; net storage tiny
Trip events stream~500 B~60M events ≈ 30 GB/dayKafka retention hours–days only

Location data is the lesson’s twist: highest write volume, near-zero stored bytes because expiry is a design decision made before sizing.

Growth Shape Matters

Linear accumulation vs compounding usage:

 linear (fixed users):          compounding (user growth 2x/yr):
 year 5 = 5 × year-1            year 5 ≈ 32 × year-1  ← 2^5
 
 storage plans that assume linearity die quietly in compounding products
 → re-run estimates quarterly against actuals

Retention Is an Architecture Decision

The cheapest storage is deleted storage:

 TIERED RETENTION (typical pattern)
 hot    0–90 days   Postgres/SSD     full query speed     ~0.5 TB tier
 warm   90d–2yr     compressed rows  occasional queries   ~10 TB tier
 cold   2yr+        object storage   compliance reads     pennies/TB/month
 
 same data, three price points — retention policy IS cost architecture

Legal/compliance floors set minimums (“financial records 7 years”); product need sets everything above the floor.

Interview Framing

Storage estimation scores through method visibility: state record size with a one-line justification (“ids + geo + fare ≈ 1KB”), run the multiplication aloud including all three multipliers, then use the result (“165TB replicated means trips archive to object storage after 12–18 months”). The follow-up almost always tests retention — have the tiered answer ready.

My Private Notes

Notes are auto-saved locally to this device.