System Design Reference

Click a section to expand

Character Encoding & String Sizes
Quick: English text ~1 byte/char (UTF-8). International ~2-3 bytes/char. Todo label ~50-100 bytes.

UTF-8 Encoding (Most Common)

Character TypeBytesExamples
ASCII1a-z, A-Z, 0-9, punctuation
Latin Extended2é, ñ, ü, ø
CJK3中, 日, 한
Emoji4😀, 🎉, 🚀

In-Memory String Representation

Different from disk! Languages decode to their own internal format.

LanguageInternal FormatBytes/Char
Python 3Flexible (Latin-1/UCS-2/UCS-4)1, 2, or 4
JavaScriptUTF-162 or 4
JavaUTF-16 (Latin-1 since Java 9)1 or 2
Go / RustUTF-81-4

String Size Estimates

Content TypeCharsBytes (UTF-8)
Todo label20-80~50-100
Tweet280~280-560
Email subject50-100~50-150
Username3-30~3-30
URL50-200~50-200
Paragraph~500~500-800
Storage Units & Data Sizes

Powers of 2

PowerExactApproxName
2^101,024~1 thousand1 KB
2^201,048,576~1 million1 MB
2^301,073,741,824~1 billion1 GB
2^401.1 trillion~1 trillion1 TB

Common Data Type Sizes

TypeBytesRange
boolean1true/false
int8 / byte1-128 to 127
int16 / short2-32K to 32K
int32 / int4-2.1B to 2.1B
int64 / long8±9.2 quintillion
float324~7 decimal digits
float64 / double8~15 decimal digits
UUID16128-bit identifier
Latency Numbers
Mental model: Memory = nanoseconds | SSD = microseconds | Network = milliseconds

Latency Reference

OperationTimeNotes
L1 cache~1 ns
L2 cache~4 ns
L3 cache~12 ns
RAM access~100 nsMain memory
SSD random read~100 µsNVMe: ~20 µs
HDD seek~10 msMechanical
Same datacenter RTT~0.5 msWithin rack: ~0.1 ms
Cross-region RTT~50-150 msUS East↔West: ~70 ms
Transatlantic RTT~80-120 msUS↔Europe

1 ms = 1,000 µs = 1,000,000 ns

Throughput & QPS

Network Speeds

ConnectionSpeed
1 Gbps125 MB/s
10 Gbps1.25 GB/s
SSD write (SATA)~500 MB/s
NVMe write~3 GB/s

QPS Estimates

SystemQPSNotes
Single web server1K-10KDepends on complexity
Redis (single)100K+In-memory
MySQL/Postgres5K-20KSimple indexed queries

Time Conversions

PeriodSeconds1K QPS =
1 day86,40086M requests
1 month~2.6M2.6B requests
1 year~31.5M31.5B requests

Handy: 1 day ≈ 100K seconds, 1 year ≈ 30M seconds

Common Object Sizes

User/Account Data

FieldSize
User ID8-16 bytes
Username~20 bytes
Email~30 bytes
Password hash (bcrypt)60 bytes
Basic user row~200-500 bytes

Media Sizes

TypeSize
Avatar (100x100)5-20 KB
Photo (web, 1080p)100-500 KB
Photo (original)2-10 MB
Video (1 min, 720p)~50-100 MB
Video (1 min, 4K)~300-500 MB
Audio (1 min, MP3)~1 MB
Scaling Rules of Thumb

Capacity Planning

Storage = users × data_per_user × retention_days
QPS_peak = QPS_avg × 2-3 (normal) or × 10 (viral)

Common Ratios

MetricTypical
Read:Write10:1 to 100:1
DAU:MAU10-30%
Peak:Average traffic2-3x
Cache hit rate (good)95-99%

1 Million Users

If each user has...Total
500 bytes (basic profile)~500 MB
1 KB (profile + settings)~1 GB
1 MB (with avatar)~1 TB
10 MB (with photos)~10 TB