Skip to content
back to journal

supabase deployment

Fly.io + Supabase: The Reliability Stack That Scales

How to build rock-solid applications with Fly.io and Supabase. Architecture patterns, deployment strategies, and common pitfalls.

Ralph DuinJanuary 23, 20262 min read
<p>Fly.io and Supabase together form a powerful stack for building global applications. But getting reliability right requires understanding their operational characteristics.</p> <h2>Why This Stack?</h2> <p>Fly.io gives you globally distributed compute with Machines that boot in milliseconds. Supabase provides Postgres with real-time capabilities and built-in auth. Together: fast, simple, and scalable.</p> <h2>Architecture Patterns</h2> <h3>Regional Deployment</h3> <p>Deploy Fly Machines in the same region as your Supabase instance. Network latency between compute and database kills performance.</p> <pre><code># fly.toml primary_region = "sjc" # Same as Supabase min_machines_running = 1 # Prevent cold starts auto_stop_machines = false</code></pre> <h3>Connection Pooling</h3> <p>Use Supabase's connection pooler in transaction mode. Don't open connections directly to Postgres from every Machine.</p> <pre><code>DATABASE_URL=postgres://...supabase.co:6543/postgres # Port 6543 = Pooler in transaction mode</code></pre> <h3>Read Replicas for Scale</h3> <p>For read-heavy workloads, deploy Fly Machines near users and use Supabase read replicas. Keep writes regional, spread reads globally.</p> <h2>Reliability Checklist</h2> <ul> <li>✅ Health checks configured (Fly monitors /health endpoint)</li> <li>✅ Grace period for shutdown (drain connections before kill)</li> <li>✅ Database connection retries with exponential backoff</li> <li>✅ Request timeouts (prevent hanging connections)</li> <li>✅ Structured logging (ship to Axiom or Logflare)</li> </ul> <h2>Common Pitfalls</h2> <h3>1. Auto-stop Machines = Cold Start Latency</h3> <p>Fly auto-stops idle Machines by default. For user-facing apps, keep at least 1 Machine running. The cost is minimal, the UX gain is massive.</p> <h3>2. Missing Connection Limits</h3> <p>Supabase free tier: 60 connections. If your Machines don't pool properly, you'll hit limits fast. Monitor <code>pg_stat_activity</code>.</p> <h3>3. Not Using Fly Volumes for State</h3> <p>Machines are ephemeral. Use Fly Volumes for persistent storage. Back them up regularly - volumes aren't replicated.</p> <h2>Monitoring</h2> <p>Key metrics to track:</p> <ul> <li>Fly Machine response time (p50, p95, p99)</li> <li>Supabase active connections</li> <li>Database query duration</li> <li>Error rates and types</li> </ul> <p>This stack is production-ready out of the box, but reliability comes from understanding the operational details.</p> <!-- related:/technical-seo --> <h2>Further reading</h2> <p>Reliability and SEO sit on the same Core Web Vitals foundations: p95 response time, cold-start behaviour, and database query latency all show up in Google's field data. A <a href="/technical-seo">technical SEO audit</a> ties those infrastructure metrics back to rankings, indexability, and AI search readiness.</p>