nixfredFLY.IOFIELD GUIDE · BY NIX UNOFFICIAL
LEARN / APPS, MACHINES AND VOLUMES

Apps, Machines, regions and volumes

A Fly App is a named group of Machines, and a Machine is one Firecracker microVM that starts in well under a second. Size it with presets, place it in a region, let Fly Proxy stop and start it with traffic, and attach a volume only if you accept the limits.

This page is drawn from https://fly.io/docs/apps/overview/, https://fly.io/docs/machines/overview/, https://fly.io/docs/machines/machine-states/, https://fly.io/docs/machines/cpu-performance/, https://fly.io/docs/launch/autostop-autostart/, https://fly.io/docs/volumes/overview/, https://fly.io/docs/launch/deploy/, https://fly.io/docs/launch/processes/ and https://fly.io/docs/reference/configuration/.

Apps versus Machines

“A Fly App is an abstraction for a group of Fly Machines running your code on Fly.io.” (https://fly.io/docs/apps/overview/) An app holds config, provisioned resources, Anycast IPs, certificates, custom domains, secrets and optional volumes (https://fly.io/docs/apps/overview/). All apps in an organization can talk over a private network (https://fly.io/docs/apps/overview/).

A Machine is “the configuration and state for a single VM running on Fly.io”, and every Machine belongs to an app (https://fly.io/docs/machines/overview/). Application code runs in Firecracker microVMs (https://fly.io/docs/reference/architecture/).

QuestionAnswerSource
When do you drive Machines directly?When you need to be picky about “how, where, and when to start VMs”https://fly.io/docs/machines/overview/
Can one app mix both?Yes. Machines made with fly machine run are unmanaged and fly deploy does not update themhttps://fly.io/docs/launch/deploy/

Say: “An app is the unit you deploy and bill against. A Machine is the unit that boots.” Ask: “Do you deploy with fly deploy, or do you create Machines through the API?” The answer decides which scaling commands work (https://fly.io/docs/launch/scale-machine/).

Machine states and lifecycle

Create a Machine and it sits in created while Fly reserves space, fetches the image and builds a root file system, which “can take some time, maybe low double digit seconds”. After that it boots, usually “well under a second” (https://fly.io/docs/machines/overview/).

KindStatesSource
Persistentcreated, started, stopped, suspended, failedhttps://fly.io/docs/machines/machine-states/
Transientcreating, starting, stopping, restarting, suspending, destroying, launch_failed, updating, replacinghttps://fly.io/docs/machines/machine-states/
Terminaldestroyed, replaced, migratedhttps://fly.io/docs/machines/machine-states/

Support rules of thumb from the docs:

CPU and memory

Machines come in two CPU kinds, shared and performance. Both run on the same hardware and clock speed; the difference is how much time they may run (https://fly.io/docs/machines/cpu-performance/).

CPU typePeriodBaseline quotaBurst balance (initial / max)Source
shared80ms5ms (6.25%)5s / 500shttps://fly.io/docs/machines/cpu-performance/
performance80ms80ms (100%)nonehttps://fly.io/docs/machines/cpu-performance/

The page says these numbers might change over time (https://fly.io/docs/machines/cpu-performance/).

Presets and their prices from the pricing page, each for a started Machine (https://fly.io/docs/about/pricing/):

Preset (source: https://fly.io/docs/about/pricing/)RAMPrice
shared-cpu-1x256MB$2.19/month
shared-cpu-1x1GB$6.70/month
shared-cpu-2x2GB$13.39/month
performance-1x2GB$33.00/month
performance-2x4GB$66.00/month

Rules for custom sizes: valid cpus are 1, 2, 4, 8 or 16 depending on cpu_kind (https://fly.io/docs/reference/configuration/). Maximum memory is 2gb times the shared CPU count or 8gb times the performance CPU count, and minimum memory is 256m per shared CPU or 2048m per performance CPU (https://fly.io/docs/machines/guides-examples/machine-sizing/). Run fly platform vm-sizes for the list (https://fly.io/docs/launch/scale-machine/).

Precedence for sizing: the [[vm]] section in fly.toml wins on fly deploy; otherwise existing Machines are kept; otherwise the default shared-cpu-1x is used (https://fly.io/docs/launch/scale-machine/). If you change size with fly scale vm while [[vm]] is still in fly.toml, the next deploy resets it (https://fly.io/docs/reference/configuration/).

Regions and placement

Fly lists 17 regions in the docs table, from ams to yyz, and fly platform regions shows the live list (https://fly.io/docs/reference/regions/). “Gateway” regions host WireGuard gateways, and “MPG” regions can host Managed Postgres (https://fly.io/docs/reference/regions/). Run fly status to see where your app runs (https://fly.io/docs/reference/regions/).

You choose a region, not a server. If you name a region, the Machine is created only there (https://fly.io/docs/machines/overview/). “Placement can fail!” because a region can run out of capacity, and callers must retry (https://fly.io/docs/machines/overview/). A failed region in a multi-region fly scale count makes the whole operation fail (https://fly.io/docs/machines/guides-examples/machine-placement/). Give fly machine clone a list such as -r "iad,dfw" or an alias such as eu to get fallbacks (https://fly.io/docs/machines/guides-examples/machine-placement/).

Advice: give customers a fallback list, because the docs say sjc and gru tend to be in high demand (https://fly.io/docs/machines/guides-examples/machine-placement/).

Autostop, autostart and min_machines_running

Fly Proxy can stop or suspend Machines when traffic falls and start them when a request arrives (https://fly.io/docs/launch/autostop-autostart/).

SettingMeaningSource
auto_stop_machines"off", "stop" or "suspend"https://fly.io/docs/launch/autostop-autostart/
auto_start_machinesStart Machines on requests and capacityhttps://fly.io/docs/launch/autostop-autostart/
min_machines_runningMinimum running Machines, primary region only, needs stop or suspendhttps://fly.io/docs/launch/autostop-autostart/
[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = "stop"
  auto_start_machines = true
  min_machines_running = 0

(https://fly.io/docs/launch/autostop-autostart/)

Facts to remember:

Volumes and their limits

“Fly Volumes are local persistent storage for Fly Machines” (https://fly.io/docs/volumes/overview/). Rules that surprise customers:

Snapshots

Fly takes daily block-level snapshots, keeps them 5 days by default, and retention can be set from 1 to 60 days (https://fly.io/docs/volumes/snapshots/). Snapshots can be created on demand and restored only into a new volume of equal or greater size (https://fly.io/docs/volumes/overview/). Storage is $0.08/GB/month with the first 10GB free (https://fly.io/docs/about/pricing/). Daily snapshots may not have your latest data (https://fly.io/docs/volumes/overview/).

Deploy strategies

Set strategy in [deploy] or pass fly deploy --strategy (https://fly.io/docs/reference/configuration/).

StrategyBehaviorSource
rolling (default)Replace Machines one by one; max_unavailable default 0.33https://fly.io/docs/reference/configuration/
immediateReplace all at once without waiting for health checkshttps://fly.io/docs/reference/configuration/
canaryBoot one new Machine, check health, then roll; not for Machines with volumeshttps://fly.io/docs/reference/configuration/
bluegreenBoot a new Machine beside each one; needs a health check; not for volumeshttps://fly.io/docs/reference/configuration/

Process groups

Define [processes] to run several programs, each in its own Machine(s), scaled separately (https://fly.io/docs/launch/processes/). Without it, Machines belong to the app group (https://fly.io/docs/launch/processes/). “Fly Proxy doesn’t know about process groups”, so give each group its own external port (https://fly.io/docs/launch/processes/).

fly.toml essentials

What is not possible

← The architecture · Proxy, networking, domains, TLS →