Skip to content

Beginner bootcamp · Module 2

How servers scale: from one instance to a fleet

8 min reading · Sources

Outcome: Distinguish scale-up from scale-out and explain why request state must survive routing to another instance.

More
20px
Page details

Published date · Last edited:

Prerequisites: How a request travels the internet

Hypothetical scenario: Northwind adds a second application instance for a promotion. Half of signed-in visitors suddenly appear logged out. The database is healthy. The first instance kept session information only in its own memory, while the load balancer can now send requests to either instance.

Words to recognize

Process
Analogy: A workshop with its own working area.
Definition: A running program instance with execution state and an address space. Related topic
·
Thread
Analogy: A worker operating in the same workshop.
Definition: An execution sequence within a process that can share its memory. Related topic
·
Concurrency
Analogy: One cook switching among several simmering dishes.
Definition: Multiple tasks making progress during overlapping intervals. Related topic
·
Parallelism
Analogy: Several cooks working at the same time.
Definition: Multiple tasks executing simultaneously. Related topic
·
Stateless
Analogy: Any clerk can help because the shared record carries the context.
Definition: Request handling that does not require continuity in one instance's private session memory. Related topic
·
Load balancer
Analogy: A dispatcher choosing which available clerk serves each visitor.
Definition: A component distributing traffic across selected backends. Related topic

More machines do not automatically share a memory

A single kitchen can add a larger oven, or a restaurant can open another kitchen. Scale-up gives one instance more resources. Scale-out adds instances and a routing decision. Both cost money and introduce limits; neither determines where the authoritative data should live.

A process is a running program with its own address space. Threads execute within a process and commonly share that address space. Concurrency means work can be in progress at overlapping times; parallelism means work actually executes simultaneously. A service can handle concurrent waiting on one core without running every operation at once.

Move from a single box deliberately

The first useful separation may be application and database, so their resource needs can be managed independently. Adding a load balancer then lets several application instances serve requests. In AWS Application Load Balancer terminology, listeners receive traffic and target groups identify backends. Health checks guide routing, but an instance passing a shallow check can still fail a business operation.

Stateless request handling does not mean the whole system has no state. It means that another suitable application instance can continue a client interaction because required state has a shared authority or is carried in a validated request. A cookie can carry an opaque session identifier; the session contents can live in a shared store. A signed token is a different choice, with expiry and revocation trade-offs.

Routing must preserve the user interactionA load balancer routes to an application fleet; the fleet uses shared authoritative state rather than relying on one instance’s memory.Load balancerApp fleetShared state
A load balancer routes to an application fleet; the fleet uses shared authoritative state rather than relying on one instance’s memory.

Calculate survivor capacity

Assume the promotion peak is 900 requests per second. In this hypothetical workload, one instance has a tested sustainable capacity of 400 requests per second under the required latency target. Three instances nominally offer 3 × 400 = 1,200. If one fails, only 2 × 400 = 800 remains, below the 900 target.

To survive one failure in this model, solve (N − 1) × 400 ≥ 900. Therefore N − 1 ≥ 2.25, and the smallest whole N is 4. Four instances leave three survivors with 1,200 requests per second of assumed capacity. This is a planning derivation, not evidence that a particular server can serve 400 requests per second.

Find the next shared bottleneck

Hypothetical scenario: four application instances each open 100 database connections, but the database budget is 250. Potential demand is 4 × 100 = 400, exceeding the budget by 150. Scaling the application has moved contention downstream. Bound per-instance pools or add a deliberate pooling layer, and test database work separately.

Sticky routing can temporarily preserve local sessions, but losing the selected instance still loses that state. Shared sessions introduce another dependency that needs its own capacity and failure policy. Use scale-out when independent request work and survivor capacity justify it. Keep a smaller topology when demand fits and the operational cost of coordinating more components would exceed the benefit.

Make session and token choices explicit

A cookie is a browser storage and request mechanism, not a complete authentication design. An opaque session identifier can reference server-side state. A JSON Web Token can represent claims whose signature a service validates. Neither choice removes the need to check issuer, audience, expiry and the authorization appropriate to the operation. Token contents also need a privacy decision: a signed claim is not automatically secret.

Suppose a user is removed from a privileged role while an earlier token remains valid. The design must decide how quickly that removal takes effect. Short lifetimes, revocation checks and shared session lookup make different availability and freshness trades. The beginner lesson is to put the required state and validation rule on the drawing. Moving from local RAM to a shared store fixes one placement problem, but does not by itself make an authentication system correct.

Distinguish routing, scheduling and useful work

A reverse proxy receives requests on behalf of services. A load balancer distributes them among backends; one product can perform both roles. A forward proxy instead acts on behalf of the requesting client. This direction matters when deciding where credentials, connection ownership and failure reporting belong. A backend-for-frontend gateway can tailor responses to a client experience, but also owns aggregation deadlines and partial-result behavior.

Before adding another instance, name the constrained resource. CPU work, network waiting, database locks and connection slots need different responses. If each request waits on a slow dependency, more application workers may merely create more simultaneous waiting. If a worker needs a large private memory footprint, raising concurrency can exhaust memory before CPU becomes busy. Keep queueing bounded and measure useful completions. Instance count is an input to a design, while healthy throughput and survivor behavior are outcomes to verify. There is no universal user count at which a single server becomes incorrect; activity rate and per-operation work determine the relevant limit.

Step through the decision

This exercise runs entirely in your browser. All values are hypothetical inputs, not measured performance.

Text alternative: all steps

Use the following ordered steps to work through the same example without the interactive controls.

  1. One instance keeps session A locally. Its next request can be served only while that state is reachable.
  2. A second instance is added. Routing the next request there does not copy session A.
  3. Store session A under an opaque identifier in a shared authority and let both instances resolve it.
  4. Check survivor capacity and shared-store dependencies before claiming the fleet can tolerate a failure.

Check your decisions

Do three 400-request/second instances survive one failure at 900 requests/second?

No. Two survivors provide an assumed 800. The model needs four instances so three survive with 1,200.

Does stateless mean the application never writes data?

No. It means request continuity does not depend on one application instance’s private memory. Durable and session state still exist elsewhere.

Why can adding app servers make the database less healthy?

Every instance may add connections and concurrent queries. The shared database can saturate even when application CPU has spare capacity.

Go deeper

Decision log

Decision: separate routing from session authority and budget for survivors.

Limit: adding application capacity cannot remove a saturated shared dependency.

Next decision: decide which data needs memory, a durable database or object storage.