Docs
/

Magic Apps

The disk is temporary

Files your app writes to its own disk are lost on every deploy and restart. Here is where to keep data instead.

Each instance of your app has its own local disk. Anything written there is lost when the instance is replaced, and instances are replaced often:

  • on every deploy and rollback,
  • when a crashed process restarts,
  • when the app scales in, or changes regions.

Instances also don’t share disks. A file one instance writes is not there for the others, even while it lasts.

The local disk holds up to 10 GB per instance. An instance that writes more than that is stopped and replaced.

What breaks

If your app keeps It loses
A SQLite file next to its code The whole database, on the next deploy
User uploads in a local folder, such as Django’s MEDIA_ROOT The uploads
Sessions or job queues in files Logged-in users and queued jobs

Caches and temporary files are fine: losing them costs only time.

Where to keep data

  • A database. Serverless SQLite or Postgres. Both are reachable from every instance and every region.
  • Object storage, for uploads and other files, from any provider your app can reach over HTTPS.
  • A volume, when the data has to be a local file and one instance is enough. See below.

Volumes

A volume is a directory whose files outlive restarts, deploys and rollbacks. Each process can have one.

  1. Choose the process, a path to mount it at, and a size.
  2. Save. The volume is added at once, without a deploy: a new instance with the volume starts, and the old one serves until it’s ready.

The volume starts empty, and hides whatever the image has at that path.

The rules

A volume belongs to one instance on one machine, so:

  • A process with a volume runs exactly one instance, in one region, with no enabled regions. More instances, or a second region, are refused while it has one.
  • Each deploy has about 40 seconds of downtime. The old instance stops before the new one starts, since they can’t share the volume. A deploy whose new version crashes is down for about 4 minutes, until the rollback serves.
  • It’s not backed up. If the disk is lost, the data is lost. Keep your own copies of anything that matters.
  • Reads and writes run at up to 10 MB/s.
  • The release command doesn’t see it. Run migrations for a database on the volume as part of the process’s start command, for example python manage.py migrate && gunicorn …. The deploy log reminds you when a process has a volume.

Mount paths

The path must be absolute. It can’t be /, /app (where most images keep their code), or a system directory such as /etc, /usr or /var/run. A path under /app, such as /app/data, is fine.

Grow or remove

  • Grow a volume at any time. The instance restarts in place, with about 10 seconds of downtime. A volume can’t shrink.
  • Remove a volume, and its data is deleted with it. The instance is replaced without it, with about half a minute of failed requests.

Deleting the process or the app deletes its volume too.