{
  "id": 22233844,
  "title": "What breaks when your app scales to zero, and how to catch it",
  "url": "https://urgent.news/2026/11/27/what-breaks-when-your-app-scales-to-zero-and-how-to-catch-it",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-27T21:00:00.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/hpoyrazk/what-breaks-when-your-app-scales-to-zero-and-how-to-catch-it-2jdj"
  },
  "original_language": "en",
  "account": "When an app scales to zero on Gregale, any data kept only on the app's machine is lost. This includes files written to local disk or /tmp, and sessions stored in memory. Timers and background processes that run between requests also stop functioning. Any data stored in a database, object storage, or the platform's cron jobs and queues remains intact, as it persists outside the individual instance. When a Gregale instance wakes up, it starts from the same snapshot, and any local state is discarded. Gregale checks for common mistakes, such as refusing stateful base images and VOLUME directives when accepting a deployment. These checks are available on all plans. An idle instance is paused after about a second of inactivity, and paused seconds are not billed. Memory, caches, and open connections remain active during the pause. However, timers do not run during the pause. If an app declares no pause setting, it will only be paused when it has been truly idle for a second. If an app stays idle, Gregale will discard it and restore a fresh instance from the app's snapshot. By default, the snapshot is taken from the deployment after the app becomes ready, not from the instance that parked. This means that each instance restored starts from the same memory state as the last instance, even if they were idle at different times. Two settings can change the contents of the snapshot: what goes into it and what is discarded. When an app saves uploads, a SQLite file, or JSON to ./data or /data, this data is lost when the instance parks. Gregale records a stateless.advisory audit row for these actions. Object storage for files and managed PostgreSQL for records are better alternatives. Keeping login sessions in memory is fine for short-lived sessions, but they will be lost after a park. Instead, use a separate Postgres or hosted Redis such as Upstash to maintain login sessions. A cache that can be rebuilt is acceptable in memory, but any caching logic should be designed to handle the loss of data when the instance parks. Cleanup or heartbeat processes running on setInterval or separate threads will stop functioning when an instance parks. To ensure these processes continue running, they should be implemented as part of the app's code that is executed after the instance is restored. Cron jobs open a new database connection at startup, which is captured in the snapshot and copied into every restored instance. To avoid this issue, the app should reopen the connection in an after_restore hook. Gregale automatically checks for these stateless violations when an app is deployed. If a base image used in the deployment includes a stateful database such as postgres:16, mysql:8, redis:7, mongo:7, mariadb, cockroach, or cassandra, Gregale will reject the deployment with a stateless_only_violation error. Managed PostgreSQL or any other database service can be used instead. At runtime, Gregale monitors the state-shaped directories in each instance, such as data/, db/, /data, /db, and /var/lib/postgresql, /var/lib/mysql, /var/lib/redis, and other database directories. The first write to any of these directories triggers a stateless.advisory audit row. This check is advisory, meaning that the app will continue to run, but the presence of these files signals that the data will not survive the next park. The audit rows can be viewed using gregale audit list --kind-prefix stateless.advisory or by streaming them live with gregale invocation watch --include-stateless. Before deploying an app to Gregale, it is recommended to review the list of design choices and ensure that the app adheres to the platform's stateless requirements. When a Gregale instance is restored after being parked, any connections opened at startup are captured in the snapshot and copied into every restored instance. Therefore, the instance must reopen these connections. To ensure proper functionality after a restore, an after_restore hook should be declared in the app's gregale.yaml file. This hook will be executed after the guest's clock and entropy have been repaired, and it can be used to reopen any necessary connections or restore any lost state. By following these guidelines and avoiding stateful dependencies, developers can ensure that their apps function correctly when scaling to zero on Gregale.",
  "summary": "Originally published on gregale.dev . I build Gregale, so read this as a vendor's page. Competitor details come from each vendor's own docs, linked in the post. This post was written with AI assistance. When an app scales to zero, whatever it kept only on its own machine is lost, such as files written to local disk or /tmp and sessions held in memory, and timers or background loops meant to run…",
  "summary_source": "publisher",
  "key_points": [
    "Data on app's machine lost when scaling to zero",
    "Timers and background processes stop functioning",
    "Object storage and managed databases persist data"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}