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
| Term | Meaning | Example |
|---|---|---|
| Vertical scale (scale up) | Bigger single server — more RAM, CPU | Upgrade VPS 4 GB → 8 GB |
| Horizontal scale (scale out) | More servers sharing load | Two web VMs behind load balancer |
| Elasticity | Auto add/remove capacity by demand | Kubernetes HPA, cloud autoscaling groups |
| Fixed capacity | Pay for peak all year | Workshop 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:
- Short term: enable PHP opcache tuning, add RAM to VM 110 (vertical)
- Medium term: clone web VM, add Traefik load balancing (horizontal)
- 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
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.
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:
- Nextcloud slow serving 200 MB video previews
- PHP booking app CPU at 90% Saturday mornings
- Marketing images on homepage
Sample answers
- Vertical RAM/CPU on files VM or object storage offload (hybrid)
- Vertical first (more CPU); horizontal if sustained after tuning
- CDN — cache static images at edge, cheap elasticity
Check your understanding
- Is elasticity the same as horizontal scaling?
- Why might Workshop Co. avoid Kubernetes for 500 weekly users?
Answers
- Related but not identical — elasticity is automatic add/remove; horizontal scale can be manual permanent servers.
- Operational overhead exceeds benefit — Proxmox + one web VM matches team size and traffic.