nixfredFLY.IOFIELD GUIDE · BY NIX UNOFFICIAL
WHITEBOARD / BOARD: MULTI-REGION

Board: multi-region and the real cost of going global

The goal is to show users in three places hitting local Machines, writes replayed to one primary region, and the bill lines that grow every time you add a region.

This page is drawn from https://fly.io/docs/reference/regions/, https://fly.io/docs/blueprints/multi-region-fly-replay/, https://fly.io/docs/reference/load-balancing/ and https://fly.io/docs/about/pricing/.

Whiteboard outcome

When you are done, the board shows three regions each with a Machine, one marked primary with the writable database, read replicas elsewhere, a fly-replay arrow for writes, and a cost note beside each region.

Before you draw: three questions

  1. Where are the users?
  2. What share of requests are writes? Avoid read replicas if “more than 50% write requests” (https://fly.io/docs/blueprints/multi-region-fly-replay/).
  3. Can the app read slightly old data after a write?

Draw it in 6 steps

  1. Draw three dashed boxes: ord (primary), gru, ams, each with a Machine. Say: Fly.io lists 17 regions today, and “Fly Volumes and Fly Machines are tied to the region they’re created in” (https://fly.io/docs/reference/regions/).
  2. Draw users on the left with arrows to their nearest box. Say: Fly Proxy sends traffic to the “least loaded, closest Machine”, and routes across regions only when, in its words, “all Machines in the local region are unhealthy or at their hard_limit” (https://fly.io/docs/reference/load-balancing/).
  3. In ord, draw a cylinder “primary DB”. In the others, “read replica”. Say: Each Machine reads its local replica, and “primary region is exposed in the PRIMARY_REGION environment variable” (https://fly.io/docs/blueprints/multi-region-fly-replay/).
  4. Draw a dotted arrow from gru to ord labeled fly-replay: region=ord for POST. Say: The app answers write requests with only that header and Fly Proxy “will replay the whole request” to the primary (https://fly.io/docs/blueprints/multi-region-fly-replay/).
  5. Write “1MB limit” on the arrow. Requests larger than 1MB cannot be replayed (https://fly.io/docs/networking/dynamic-request-routing/). Under the replicas write “read your own write”: there “will be short periods of time when data is not consistent between replicas and the primary” (https://fly.io/docs/blueprints/multi-region-fly-replay/).
  6. At the bottom, write the rule: Reads go local, writes go home. Every region you add is another Machine, volume and transfer line. (https://fly.io/docs/blueprints/multi-region-fly-replay/, https://fly.io/docs/about/pricing/)
flowchart LR
  U1[Users near gru] --> G
  U2[Users near ams] --> A
  subgraph G[gru]
    MG[Machine] --- RG[(Read replica)]
  end
  subgraph A[ams]
    MA[Machine] --- RA[(Read replica)]
  end
  subgraph O[ord primary]
    MO[Machine] --- PO[(Primary DB)]
  end
  MG -.fly-replay writes.-> MO
  MA -.fly-replay writes.-> MO
  PO -.replication.-> RG
  PO -.replication.-> RA
Whiteboard diagram (rendered from the source mermaid)

What going global really costs

Cost lineFactSource
MachinesThe same shared-cpu-1x 1GB costs $6.70 in iad, $7.73 in fra and $8.50 in sin per monthhttps://fly.io/docs/about/pricing/
Three-region exampleOne Machine per region, 50GB served each and 10GB cross-region traffic each, totals $27.20/monthhttps://fly.io/docs/about/pricing/
Internet egress$0.02/GB in North America and Europe, $0.04/GB in Asia Pacific, Oceania and South America, $0.12/GB in Africa and Indiahttps://fly.io/docs/about/pricing/
Cross-region private traffic$0.006/GB in North America and Europe, $0.015/GB in Asia Pacific, Oceania and South America, $0.050/GB in Africa and India; billed in both directionshttps://fly.io/docs/about/pricing/

What they will ask

QuestionAnswerSource
“Do I get a regional database from Fly.io?”Managed Postgres runs in a subset of regions, so check the MPG column. Unmanaged Postgres is not supported by support.https://fly.io/docs/reference/regions/, https://fly.io/docs/about/support/
“Does a regional outage fail over?”Spreading across regions is the documented defense; entire regions can fail.https://fly.io/docs/blueprints/resilient-apps-multiple-machines/

← Board: stateful app · The pitch →