| name | flyio-performance-tuning |
| description | Optimize Fly.io application performance with auto-stop/start tuning,
VM sizing, multi-region latency optimization, and connection pooling.
Trigger: "fly.io performance", "fly.io cold start", "fly.io latency", "fly.io VM sizing".
|
| allowed-tools | Read, Write, Edit, Bash(fly:*) |
| version | 1.6.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","edge-compute","flyio"] |
| compatibility | Designed for Claude Code |
Fly.io Performance Tuning
Overview
Optimize Fly.io performance: eliminate cold starts, right-size VMs, leverage multi-region for low latency, and tune concurrency settings.
Instructions
Step 1: Eliminate Cold Starts
[http_service]
auto_stop_machines = "suspend"
auto_start_machines = true
min_machines_running = 1
Step 2: Right-Size VMs
fly scale show -a my-app
fly scale vm shared-cpu-1x --memory 256
fly scale vm shared-cpu-1x --memory 512
fly scale vm shared-cpu-2x --memory 1024
fly scale vm performance-2x --memory 4096
| Workload | VM | Memory | When |
|---|
| Static site / API proxy | shared-cpu-1x | 256mb | Low traffic |
| Node.js API | shared-cpu-1x | 512mb | Most apps |
| Heavy processing | shared-cpu-2x | 1gb | Background jobs |
| Database / ML | performance-2x | 4gb | Compute-intensive |
Step 3: Multi-Region Latency Optimization
fly scale count 1 --region iad
fly scale count 1 --region lhr
fly scale count 1 --region nrt
curl -w "DNS: %{time_namelookup}s, Connect: %{time_connect}s, Total: %{time_total}s\n" \
-o /dev/null -s https://my-app.fly.dev/health
Step 4: Connection Pooling for Postgres
const pooledUrl = process.env.DATABASE_URL?.replace(':5432/', ':5433/');
Step 5: Tune Concurrency
[http_service.concurrency]
type = "requests"
hard_limit = 250
soft_limit = 200
Resources
Next Steps
For cost optimization, see flyio-cost-tuning.