05 / 25 · Traffic and capacity

Horizontal scaling

Horizontal scaling adds more machines or application copies. Work must be shareable between them. It differs from auto scaling: horizontal describes the direction of growth; automatic describes how the decision is made.

What you will practise

  • Separate scaling direction from automation
  • identify serial work
  • calculate scaling efficiency

Before you start: Replica, throughput and shared state.

About 4 minutes · offline-generated English female narration · captions included. Diagrams are conceptual; timings are illustrative.

Download MP4Captions

Listen without the videoDownload audio

The same pre-recorded voice as the video. Starting audio pauses the video, and starting the video pauses audio.

Chapters and full transcript

Let us understand horizontal scaling. A teacher asks three helpers to check homework instead of giving one helper a faster pen. This helps if papers can be divided. It does not help much if every paper must wait for one locked answer book. Shared resources and coordination decide whether more helpers actually increase throughput. Horizontal scaling adds more machines or application copies. Work must be shareable between them. It differs from auto scaling: horizontal describes the direction of growth; automatic describes how the decision is made.

Follow the normal path. One application serves event pages. Its safe measured capacity is finite, and a restart can interrupt every request reaching that copy. Deploy the same application on another machine or process. Horizontal scaling adds peers rather than increasing resources inside the original machine. SeatSpot can run several stateless event-page replicas during a sale. A user may reach a different copy on the next request, so login state, uploaded files and reservations cannot silently live only in one replica memory.

Now change one condition. Routing sends requests to ready replicas. Balance according to workload characteristics; more boxes are useful only when requests can reach them. A common misunderstanding is this: More app copies automatically scale database writes. The write owner, locks and connection limits can still constrain throughput. Think about this. Four copies reach 250 requests/second when one reaches 100. Did capacity grow four times? Pause the video and make your prediction. No. The measured efficiency is 62.5% of the ideal 400. Investigate the shared bottleneck before adding more replicas.

Let us reason with a concrete example. One replica safely serves 100 requests/second. A load test with four replicas reaches only 250. Ideal linear scaling would suggest 400, but the measured efficiency is 250/400 = 62.5%. This number describes the experiment, not a universal law. Investigate database locking, shared CPU, connection limits and the serial part before adding another four replicas. Re-test after each change. These figures are teaching examples, not production guarantees.

Turn the idea into a design decision. Both replicas use the same appropriate storage for files, sessions or records. A file written only to Replica A will not magically appear on Replica B. If every request waits on one locked database operation, extra applications may add waiting instead of throughput. Trace and load-test the complete path. When you try the practice task, look for this result. A gap from ideal scaling is a diagnostic clue, not proof which dependency is slow.

Check your understanding. Compare throughput and tail latency before and after scaling. Also remove one replica to check that remaining copies serve users correctly with available capacity. Here is a challenge. An upload is saved to App A local disk. The next download request reaches App B. Propose a fix. Pause before the answer. Store the file in a shared durable object store and keep metadata/access rules in an authoritative store. Stream or redirect authorized downloads from that shared location. Do not depend on sticky sessions for durability. For an interview, discuss state, job ownership, database limits and real load tests. Say what you would measure, not only which tool you would buy.

Start with an everyday picture

A teacher asks three helpers to check homework instead of giving one helper a faster pen. This helps if papers can be divided. It does not help much if every paper must wait for one locked answer book. Shared resources and coordination decide whether more helpers actually increase throughput.

Why SeatSpot needs this

SeatSpot can run several stateless event-page replicas during a sale. A user may reach a different copy on the next request, so login state, uploaded files and reservations cannot silently live only in one replica memory.

Trace one step at a time

Move through the diagram at your pace. Teal paths are active; unavailable components are labelled.

VisitorsRouterReplica AReplica BShared state

Step 1 of 6 · One replica

Start with one copy

One application serves event pages. Its safe measured capacity is finite, and a restart can interrupt every request reaching that copy.

Read all six mechanism steps
  1. Start with one copy

    One application serves event pages. Its safe measured capacity is finite, and a restart can interrupt every request reaching that copy.

  2. Add another copy

    Deploy the same application on another machine or process. Horizontal scaling adds peers rather than increasing resources inside the original machine.

  3. Share incoming work

    Routing sends requests to ready replicas. Balance according to workload characteristics; more boxes are useful only when requests can reach them.

  4. Move durable state

    Both replicas use the same appropriate storage for files, sessions or records. A file written only to Replica A will not magically appear on Replica B.

  5. Find serial work

    If every request waits on one locked database operation, extra applications may add waiting instead of throughput. Trace and load-test the complete path.

  6. Test the gain

    Compare throughput and tail latency before and after scaling. Also remove one replica to check that remaining copies serve users correctly with available capacity.

Pause and make a prediction

Four copies reach 250 requests/second when one reaches 100. Did capacity grow four times?

Answer aloud or write your reasoning in the lesson notes before revealing the explanation.

Correct a common misunderstanding

Claim to question: More app copies automatically scale database writes.

Better explanation: The write owner, locks and connection limits can still constrain throughput.

Compare ideal and measured growth

A paper or whiteboard task. No cloud account or paid infrastructure is required.

  1. Write the measured single-copy throughput.
  2. Multiply by four for the ideal reference.
  3. Compare the real result and name three shared constraints.

Check what you can explain

This is your self-check, not an automated grade. Try again without the diagram tomorrow.

0 of 3 goals checked. Choose one remaining idea to practise next.

These checkboxes reset when you leave. Use your saved lesson notes and completion marker to record lasting progress.

Teach it back

Without looking, explain what this component changes, what it does not solve and what happens if it fails. Use the animation to check your explanation, then switch to Engineering.

Try it before viewing the solution

An upload is saved to App A local disk. The next download request reaches App B. Propose a fix.

Check one key idea

Horizontal scaling means:

Your explanation and interview notes

Saved only in this browser when storage is available. Export a backup from the course page before clearing browser data or moving devices.

Loading your local notes…

Official references and next reading

The explanation, fictional examples and animations are original teaching material. Vendor behavior depends on the specific product/version; use its documentation before deploying.