Backend & Node.js · APIs, data and failure

What is the difference between horizontal and vertical scaling?

Easyscalingdistributed systemsarchitectureUpdated Oct 2026
Quiz this track

Short answer

Vertical scaling adds CPU, memory or disk to one machine. Horizontal scaling adds more machines or instances. Vertical is simpler but has a ceiling; horizontal is more resilient but requires stateless services, load balancing and shared state.

Vertical scaling is the fastest first step: a bigger database instance or more memory often solves a short-term bottleneck without code changes. The limit is cost and hardware size, and a single machine remains a single failure domain. Horizontal scaling spreads load across replicas and can survive a node loss.

What horizontal scaling requires

  • Stateless application instances or externalized session state
  • A load balancer or service discovery layer
  • A shared database, cache or queue that can handle the connection count
  • Idempotent operations and safe retries across instances
  • Distributed tracing and centralized logs to diagnose a fleet
  • A plan for database scaling, which is often the real bottleneck
js
const sessions = new Map();

app.post("/login", (req, res) => {
  sessions.set(req.body.id, req.body);
  res.json({ ok: true });
});
Local state prevents a second instance from serving the same user. Externalize it before scaling out.

Scaling the application tier is usually easier than scaling the database. Adding ten app instances can exhaust the connection pool or saturate the primary database. Read replicas, partitioning, caching and query optimization may be needed before more app replicas help.

Vertical scaling still matters for databases and stateful systems, where horizontal sharding adds significant complexity. A common path is to scale up first, then scale out the stateless tier, then address data partitioning when measurements justify it.

Autoscaling is not free. Cold starts, connection storms and fluctuating capacity can make an outage worse. Scale on a signal that reflects real load and keep headroom for bursts.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1Why does horizontal scaling require stateless services?
  2. 2What is usually the bottleneck after adding app replicas?
  3. 3When is vertical scaling the better choice?
  4. 4What signals should drive autoscaling?

Say it in the interview

Vertical scaling makes one machine bigger, while horizontal scaling adds more machines. Vertical is simpler and often the right first move, especially for databases, but it has a ceiling and a single point of failure. Horizontal scaling gives resilience and more capacity, but it requires stateless services, load balancing and shared state. In practice the database becomes the bottleneck, so I measure before adding more application replicas.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Backend & Node.js mock interview and get scored feedback on depth, clarity and confidence.