Scaling/

Vertical Scaling

Lesson overview

Vertical Scaling

Vertical scaling: scaling up a single machine.

Vertical scaling means increasing the capacity of a single machine by upgrading its resources. You upgrade things like: More CPU cores Faster CPU More RAM Faster disk (SSD, NVMe) Better network card

Vertical Scaling

CPU BottleNeck4-core machine CPU capacity = 4 × 1000 = 4000 ms/sec Each request = 20 ms CPU Max RPS = 4000 / 20 = 200 RPS Upgrade to: 8-core machine New CPU capacity = 8 × 1000 = 8000 ms/sec New max RPS = 8000 / 20 = 400 RPS

I/O bottleneck happens when requests wait on Disk latency = 10 ms per read After upgrade : Disk latency = 1 ms per read If each request does 3 disk reads: Before: 30 ms disk time After: 3 ms disk time

Memory bottleneck happens when: RAM is full System starts swapping Cache gets evicted too often Vertical scaling solutions: Add more RAM Use bigger memory-optimized machine Example: Server has 8 GB RAM Cache needs 12 GB

Network bottleneck happens when: NIC is saturated Bandwidth limit is hit Packet queues build up Vertical scaling solutions: Upgrade to higher bandwidth NIC Use instance types with better network throughput Example: Before: 1 Gbps NIC Traffic needs = 3 Gbps

DB bottleneck happens due to: CPU on DB Disk I/O Memory for buffer cache Vertical scaling solutions: Bigger DB instance More RAM for DB cache Faster storage Example: Before: DB cache hit rate = 70% Many disk reads After adding more RAM: DB cache hit rate = 95%

LIMITATIONS Vertical scaling has hard limits: Max CPU cores per machine Max RAM per machine Hardware becomes very expensive Single point of failure Downtime during upgrades Example: You can go from: 4 cores → 8 → 16 → 32 But you cannot go to infinite cores.

8 vCPU 32 GB RAM 128 GB DISK

16 vCPU 64 GB RAM 256 GB DISK

32 vCPU 64 GB RAM 512 GB DISK

Loading Vertical Scaling