Skip to main content

Running and idling

An app with a server runs only while it's being called. Without requests it freezes, then goes to sleep, and the next request wakes it up. The request isn't lost: it waits on the platform and gets a real answer, not an error.

States​

StateWhen it startsWhat a visitor sees
Runningrequests are coming inthe app's normal speed
Frozenafter about 20 seconds without requeststhe app unfreezes in a fraction of a second
Asleepafter 15 minutes without requests, or earlier when the server is short of memorythe app is restored from a snapshot — slower than unfreezing, faster than starting from scratch
Removed from the serverafter 48 hours without visitors, on any planthe app starts from scratch: the slowest case, the time depends on the stack

While at least one connection is open, such as a WebSocket, the app doesn't freeze.

What this means for your code​

  • Background tasks stop together with the app. While the app is frozen or asleep, timers, schedulers (node-cron, APScheduler) and long-polling bots stop until the next request. A bot or worker that needs a constantly running process doesn't fit this model.
  • Up to 60 seconds for a response. If the app hasn't answered by then, the platform drops the connection. Split long work into parts and keep the progress in the database.
  • The disk is temporary. Everything the app writes to disk is gone after a restart — see Files and state.

Next.js with server rendering​

A Next.js site with server rendering doesn't keep its own process: its pages are rendered on the platform's shared servers. That's why only page rendering time is paid for — see Usage and limits.

Resources​

PlanMemoryCPU
Free256 MB0.25 CPU
Proup to 1 GBup to 1 CPU

You can lower the resources and the time before sleep with the memory_mb, cpu_quota and idle_timeout_s keys in layero.json, but not raise them above the plan.

If the app crashes for lack of memory, the app log shows it: npx layero@latest logs --runtime. Heavy apps usually do fine with 1 GB on Pro.

What it costs​

App time is counted in GB·h: the time the app isn't asleep times the memory of its configuration. Frozen time counts, sleep time doesn't. Limits and prices are on Usage and limits.