How Fly.io's Machines, regions and Postgres options compare with ECS, RDS and ElastiCache in your own AWS account, and which one fits a backend that has outgrown a single fly.toml.

Fly.io runs your app as Machines, fast-booting VMs that can sit in many regions close to users, start on a request and stop when idle, all from a fly.toml and fly deploy. It is a very good fit for latency-sensitive apps and side projects that should cost nothing while nobody is using them. It gets harder when the Postgres app someone deployed two years ago is now the production database with nobody sure about its backups, when a customer asks for the data in your own cloud account, or when the backend needs a private path to services that already run in AWS.
AWS gives you managed versions of each of those pieces in an account you own, along with the networking and IAM work Fly.io spares you. This guide compares the two on compute, databases, caching, networking and cost, and shows how to run the backend in your own AWS account with a workflow close to fly deploy.
A Fly Machine boots in well under a second from your Docker image, and the Fly Proxy can start and stop Machines as requests arrive, so an app can scale to zero and wake on traffic. Placing Machines in several regions with anycast routing is a few commands, which is Fly.io's clearest advantage over AWS.
On AWS a backend usually runs as ECS services on Fargate in one region behind an Application Load Balancer, with autoscaling between a minimum and maximum task count. Running in several regions is possible and a project in itself, with replicated data and global routing. For most backends whose users and database sit in one region, that matters less than it seems, since every request still goes to the one primary database.
Fly.io now offers Managed Postgres, where Fly runs the cluster, backups and failover. A lot of production apps still run the original Fly Postgres, which Fly's own docs describe as not a managed database: it is a Postgres app on Machines and volumes that you scale, upgrade, back up and recover yourself.
Amazon RDS for PostgreSQL is managed by AWS, with automated backups, point-in-time recovery, Multi-AZ standbys, read replicas and maintenance windows, in private subnets of your VPC. For Redis, Fly.io offers Upstash Redis as a managed add-on, while AWS has ElastiCache inside your VPC.
Fly.io connects your apps over a private WireGuard mesh with internal DNS, and you can join that network from a laptop or another cloud with a WireGuard peer. Reaching an RDS database or an internal API in your AWS account still means a tunnel or a public endpoint.
In AWS, services, databases and caches share a VPC, security groups control which service reaches which resource, IAM roles replace static credentials, and CloudTrail logs API activity in your own account.
Fly.io bills Machines per second by CPU and memory, stopped Machines only for their root filesystem, plus volumes, Managed Postgres and bandwidth, as listed on its pricing page. Apps that idle most of the day are cheap.
AWS bills Fargate per vCPU-second and GB-second, RDS and ElastiCache per node hour, and adds load balancers, NAT gateways and data transfer. A backend that runs all day with a database and a cache tends to cost less there, especially with Savings Plans, and the engineering time to set it up is the larger cost to compare.
Encore is a backend framework with built-in infrastructure for Go and TypeScript, which gives a fly deploy style workflow on AWS: the Postgres database and the Redis cache are declared in Go next to the code that uses them, and a push provisions RDS, ElastiCache and the ECS services in your own AWS account. The own cloud docs cover connecting the account.
Install the Encore CLI with the command for your system, then create the app:
Run in your terminal to get started locally.
The migration creates a links table with code TEXT PRIMARY KEY, target TEXT NOT NULL and created_at. Lookups read through a Redis keyspace before touching Postgres, the job an Upstash add-on or a Redis app did on Fly.io:
// links/links.go
package links
import (
"context"
"errors"
"time"
"encore.dev/beta/errs"
"encore.dev/storage/cache"
"encore.dev/storage/sqldb"
)
// RDS for PostgreSQL in your AWS account.
var db = sqldb.NewDatabase("links", sqldb.DatabaseConfig{
Migrations: "./migrations",
})
// ElastiCache for Redis in your AWS account.
var cluster = cache.NewCluster("links-cache", cache.ClusterConfig{
EvictionPolicy: cache.AllKeysLRU,
})
var targets = cache.NewStringKeyspace[string](cluster, cache.KeyspaceConfig{
KeyPattern: "link/:key",
DefaultExpiry: cache.ExpireIn(24 * time.Hour),
})
type Link struct {
Code string `json:"code"`
Target string `json:"target"`
}
//encore:api public method=POST path=/links
func Create(ctx context.Context, l *Link) (*Link, error) {
if l.Code == "" || l.Target == "" {
return nil, &errs.Error{Code: errs.InvalidArgument, Message: "code and target are required"}
}
_, err := db.Exec(ctx, `INSERT INTO links (code, target) VALUES ($1, $2)`, l.Code, l.Target)
return l, err
}
//encore:api public method=GET path=/links/:code
func Get(ctx context.Context, code string) (*Link, error) {
if target, err := targets.Get(ctx, code); err == nil {
return &Link{Code: code, Target: target}, nil
} else if !errors.Is(err, cache.Miss) {
return nil, err
}
var target string
err := db.QueryRow(ctx, `SELECT target FROM links WHERE code = $1`, code).Scan(&target)
if errors.Is(err, sqldb.ErrNoRows) {
return nil, &errs.Error{Code: errs.NotFound, Message: "link not found"}
} else if err != nil {
return nil, err
}
_ = targets.Set(ctx, code, target) // a failed cache write only costs a later miss
return &Link{Code: code, Target: target}, nil
}
encore run starts Postgres and an in-memory Redis locally, so the cache-aside path runs on a laptop without a Fly app, an Upstash database or a WireGuard tunnel. On push, Encore provisions the service on ECS, the RDS database with automated daily backups, and an ElastiCache cluster in the same VPC, and Encore provisions an IAM role for the service. The Go caching docs cover keyspaces and expiry. A coding agent adding rate limiting puts a new keyspace on the same cluster in the same Go change and checks it with the local run.
The database docs cover migrations, queries and transactions in more detail.
Best fit: teams leaving Fly.io for their own AWS account who want managed Postgres and Redis there and a deploy that stays a git push.
Fly.io remains the better choice for apps that need to run close to users in many regions, for workloads that should scale to zero between requests, and for teams comfortable operating their own database or happy with Managed Postgres. Its CLI and Machines API are also a good base for per-user sandboxes and short-lived workers.
Best fit: latency-sensitive, multi-region apps and projects that idle most of the time.
The by-hand version is ECS on Fargate behind an Application Load Balancer, RDS, ElastiCache, Secrets Manager, and the IAM roles, security groups and VPC to connect them, in Terraform or CDK with a CI pipeline for images. It suits teams with platform engineers who want each resource tuned to their standards.
Best fit: companies with a platform team and existing infrastructure modules.
Stay on Fly.io when multi-region placement or scale to zero is central to the product. Build on AWS by hand when a platform team is ready to own the infrastructure code. Pick Encore when you want your backend, Postgres and Redis managed in your own AWS account, with the database and cache declared in the code you push.
Yes. For small apps that stop when idle, Fly.io is often cheaper, since Machines bill per second and can scale to zero. For a backend that runs all day with a production database and cache, comparable capacity in your own AWS account usually costs less in cloud spend, and the difference has to be weighed against the engineering time AWS takes.
Yes. Fly.io offers Managed Postgres, where Fly runs the cluster, backups and failover. Many older apps still use the original Fly Postgres, which is a Postgres app you deploy and operate yourself on Machines and volumes. On AWS, RDS for PostgreSQL is fully managed, with automated backups, point-in-time recovery and Multi-AZ failover.
Common reasons are a database that needs managed failover and backups you trust, customers who require their data in your own cloud account, private access to services already running in AWS, and a backend that runs in one or two regions where Fly.io's global placement no longer helps.
With Encore, declare the database with sqldb.NewDatabase and the cache with cache.NewCluster in Go. encore run starts Postgres and an in-memory Redis locally, and a git push provisions the service on ECS, RDS for the database and ElastiCache for Redis in your AWS account.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.