DEV Community

Alex Spinov
Alex Spinov

Posted on

Fly Machines Has a Free API: Deploy Containers Globally With Sub-Second Cold Starts

Lambda functions run in one region. Docker containers take seconds to start. Fly Machines deploy globally and start in 300ms.

What Are Fly Machines?

Fly Machines are fast-launching VMs that run Docker containers on Fly.io's global network. They combine the flexibility of containers with the speed of serverless.

# Deploy a Docker image globally
fly launch --image nginx:latest
# Running in 20+ regions, accessible via Anycast
Enter fullscreen mode Exit fullscreen mode

The Machines API

# Create a machine
curl -X POST "https://api.machines.dev/v1/apps/my-app/machines" \
  -H "Authorization: Bearer $FLY_API_TOKEN" \
  -d '{
    "config": {
      "image": "my-app:latest",
      "guest": {"cpus": 1, "memory_mb": 256},
      "services": [{"ports": [{"port": 443, "handlers": ["tls", "http"]}]}]
    }
  }'

# Stop a machine (scale to zero)
curl -X POST "https://api.machines.dev/v1/apps/my-app/machines/{id}/stop" \
  -H "Authorization: Bearer $FLY_API_TOKEN"

# Start it again (300ms cold start)
curl -X POST "https://api.machines.dev/v1/apps/my-app/machines/{id}/start" \
  -H "Authorization: Bearer $FLY_API_TOKEN"
Enter fullscreen mode Exit fullscreen mode

Scale to Zero

# fly.toml
[http_service]
  auto_stop_machines = true   # Stop when no traffic
  auto_start_machines = true  # Start on first request
  min_machines_running = 0    # Scale to zero!
Enter fullscreen mode Exit fullscreen mode

No traffic → machine stops → $0. First request → machine starts in 300ms → serves response.

Why Fly Machines

  • 300ms cold start — vs Lambda 500ms-5s, Cloud Run 2-10s
  • Global by default — deploy to 30+ regions with one command
  • Any Docker image — not just functions, full containers
  • Persistent volumes — attached SSDs for databases
  • GPU machines — run AI models on A100s
  • Scale to zero — pay nothing when idle

Free Tier

  • 3 shared-cpu-1x VMs (256MB each)
  • 3GB persistent storage
  • 160GB outbound transfer

Building globally distributed apps? Check out my developer tools or email spinov001@gmail.com.

Top comments (0)