tezvyn:

When horizontal scaling is the wrong fix

AI-drafted, machine-checkedSource: interviewadvanced
WHAT IT TESTS

Scaling judgment.

OUTLINE

adding instances fails when the bottleneck is a shared resource like one database, a lock, or a queue, so more instances just add contention; investigate where time is actually spent.

WHAT THIS TESTS: Whether you understand the limits of horizontal scaling and can spot when adding instances masks rather than solves a problem.

WHEN IT IS WRONG: Horizontal scaling helps only when the workload is parallelizable and the stateless tier you are scaling is the actual bottleneck. It is the wrong fix when the real constraint lies in a shared resource that every instance contends for: a single primary database, a distributed lock, a rate-limited third-party API, a shared cache, or a serial section of the code. Adding more application instances then increases pressure on that shared resource, more open database connections, more lock contention, more contention on the hot row, so latency can actually worsen. The universal scalability law and Amdahl's law formalize this: contention and coordination overhead eventually flatten or reverse the gains from adding nodes.

HOW TO INVESTIGATE: Profile and trace to find where requests actually spend time. Distributed tracing shows whether the latency is in your service or waiting on a downstream call. Database and dependency metrics reveal connection saturation, lock waits, or throttling. Look for a single resource whose utilization rises as you add instances.

COMMON WRONG ANSWERS: Assuming more instances always help, ignoring shared-resource contention, or scaling out without measuring where time is spent.

LIKELY FOLLOW-UPS: How does connection pooling interact with this? When do you shard or add read replicas instead? What is the universal scalability law? How do you find the serial fraction?

ONE CONCRETE EXAMPLE: An API tier hits its limit, so you double the instance count. Latency does not improve and error rates rise. Tracing shows every request waits on writes to one primary database whose connection pool is now exhausted by the doubled fleet, and lock waits on a hot counter row have increased. Horizontal scaling masked a database bottleneck and amplified contention. The right fix is reducing per-request database work, adding read replicas, sharding the hot data, or removing the lock, not adding more stateless instances that all funnel into the same constrained primary.

Read the original → learn.microsoft.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.