FullStack AI Hub
Studio
System Design · 02. Scaling
11 min
11 steps
Beginner

Vertical vs Horizontal Scaling

Compare bigger hardware against elastic fleets through night dips, session state, and flash sales.

System Design02. ScalingLesson 1 of 5
11 minBeginner11 steps

Vertical vs Horizontal Scaling

Compare bigger hardware against elastic fleets through night dips, session state, and flash sales.

TRAFFIC
900/s
CPU LOAD
45%
P95 LATENCY
38 ms
MONTHLY COST
$140/mo
6,000 onlineApp (4 vCPU)45%8 GB RAMPrimary DB32%
user request
peak surge
session / DB write
dropped / 503
In This LessonStep 1 of 11
What You Will Master
  • ✓Recognize where vertical scaling shines and where hardware ceilings and reboot downtime bite
  • ✓Externalize session state into Redis so horizontal fleets scale cleanly behind a load balancer
  • ✓Match fleet capacity to diurnal night dips and flash peaks without paying for idle iron
  • ✓Combine horizontal stateless compute with pragmatically scaled stateful databases

Architectural Trade-Off Comparison Matrix

PatternBest ForKey Trade-Off
Vertical Scaling (Scale Up)Early-stage apps, primary SQL databases, and single-node workloads avoiding distributed complexityHard hardware ceiling, steep non-linear cost curve, reboot downtime, and single-point-of-failure risk
Horizontal Scaling (Scale Out)Stateless web/API tiers, high availability (N+1 fault tolerance), and elastic cloud cost controlRequires a load balancer, externalized session state, and distributed observability
Externalized Session Store (Redis)Keeping application nodes interchangeable so any server can handle any user requestAdds a ~1–2 ms network hop and makes Redis availability critical for login sessions
Hybrid Tiered ScalingProduction architectures: scale stateless app fleets horizontally and primary DBs vertically firstDemands clear boundaries between stateless compute and stateful persistence tiers

Step-by-Step Architectural Breakdown (11 Steps)

Full architectural walkthrough transcript and state transitions for Vertical vs Horizontal Scaling.

STEP 01 · SETUPJump to step →

Start simple: one modest server

On launch day, a single **4-vCPU / 8 GB** application server handles 900 requests/sec comfortably with sub-40 ms latency and zero distributed moving parts.

Starting on one box is not a mistake—it minimizes network hops, eliminates load-balancer ops, and lets you ship product features fast until real growth arrives.

idea:Never pay the distributed-systems tax on day one—scale architecture only when traffic, availability, or data size demands it.

Single-Node BaselineVertical Headroom
STEP 02 · SOLUTIONJump to step →

Scale Up (Vertical): buy a bigger machine

Traffic triples to **2,700 req/s** and the 4-vCPU server melts. Your fastest move is **Vertical Scaling (Scale Up)**: swap the box for a beefy **32-vCPU / 128 GB** instance.

Not a single line of application code changes. Everything still talks over fast local memory, CPU drops back to 38%, and P95 latency stays razor-sharp at 42 ms.

good:Vertical scaling gives instant relief with zero code rewrites—making it the best first move when you still have cloud instance headroom.

Vertical ScalingScale UpHardware Headroom
STEP 03 · PROBLEMJump to step →

The vertical ceiling, reboot tax, and SPOF

A Black Friday surge hits **9,500 req/s**—past the biggest 96-vCPU machine your cloud offers. Worse, every vertical resize requires stopping and rebooting the instance, causing minutes of hard downtime.

Pricing also goes super-linear at the top tier: a 128-vCPU monster costs far more per core than commodity 8-vCPU boxes, and a single motherboard fault takes down 100% of your users.

watch:Vertical scaling has three hard walls: maximum machine size, resize reboot downtime, and zero fault tolerance.

Hardware CeilingResize DowntimeSuper-Linear Cost
STEP 04 · TRADE-OFFJump to step →

Paying for peak hardware during 3 AM night dips

Traffic is never flat—consumer apps routinely see **5×–10× swings** between 8 PM peak and 3 AM quiet hours. A single vertically scaled 96-vCPU server must stay provisioned for peak 24/7 because you cannot shrink it without rebooting.

At 3 AM, you are paying **$6,800/mo** while 93% of your giant machine sits completely idle.

watch:Fixed vertical sizing forces you to pay peak-hour rent every night of the year—elastic horizontal fleets let you turn off surplus nodes.

Diurnal Traffic CurveIdle Capacity WasteElasticity
STEP 05 · SOLUTIONJump to step →

Scale Out (Horizontal): add commodity servers

With **Horizontal Scaling (Scale Out)**, we replace the giant single box with a **Load Balancer** feeding a fleet of smaller, cheaper **16-vCPU commodity servers** (`App 1`, `App 2`, `App 3`, `App 4`).

Now capacity scales linearly—need more headroom for Black Friday? Add 4 more nodes online with zero reboots. When 3 AM arrives, drain and terminate surplus nodes automatically.

good:Horizontal scaling trades a small front-door load balancer for near-infinite ceiling, rolling deploys, and elastic pay-for-what-you-use cost.

Horizontal ScalingScale OutCommodity Fleet
STEP 06 · PROBLEMJump to step →

The hidden trap: in-memory local sessions break

Five minutes after going horizontal, shoppers report getting randomly logged out and losing their shopping carts! Why? Because the old single-server app stored login sessions in **local RAM**.

Alice logs in on **App 1** (which saves `session:alice` in its local memory), then her very next click lands on **App 2**—which has never heard of Alice and bounces her with `401 Unauthorized`.

watch:Sticky sessions on the load balancer are a brittle bandage: if App 1 crashes or scales down, every pinned user still loses their session.

Stateful Compute TrapSticky SessionsSession Affinity
STEP 07 · SOLUTIONJump to step →

Externalize state into Redis for true statelessness

To make horizontal scaling effortless, move all user sessions and carts out of local app RAM into a shared **Redis Session Store** (or signed stateless JWTs).

Now **App 1, App 2, and App 3** are completely interchangeable cattle—not pets. Any server can fulfill any request, and killing or autoscaling nodes drops **0 user sessions**.

idea:Rule of horizontal compute: keep app processes strictly stateless; push all durable and ephemeral state into specialized stores (Redis, S3, DB).

Stateless ArchitectureExternalized Session StoreCattle vs Pets
STEP 08 · TECHNIQUEJump to step →

Elastic scale-in saves 65% overnight

Now revisit the **3 AM night dip** with your stateless horizontal fleet. Instead of idling a $6,800 monster machine, your orchestrator gracefully drains and terminates 4 surplus nodes, leaving a lean **2-node HA pair**.

You keep **N+1 high availability** (two nodes across two availability zones) while slashing overnight compute spend by over **65%**.

good:Never scale down to 1 instance in production—keep a minimum floor of 2 nodes across 2 AZs so a single host fault never wakes up on-call.

Elastic Scale-InMinimum HA Floor (N=2)Cloud Cost Efficiency
STEP 09 · PROBLEMJump to step →

Scaling compute shifts pressure onto the database

Stateless app servers scale horizontally in minutes—which means your **Single Primary Database** quickly becomes the new bottleneck! Every new app node opens more SQL connections and fires more queries.

Unlike stateless compute, scaling a database **horizontally** (sharding) breaks cross-table JOINs and multi-row ACID transactions—so teams almost always scale databases **vertically first**, then add caching and read replicas.

watch:Doubling your app fleet without connection pooling, caching, or DB headroom can actually crash your database faster.

Bottleneck ShiftingStateful Scaling FrictionConnection Fan-In
STEP 10 · SOLUTIONJump to step →

Real-world sweet spot: Hybrid Scaling by tier

Senior architects rarely choose "pure vertical" or "pure horizontal". Instead, you **scale stateless tiers horizontally** (`App 1–3` behind an LB) while scaling the **Primary DB vertically** and shielding it with **Redis + Read Replicas**.

That hybrid design keeps ACID transactions simple on one beefy Primary writer, offloads 80%+ of reads to cache/replicas, and retains instant horizontal elasticity at the front.

idea:Vertical scaling is not "bad"—using a beefy 64-vCPU Postgres primary with Redis and read replicas often avoids premature sharding for years.

Hybrid ScalingTier-Appropriate ScalingRead Shielding
STEP 11 · RECAPJump to step →

Vertical vs Horizontal Scaling recap

Use **Vertical Scaling** to buy fast, zero-complexity runway early and to keep single-leader SQL databases simple. Use **Horizontal Scaling** for stateless compute tiers that need elastic cost savings, rolling deploys, and N+1 survival.

Remember the golden prerequisite: horizontal fleets stay clean only when you **externalize sessions and files** out of local node RAM and disk.

good:Interview rule of thumb: scale stateless services horizontally (min 2 AZs), scale relational writes vertically + read replicas until you genuinely outgrow the largest node.

Scaling Decision MatrixHybrid Cloud Blueprint

Related Production Deep-Dives & Simulators

Included In Free Course
Free · Verifiable Credential

FS-102LLM Systems Foundations

Build a connected mental model from tokens through retrieval evaluation security and operations.

24 concepts~18h self-paced
Start Free Course
Weekly Engineering Dispatch

Get the weekly systems teardown

One technical note per week covering inference bottlenecks, retrieval harnesses, and commit-pinned teardowns.