An app runs one or more processes from its image. A process is a command, run as one or more instances, all the same size. You manage them on your app’s Processes page.
The web process
- An app has at most one web process. It gets the app’s public address, and all of its web traffic.
- A new app starts with one, called
web, which runs the image’s own start command. - Your app must listen on the web process’s Port, on all interfaces (
0.0.0.0or::). The port is also in thePORTvariable. - The web process always runs at least one instance, except while it sleeps or the app is stopped.
An app doesn’t need a web process. A database, for example, has none: when you create the app, untick The web process receives web traffic. Your other apps then reach it at <app>.internal. See Private addresses.
Other processes
Workers, schedulers and queue consumers run beside the web process. They get no public traffic, but your other apps can reach them at <process>.<app>.internal.
To add one:
- On Processes, find Add a process.
- Enter a Name, such as
worker, and its Command. - Choose its Size and Instances.
- Choose Add process.
A new process starts with your next deploy.
An app can have up to 10 processes. Remove process stops a process’s instances and removes it at once. The web process can’t be removed.
Commands
Leave Command empty to run the image’s own start command.
A command you set replaces the image’s CMD and is passed to its ENTRYPOINT, as command: does in Docker Compose. It’s split into words without a shell, so variables like $WORKERS, pipes and && aren’t expanded. When you need them, run a shell yourself:
sh -c "bundle exec sidekiq --concurrency $WORKERS"
Sizes
Every instance of a process has the same size:
| Size | A month | An hour |
|---|---|---|
| 1 shared CPU, 512 MB | $2.25 | $0.0031 |
| 1 shared CPU, 1 GB | $4.50 | $0.0062 |
| 2 shared CPUs, 2 GB | $9.00 | $0.0123 |
| 2 shared CPUs, 4 GB | $18.00 | $0.0247 |
An instance is billed by the second while it’s running. Starting up isn’t billed, and neither is sleeping. See Billing.
Scaling
- On Processes, set the process’s Size and Instances.
- Choose Save.
A new size or instance count applies at once, with no new release. A size change starts all the process’s instances at the new size, then stops the old ones once every new one is running. If there’s no room for them all, nothing changes.
A changed Command or Port waits for your next deploy. Until then, the app shows Changes not deployed yet, with Deploy changes.
- Limits: every running instance counts towards your organisation’s limits, across all your apps. The page shows how much you use, with Request higher limits. See Limits.
- Volumes: a process with a volume runs exactly one instance. See Volumes and backups.
- Spread: two or more instances of a process are spread across our infrastructure where there’s room, so one failure is less likely to stop them all. See Availability.
- No room: if the region has no room for new instances, the change fails with “The region is at capacity.” Nothing is billed, and what’s running isn’t touched. Try again later.
Health checks
- The web process gets a TCP check on its port: an instance is healthy while the port accepts connections.
- Traffic goes only to healthy instances. An instance that keeps failing its check is taken out of traffic. It keeps running, and it’s still billed.
- A new instance that never passes its check while it starts is stopped, and counts as a crash.
- Other processes count as running once their command starts.
- Health checks never count as traffic, so they don’t keep a sleeping app awake.
Crashes and restarts
- When a process’s command exits or crashes, it starts again. If it keeps failing, the wait between restarts grows. That wait isn’t billed.
- After repeated crashes in a short time, the process is marked crash-looping, the overview says “A process keeps crashing.”, and we email you. Check its output in Logs, or try a bigger size: running out of memory shows in Events.
- When an instance stops, your app gets
SIGTERMand a short time to finish before it’s killed, as with Docker.
The disk inside an instance
Each instance has a small writable disk that’s wiped at every start. Keep anything that must last on a volume, or in a database.
Sleep when idle
Sleep when idle is on for new apps. It applies only to the web process.
- Going to sleep: after 15 minutes with no public requests, no open WebSockets and no traffic from your other apps, the web process stops and shows Sleeping. Compute isn’t billed while it sleeps.
- Waking: the next request wakes it. The request waits while the instances start (Waking), then gets its answer, a few seconds later than usual. If the start takes too long, the visitor gets a “Starting up” page that tries again by itself. The start isn’t billed.
- From your other apps: a connection to its private address wakes it the same way.
- What keeps running: other processes never sleep, and volumes and backups keep billing.
- Events: each sleep and each wake shows in Events, with how long the wake took.
To turn it off:
- Open your app’s Settings.
- Untick Sleep when idle.
- Choose Save settings.
Turning it off wakes a sleeping web process. Turning it on lets it sleep after its next 15 quiet minutes.
Stopping and starting an app
- At the top of any page of your app, open More actions (the … button).
- Choose Stop app, and confirm.
Every instance stops, and compute stops being billed. Your settings and scale are kept. Visitors see a plain “unavailable” page. Volumes and backups keep billing.
Start app runs the current release again at the same scale, in new instances.