| name | flyio-reference-architecture |
| description | Implement Fly.io reference architecture with multi-region apps, Postgres,
Redis, background workers, and private networking.
Trigger: "fly.io architecture", "fly.io system design", "fly.io multi-region".
|
| allowed-tools | Read, Write, Edit |
| version | 1.6.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","edge-compute","flyio"] |
| compatibility | Designed for Claude Code |
Fly.io Reference Architecture
Overview
Production architecture for Fly.io: multi-region web tier, Postgres with read replicas, Redis for caching, background workers, and private networking.
Architecture
โโโโโโโโโโโโ Fly.io Anycast DNS โโโโโโโโโโโ
โ โ
โโโโโโโโผโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโผโโโโ
โ Web (iad) โ โ Web (lhr) โ โ Web (nrt) โ
โ shared-1x โ โ shared-1x โ โ shared-1x โ
โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโ
โ โ โ
โโโโโโโโดโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโดโโโ .internal DNS
โ โ โ
โโโโโโโโผโโโโโโโ โโโโโโโโผโโโโโโโโ โโโโโโโโโโผโโโโโโโโโ
โ Postgres โ โ Postgres โ โ Redis โ
โ Primary โ โ Replica โ โ (upstash.io) โ
โ (iad) โ โ (lhr) โ โ โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโผโโโโโโโ
โ Worker โ
โ (iad) โ
โ shared-1x โ
โโโโโโโโโโโโโโโ
Setup Commands
fly launch --name my-web --region iad
fly scale count 1 --region lhr
fly scale count 1 --region nrt
fly postgres create --name my-db --region iad
fly postgres attach my-db -a my-web
fly machine clone <primary-machine-id> --region lhr -a my-db
fly launch --name my-worker --region iad --no-deploy
fly.toml Configurations
Web App
app = "my-web"
primary_region = "iad"
[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = "suspend"
min_machines_running = 1
[[vm]]
cpu_kind = "shared"
cpus = 1
memory = "512mb"
Background Worker
app = "my-worker"
primary_region = "iad"
[processes]
worker = "node dist/worker.js"
[[vm]]
cpu_kind = "shared"
cpus = 1
memory = "512mb"
Key Design Decisions
| Decision | Choice | Rationale |
|---|
| Web tier | 3 regions | Low latency for global users |
| Database | Fly Postgres + replica | Read replicas near users |
| Cache | Upstash Redis (or Fly Redis) | Managed, multi-region |
| Workers | Separate Fly app | Independent scaling |
| Networking | 6PN (.internal DNS) | Zero-trust, no public exposure |
| Storage | Fly Volumes (NVMe) | Fast, region-local |
Resources