Chapter 6

Scaling & Elasticity

Vertical vs horizontal, load balancers, state.

Learning objectives

  • Distinguish vertical and horizontal scaling
  • Explain elasticity vs fixed capacity in cloud billing
  • Plan scaling triggers for Workshop Co. seasonal demand

Scaling vocabulary

TermMeaningExample
Vertical scale (scale up)Bigger single server — more RAM, CPUUpgrade VPS 4 GB → 8 GB
Horizontal scale (scale out)More servers sharing loadTwo web VMs behind load balancer
ElasticityAuto add/remove capacity by demandKubernetes HPA, cloud autoscaling groups
Fixed capacityPay for peak all yearWorkshop Co. Proxmox sized for December gift-class rush

Workshop Co. demand pattern

Booking traffic spikes:

  • Saturday 7–11 AM — class registration windows
  • September — fall semester launch
  • December — gift certificate promotions

Marcus sized Proxmox for September peak — elasticity would mean adding a second web VM only in September, but that requires load balancer + shared session store. For their scale, vertical headroom on one web VM is simpler.

Worked example — when to scale out

If response time exceeds 2 seconds for 15 minutes during booking:

  1. Short term: enable PHP opcache tuning, add RAM to VM 110 (vertical)
  2. Medium term: clone web VM, add Traefik load balancing (horizontal)
  3. Cloud elastic: move static assets to CDN — offload without new VMs
# Hypothetical monitoring alert — not magic autoscale
# Prometheus rule: p95_latency > 2s for 15m → page Marcus
# Manual: qm set 110 --memory 8192 && qm reboot 110
Elasticity costs

AWS autoscaling saves money for spiky unknown load. Predictable Saturday peaks favor right-sized fixed VPS — you are not paying per-minute if traffic is predictable.

Database scaling caution

PostgreSQL on VM 120 does not scale out trivially — read replicas, connection pooling (PgBouncer), or managed DB service are next steps. Workshop Co. stays single-node until connection count or disk IOPS forces change.

Premature scale-out

Two weak web servers plus load balancer add complexity before one properly sized VM is maxed. Measure first — Marcus logs Saturday CPU/RAM monthly.

Try it yourself

Choose vertical, horizontal, or CDN for each:

  1. Nextcloud slow serving 200 MB video previews
  2. PHP booking app CPU at 90% Saturday mornings
  3. Marketing images on homepage
Sample answers
  1. Vertical RAM/CPU on files VM or object storage offload (hybrid)
  2. Vertical first (more CPU); horizontal if sustained after tuning
  3. CDN — cache static images at edge, cheap elasticity

Check your understanding

  1. Is elasticity the same as horizontal scaling?
  2. Why might Workshop Co. avoid Kubernetes for 500 weekly users?
Answers
  1. Related but not identical — elasticity is automatic add/remove; horizontal scale can be manual permanent servers.
  2. Operational overhead exceeds benefit — Proxmox + one web VM matches team size and traffic.