Servers and Deployment

3.Swapping Actors Without Stopping the Show

A

In this chapter

We'll learn where software actually runs — servers and cloud servers, web servers and application servers, what happens when an app starts — and how a new version replaces the old one without fans noticing, explained as a theatre's stage, front door and cast changes.

12–14 min

The Problem in Real Life

Anna asks John to show her what's behind the deploy button. He opens the production dashboard: four small boxes, each labelled app-1 to app-4, each with a green dot, sitting behind one load balancer (Act 14).

"These are our servers," he says. "When you deploy, the new version doesn't appear by magic. It has to be put onto each of these, started, checked, and given traffic — while fans are still buying tickets. Let's see how that works without anyone noticing."

A

I've been deploying to four computers I've never seen.

Anna

"It's On the Internet Somewhere" vs. Knowing What Runs Where

Code needs a computer

"The cloud" is still somebody's computer. Your app needs one to run on.

Users don't stop for deploys

Fans keep buying while a new version is installed. Deploys must not interrupt them.

Different jobs, different software

Answering web requests, running your code and serving files are separate jobs.

Servers, Application Start-up and Deployment

The theatre analogy, continued: a show needs a building (the server), a front door with ushers who greet people and send them to the right seat (the web server), the actors who actually perform (the application server running your code), and a way to swap actors between performances without cancelling the show (deployment).

  • Server — the building: a server is a computer that runs software for other computers (Act 03). It has CPU, memory, disk and a network connection, usually runs Linux (Act 05), and has no screen or keyboard — you reach it over the network (SSH, Act 06).
  • Cloud server — renting the building: instead of buying physical machines, most companies rent cloud servers (virtual machines) from providers like AWS, Google Cloud or Azure, by the hour, created in minutes. Act 20 covers the cloud properly.
  • Web server — the front door and ushers: a web server (like Nginx) is very good at handling huge numbers of connections, HTTPS, and sending static files like images, CSS and JavaScript quickly. It passes requests that need your code on to the application server.
  • Application server — the actors: the application server is the program running your code: BlueTicket's Node.js app, listening on a port (Act 11) like 3000. It handles the logic: checking seats, taking payments, talking to the database.
  • Application start-up — getting into costume: when the app starts, it reads its configuration (and checks it — chapter two), connects to the database and Redis, warms up, starts listening on its port, and then reports healthy on a health check URL like /health. Only after that should it receive real traffic.
  • Deployment — putting the new version into service: a deployment puts a new artifact onto the servers and switches traffic to it. Doing all four servers at once means a moment where nothing works. So teams use safer strategies.
Table — Web server vs. application server
FeatureWeb server (e.g. Nginx)Application server (BlueTicket's Node.js app)
Theatre versionFront door and ushersThe actors
Good atMany connections, HTTPS, static filesYour business logic
Example jobSend the seat-map imageHold a seat, take a payment
Runs your code?NoYes
Table — Deployment strategies
StrategyHowProsCons
All at onceReplace every server togetherSimpleDowntime; everything breaks together
RollingOne server at a time, with health checksNo downtime; stops if unhealthyOld and new run side by side for a while
Blue-greenFull new set, then switch trafficInstant switch and switch-backDouble the servers during the switch

A rolling deployment across four servers

Load balancer

spreads fans across healthy servers

one server out at a time

app-1

v2.7.1 ✓ healthy

app-2

updating...

app-3

v2.6.0, serving

app-4

v2.6.0, serving

A health check endpoint
app.get("/health", async (req, res) => {
const dbOk = await database.ping();
const redisOk = await redis.ping();
if (dbOk && redisOk) {
res.status(200).json({ status: "ok", version: "2.7.1" });
} else {
res.status(503).json({ status: "unhealthy" }); // load balancer stops sending traffic
}
});

Rolling deployment — swapping actors one at a time: take app-1 out of the load balancer, install v2.7.1, start it, wait for its health check to pass, put it back. Then app-2, app-3, app-4. At every moment, at least three servers are serving fans. If the new version fails its health check, the rollout stops automatically. This is what BlueTicket uses.

Blue-green deployment — a second full cast waiting in the wings: run a complete second set of servers ("green") with the new version next to the live set ("blue"). Test green, then switch the load balancer to it in one move. If something's wrong, switch back instantly. It costs double the servers during the switch, but rolling back is a single flick.

Watching v2.7.1 roll out: the next morning, Anna watches the dashboard: app-1 turns yellow (updating), then green; then app-2... The start-up check passes on each one, because production now has its own correct settings. Four minutes later, all four run v2.7.1. Not a single failed payment.

Key Takeaway

Code runs on servers — usually rented cloud servers. A web server (like Nginx) is the front door, handling connections, HTTPS and static files; the application server runs your code. On start-up, an app reads and checks its configuration, connects to its services and reports healthy before getting traffic. Deployments put a new version into service safely: rolling (one server at a time) or blue-green (a full second set, then one switch).

Why This Matters

Even if a platform hides the servers from you, knowing what's underneath — web server, application server, health checks, rolling deploys — lets you understand deployment logs, read dashboards and reason about why a deploy is slow or stuck. And zero-downtime deployment is what makes it safe to release often.

Fans reach those four servers by typing blueticket.example. But how does a name become those four machines, safely over HTTPS? John shows Anna the front of the house: domains, certificates and the reverse proxy.