Hibernation
Stop services while nobody uses them and start them again on the next request. Previews hibernate by default.
Hibernation stops a service's containers when it gets no requests for a while and starts them again when the next request arrives at its domain. Its memory is free while it hibernates. Data volumes and the container stay, so nothing is lost. The first visitor after a hibernation waits for the app to start, usually under two seconds.
The server decides on its own when to hibernate and wake a service, so this works while the dashboard is offline.
Previews hibernate by default
A preview hibernates as a whole after 30 minutes without requests: its apps, workers, cron jobs and databases. The next visit wakes it, databases first, then the apps that use them.
- Project settings → Previews turns it off for the project and sets Hibernate after and what visitors see (a wake screen, or requests that wait).
- A preview's own settings can turn it off for that preview ("Off" instead of "Project default").
- A preview is still removed when its pull request closes or after its expiry time, hibernating or not.
A cron job in a hibernating preview still runs on schedule: the server wakes what it needs for the run.
Turn it on for a service
In production and other lasting environments, hibernation is off until you turn it on per service. Open the service, then Settings → Hibernation, and choose a mode:
| Mode | What happens |
|---|---|
| Off | The service never hibernates. |
| On, with a wake screen | Browsers opening a page see a short "waking up" page, then the app. API clients and bots wait for the app. |
| On, requests wait | Every request waits until the app is up (at most 30 seconds). |
Hibernate after sets how long the service waits without requests: 5 minutes to 24 hours, 30 minutes by default. The change applies at once. It isn't a staged change and needs no deploy. Turning hibernation off wakes the service.
Databases, workers and cron jobs of lasting environments don't get the setting. A service that hibernates finds its database running when it wakes.
When a service had few requests in the last 7 days and uses enough memory, the settings page suggests hibernation, for example "web had 12 requests in the last 7 days. Hibernation would free about 180 MB."
What visitors see
With the wake screen, a browser that opens a page of a hibernating app gets a page that says the app is waking up and shows only the address the visitor typed. When the app is ready, the page opens the original address in place, so Back doesn't return to the wake screen. Apps that start within a second never show it.
Everything else waits for the real answer: form posts, API calls, assets, webhooks, WebSockets, search engines and
uptime monitors. If the app isn't up after 30 seconds, the request gets "This app is starting" with HTTP 503 and a
Retry-After header.
When a service can't hibernate
The settings page lists the checks with what each found. The mode choices stay disabled while one fails:
- No domain: hibernation wakes a service when a request arrives at its domain. Add a domain first.
- Older server: the server runs a launchroom release without hibernation. Update it in Settings → Updates.
- Another server: the service runs on one server while its requests arrive at another. Both need to be the same server.
- Several servers serve traffic: with more than one server taking public traffic, hibernation is unavailable.
- Private network: another service connects to it over the private network, for example
API_URL=http://web:3000. That traffic doesn't pass the domain, so it couldn't wake the service. - Slow start: the service took too long to pass its health check after a recent start. Requests can wait up to 20 seconds of start time; the wake screen allows up to 90 seconds.
- Scheduled jobs in the app: the build found a scheduler inside the app's process, such as
node-cronor APScheduler. Those jobs don't run while it hibernates. Check Hibernate anyway, the scheduled jobs can wait to turn it on regardless, or move the jobs to a cron job. A new scheduler in a later build asks again.
If a service with hibernation on later fails a check, it stays awake and the settings page says why.
Two notes don't block it:
- An open WebSocket or event stream keeps the service awake, and open connections close when it hibernates.
- An image service's files in a volume stay while it hibernates.
Health checks and uptime monitors
launchroom's own health checks never wake a service. While it hibernates, its health path (for example /up) answers
200 ok from the server without starting the app, so an external uptime monitor pointed at it stays green. A monitor
that requests / or any other page wakes the app, which keeps it awake. Point monitors at a health path.
Status and memory freed
A hibernating service shows Hibernating with a moon icon on the canvas, in its panel, in the command palette and on the project cards. While it starts it shows Waking up, and for a minute after a wake its panel says when it woke. See What a status means.
The server page's memory card shows how much memory hibernation frees and which services hibernate. The projects page shows it per environment, for example "2 services hibernating, about 420 MB free".
Hibernating services never raise alerts. A hibernating preview uses no memory in placement, so more previews fit on a server. A hibernating production service keeps its memory reserved so it always has room to wake.
Wake now and Hibernate now
- Wake now in the panel header of a hibernating service (or the previews list for a preview) starts it.
- Hibernate now in the panel's actions menu stops it right away, while hibernation is on.
Both need the permission to deploy and are in the audit log.
If the server is short on memory, a wake is refused instead of pushing out other services. The service shows Can't wake with how much memory it needs and how much the server has, and visitors see that the app can't start right now. Wake anyway starts it regardless.