DEV Community

Alex Spinov
Alex Spinov

Posted on

Fly.io Has a Free API: Deploy Docker Containers Globally in 35 Regions With a Generous Free Tier and Built-In Postgres

Heroku killed its free tier. AWS is complex. Vercel is great for Next.js but not for a Go backend with WebSockets. Fly.io deploys any Docker container to 35 regions worldwide with a free tier that includes 3 shared VMs, 3GB persistent storage, and 160GB outbound bandwidth.

What Fly.io Actually Does

Fly.io is a platform that runs your Docker containers on bare-metal servers across 35 global regions. Unlike Heroku (which runs in one region), Fly.io places your app close to your users. Unlike AWS (which requires VPC/subnet/security group configuration), Fly.io needs one command.

The architecture: you push a Docker image (or Fly.io builds it from a Dockerfile), specify which regions you want, and Fly.io handles networking, TLS, load balancing, and health checks. Your app gets an Anycast IP — users are automatically routed to the nearest instance.

Fly.io also provides managed Postgres (free tier: 1 shared VM, 1GB storage), Redis, and S3-compatible object storage.

Quick Start

# Install flyctl
curl -L https://fly.io/install.sh | sh
fly auth login

# Launch from any directory with a Dockerfile
fly launch
# Fly detects your framework, generates fly.toml

# Deploy
fly deploy
Enter fullscreen mode Exit fullscreen mode

Or deploy a specific Docker image:

fly launch --image nginx:alpine --name my-app
Enter fullscreen mode Exit fullscreen mode

Manage via API:

# List your apps
curl -H "Authorization: Bearer $(fly auth token)" \
  https://api.machines.dev/v1/apps

# Scale to multiple regions
fly scale count 3 --region iad,lhr,nrt

# Check status
fly status
Enter fullscreen mode Exit fullscreen mode

3 Practical Use Cases

1. Global API with Multi-Region Postgres

# Create Postgres cluster
fly postgres create --name my-db --region iad
fly postgres attach my-db --app my-api

# Add read replicas in other regions
fly machines create --app my-db \
  --region lhr --size shared-cpu-1x
fly machines create --app my-db \
  --region nrt --size shared-cpu-1x
Enter fullscreen mode Exit fullscreen mode

Your API reads from the nearest Postgres replica. Writes go to the primary.

2. WebSocket Server

# fly.toml
[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = false  # Keep alive for WebSockets
  auto_start_machines = true

[services.concurrency]
  type = "connections"
  hard_limit = 10000
  soft_limit = 8000
Enter fullscreen mode Exit fullscreen mode

Fly.io supports persistent connections natively — no WebSocket proxy configuration needed.

3. Background Workers

# Create a separate process group for workers
fly scale count web=2 worker=3
Enter fullscreen mode Exit fullscreen mode
# fly.toml
[processes]
  web = "node server.js"
  worker = "node worker.js"
Enter fullscreen mode Exit fullscreen mode

Web servers handle HTTP. Workers process background jobs. Same deployment, different scaling.

Why This Matters

Fly.io fills the gap between Heroku (simple but US-only, no free tier) and AWS (global but complex). For indie developers and small teams who need globally-distributed infrastructure without the DevOps overhead, Fly.io is the pragmatic choice. The free tier is genuinely useful — not a 5-minute demo that times out.


Need custom data extraction or web scraping solutions? I build production-grade scrapers and data pipelines. Check out my Apify actors or email me at spinov001@gmail.com for custom projects.

Follow me for more free API discoveries every week!

Top comments (0)