Skip to main content

Horizontal vs Vertical Scaling — More Machines vs Bigger Machine

Vertical scaling = bigger machine. Horizontal scaling = more machines. Horizontal requires stateless processes.

When to use vertical

  • Fast fix without architectural changes
  • Stateful workloads (DB primary, license-limited software)

When to use horizontal

  • Web/API tiers needing elasticity
  • Traffic spikes requiring dynamic instance scaling

Tradeoffs

  • Vertical has a hardware ceiling and creates a single point of failure
  • Horizontal requires load balancing and externalized session/state
// Stateless HTTP handler — session stored in Redis, not in-process
func HandleRequest(w http.ResponseWriter, r *http.Request) {
sessionID := r.Cookie("session_id")

// State lives in Redis, not in memory
userData, err := redisClient.Get(ctx, sessionID.Value).Result()
if err != nil {
http.Error(w, "session not found", http.StatusUnauthorized)
return
}

w.Write([]byte("Hello, " + userData))
}

Gotcha: Horizontal scaling is about removing state from processes, not just adding machines. If your process holds in-memory state, adding instances creates split-brain.