DEV Community

Alex Spinov
Alex Spinov

Posted on

Fly Machines Has a Free API: Deploy Containers Globally With Sub-Second Boot Times

Fly Machines is Fly.io's API for launching and managing lightweight VMs (microVMs) that start in under 300ms and run in 35+ regions worldwide.

Why Fly Machines Matters

Traditional cloud VMs take 30-60 seconds to boot. Fly Machines boot in under 300ms using Firecracker microVMs — the same tech AWS Lambda uses internally. You get VM-level isolation with serverless-level speed.

What you get for free:

  • Firecracker microVMs that boot in <300ms
  • Deploy to 35+ regions worldwide
  • Scale to zero: machines stop when idle, restart on request
  • Direct REST API for programmatic control
  • Built-in Anycast networking (automatic global load balancing)
  • Persistent volumes for stateful workloads
  • Free tier: 3 shared VMs, 160GB bandwidth

Quick Start

# Install flyctl
curl -fsSL https://fly.io/install.sh | sh

# Login
fly auth login

# Launch app from Dockerfile
fly launch

# Deploy
fly deploy

# Scale to multiple regions
fly scale count 3 --region iad,lhr,nrt
Enter fullscreen mode Exit fullscreen mode

Machines REST API

# Create a machine via API
curl -X POST "https://api.machines.dev/v1/apps/my-app/machines" \
  -H "Authorization: Bearer $FLY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "config": {
      "image": "nginx:latest",
      "guest": { "cpus": 1, "memory_mb": 256 },
      "services": [{
        "ports": [{ "port": 443, "handlers": ["tls", "http"] }],
        "protocol": "tcp",
        "internal_port": 80
      }]
    },
    "region": "iad"
  }'

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

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

Dockerfile Deploy

FROM node:20-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci --production
COPY . .
EXPOSE 8080
CMD ["node", "server.js"]
Enter fullscreen mode Exit fullscreen mode
# fly.toml
app = "my-api"
primary_region = "iad"

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = true    # Scale to zero!
  auto_start_machines = true   # Wake on request!
  min_machines_running = 0

[vm]
  memory = "256mb"
  cpus = 1
Enter fullscreen mode Exit fullscreen mode

Auto-Stop and Auto-Start

[http_service]
  auto_stop_machines = true   # Stop after 5min idle
  auto_start_machines = true  # Start on incoming request
  min_machines_running = 1    # Keep 1 always warm
Enter fullscreen mode Exit fullscreen mode

Machines automatically stop when there is no traffic and restart in <300ms when a request arrives.

Multi-Region Deploy

# Deploy to 5 regions simultaneously
fly scale count 5 --region iad,lhr,nrt,sin,gru

# Check status
fly status
# iad  running  machine_abc  256MB
# lhr  running  machine_def  256MB
# nrt  running  machine_ghi  256MB
Enter fullscreen mode Exit fullscreen mode

Persistent Volumes

# Create a volume
fly volumes create data --size 10 --region iad

# Mount in fly.toml
[mounts]
  source = "data"
  destination = "/data"
Enter fullscreen mode Exit fullscreen mode

Boot Time Comparison

Platform Cold Start Isolation
Fly Machines <300ms microVM
AWS Lambda 100-500ms microVM
AWS EC2 30-60s VM
Docker (ECS) 5-30s Container
Kubernetes 5-60s Container

Useful Links


Building globally distributed scrapers? Check out my developer tools on Apify for ready-made web scrapers, or email spinov001@gmail.com for custom solutions.

Top comments (0)