SystemTutor
About
Sign in
Loading course documentation…
SystemTutor

COURSES

  • Data Structures & Algorithms
  • CSS MasterclassNew course
  • System DesignNew course

PRACTICE

  • Algorithm practice
  • CSS practice

LEGAL

  • Privacy Policy
  • Terms of Service
  • About

© 2026 SystemTutor. All rights reserved.

Built with 🫶 by Shatlyk

System design
Application FoundationsScaling and Traffic DistributionObservability and OperationsThe System Design Mindset From deployment to a profile request
Application architecture

Scaling and Traffic Distribution

Handle growing traffic with load balancing, horizontal scaling, and caching.

Lesson goal

Locate a capacity bottleneck and choose between a larger server, more application instances, or a cache.

Before you begin — Application Foundations.

Suppose more people start opening their profiles at the same time. The application runs code for every request, and the database supplies each profile. Which component runs out of capacity first determines which change will help.

Scale the component doing the work

Vertical scaling gives one machine more resources, such as CPU or memory. If the application server spends most of its time doing computation, more CPU can let it handle more requests. The capacity is still concentrated on that machine.

Horizontal scaling adds instances that share the work. Two application servers can handle requests concurrently if either can access the necessary data. If every request still goes to one overloaded database, adding application instances leaves that shared limit in place.

Scaling up gives one server more capacity. Scaling out places several servers behind a load balancer.

Route requests to healthy instances

A load balancer chooses an application instance for each incoming request or connection. With equally sized servers doing similar work, round robin sends traffic to each in turn. Least connections favors the server with fewer active connections. IP hashing uses the client's address to select a server, which can keep a client's requests together while the server pool remains stable.

When configured with health checks, the load balancer removes an unresponsive instance from rotation once it detects the failure. The remaining instances now share its work. Whether users experience an outage depends in part on how much spare capacity those instances have.

Avoid a repeated database read

A cache holds a reusable result. Suppose the same profile is requested repeatedly. The first lookup misses the cache, so the application reads the profile from storage and can save a copy. A later lookup can use that copy, reducing the work sent to the database.

Clients reach the application, which can reuse data in its memory cache or query the database.

The author might edit the profile between those two reads. Invalidation removes an entry after a change, and a time to live (TTL) limits how long the cache can reuse the entry before it expires. The design needs a rule for how long users may see an old display name. You will examine what happens when updates and reads overlap in Caching and Content Delivery in Practice.

Check your understanding

Both application servers have spare CPU. Database reads are at capacity, and many requests ask for the same profiles. What would you expect from adding a third application server?

Compare your reasoning

Each profile lookup would still need a database read. Measure how often the same profiles are requested and decide how fresh their values need to be. A cache could remove repeated reads if those values can safely be reused.

Key Takeaways

  • Vertical scaling adds capacity to one machine. Horizontal scaling spreads work across instances.
  • A load balancer routes traffic. The healthy instances need enough capacity to absorb a failed instance's share.
  • A cache reduces repeated work on hits. Choose how to handle an edit before reusing a cached profile.

How is this lesson?

Previous lessonApplication FoundationsNext lessonObservability and Operations
Edit on GitHubReport on GitHub
On this page
%

On this page

Scale the component doing the workRoute requests to healthy instancesAvoid a repeated database readCheck your understandingKey Takeaways