launchroom
Projects and services

Scaling

Run several replicas of a service across your servers, set CPU and memory per replica and roll out new versions without downtime.

Scaling sets how many copies (replicas) of a service run, how much CPU and memory each one gets and which servers they run on. launchroom places the replicas and spreads them across servers when you have more than one, so one server going down leaves the rest serving. On every deploy it replaces them one at a time so your app keeps answering.

Scaling settings for web after an unsaved change: 3 replicas spread over control plane (1) and server-2 (2), server cards with CPU and memory headroom, a replica counter at 3 and a Save for next deploy bar.Scaling settings for web after an unsaved change: 3 replicas spread over control plane (1) and server-2 (2), server cards with CPU and memory headroom, a replica counter at 3 and a Save for next deploy bar.
Pick how many replicas run and where. launchroom checks they fit first.

The scaling page

Open the service's Settings → Scaling. The page starts with the current state, for example "3 replicas on control plane, server-2", then one card per server that runs apps, with the replicas on it and its CPU and memory against capacity. Each change is checked against the scheduler as you type. The cards show where the replicas would go (new ones dashed, removed ones hollow) or why they wouldn't fit.

Scaling settings belong to one environment, so production can run three replicas while staging runs one. Save is a split button: Save and apply (the default) restarts the service now with the existing image and applies whatever else is staged in the environment. Save for later keeps the change staged until the next deploy or until you apply it. Neither rebuilds. Compare & promote treats scaling as environment-specific and copies it to another environment only when you check it.

Replicas

How many sets the number of copies, from 0 to 64. Requests to the service's domains are shared between the replicas.

  • One replica: a deploy or a server restart interrupts it briefly.
  • Two or more: deploys roll through them one at a time (below) and a server going down leaves the others serving.
  • Zero: the service is stopped. Nothing runs until you scale it up again.

Before you add a second replica

Some apps keep state inside the container. While you set more than one replica, the scaling page warns about what would break:

  • Laravel sessions or cache stored in files, or with no session driver set (Laravel 10 defaults to files). Set SESSION_DRIVER and CACHE_STORE to database or redis.
  • A worker running schedule:work, which would run every scheduled task once per replica.
  • Next.js ISR and revalidateTag, which need a shared cache handler across replicas.

To find a single setting, type it into the search field at the top of the settings sidebar, for example "replicas".

Scaling settings of the web service scrolled to the Replicas section, highlighted after a settings search, with server cards and CPU and memory sliders below.Scaling settings of the web service scrolled to the Replicas section, highlighted after a settings search, with server cards and CPU and memory sliders below.
Search settings and land right on the one you need.

Size of each replica

Pick a size for each replica:

SizeCPUMemory
Small0.5 core512 MB
Medium1 core1 GB
Large2 cores4 GB

A size that no server the service may run on can give says Bigger than any server. Custom opens two sliders, CPU from 0.05 to 1024 cores and memory from 16 MB to 1 TB, which end at the biggest server the service may run on. The default is 1 core and 512 MB. A replica that goes over its memory limit is restarted. Previews cap each replica at half a CPU by default.

Limits are caps, not reservations. A service that idles at 80 MB only uses 80 MB, whatever its limit, so the limits of all services on a server can add up to more than the server has. launchroom places a replica where it fits:

  • Memory is what counts. A replica needs about as much as it used at its busiest in the last few hours (128 MB before it has run, never more than its limit), and the server needs that much actually free, plus a small reserve for the system.
  • CPU never stops a deploy. Services share the cores, and a busy one can use up to its limit when the others are idle.
  • A single replica can't ask for more cores or memory than the server has.

If no server has enough free memory, the deploy stops and tells you how much it needed. Stop services you don't need or add a server, then deploy again.

Where it may run

Replicas only go to servers with the Run apps role. Within those, you set:

  • Distribution: Spread (default) puts replicas on different servers and zones, so one going down leaves the rest serving. Pack fills as few servers as fit and leaves the others free.
  • Per server: each server card has a rule, May run here (default), Only here or Never here.
  • Required labels: only servers that have every one of these labels, for example region=eu or gpu=yes. Labels are set on the server's settings page.
  • Production and preview servers: production only runs on servers that allow production, previews only on servers that allow previews. Both are on by default, per server.

When no server satisfies the rules, saving is refused and the message names each server's reason ("hel-1: missing label gpu=yes; fra-2: doesn't allow previews"). Changing rules doesn't move anything. The next deploy places replicas by the new rules. See Roles and placement.

Zero-downtime deploys

A service with more than one replica is updated one replica at a time:

  1. One new replica starts next to the old ones.
  2. launchroom checks its health from outside the container (an HTTP request to the health path, or a TCP connect).
  3. Once it is healthy, it gets traffic and one old replica drains. The old replica stops getting new requests, serves open ones for the drain time (10 seconds by default, under Deploy), then stops.
  4. The next new replica starts, until all of them run the new version.

The number of serving replicas never drops below the previous count (one extra at a time, none missing). If a new replica fails its health check, launchroom removes the new replicas and puts the old ones back, and the deployment is marked Failed with the reason. The version that was live keeps serving throughout.

The health check is set under Settings → Deploy: HTTP, TCP or none, with start period, interval, timeout and failure threshold. On the default path /, any answer below 500 counts. A path you set, such as /health, expects a 2xx or 3xx answer. See Health checks.

Databases and services with volumes

Two copies can't share one data directory, so databases and services with a volume always run one replica, pinned to the server that holds their data. The scaling page shows the other servers dimmed with "Its data lives on …". A deploy of a database or a service with a volume stops the old container before starting the new one, with a short interruption. For an app that handles two copies on its data, switch on Two copies during a deploy under Settings → Deploy → Rollout: the new container then starts next to the old one, and both use the volume for a moment.

To move such a service to another server, restore a backup there. See Restore and disaster recovery.

When a server goes down

If a server stops reporting for 90 seconds, launchroom moves its stateless replicas to other servers that fit, and your edges stop sending traffic to it. When the server returns, the leftover copies are removed. Replicas don't move back on their own. The next deploy spreads them again.

Databases and services with volumes are never moved automatically, because their data is on that server. Their box on the canvas says "Server down" and links to the server, the Replace server flow and restoring the latest backup elsewhere. See Replace a server.

Next steps

On this page