Cloud and infrastructure as code
Managed vs self-hosted
For each component, weigh the provider's managed service against running open-source software yourself, using operational burden, total cost and lock-in.
For every component you face the same choice. You can use the provider's managed service, or run the open-source software yourself on VMs or Kubernetes. Judge it on three things: the operational burden, the total cost and the lock-in.
Operational burden
Running Postgres yourself means backups and restore tests, point-in-time recovery, failover, minor and major upgrades, OS patching, disk growth and replication lag. Someone is on call for all of it. A rough estimate for a production-grade self-run database cluster is a quarter to half of an engineer's time, ongoing.
Total cost, not hourly rate
Managed services often charge 1.5 to 2 times the equivalent VM. Compare the totals, including people.
Self-hosted Postgres, primary + standby + backups
2 x r7g.xlarge VMs + EBS ~ $500/month
0.3 engineer x $200k/yr loaded cost ~ $5,000/month
Total ~ $5,500/month
RDS Multi-AZ, same instance size ~ $1,000-1,200/month
0.05 engineer for upgrades and tuning ~ $830/month
Total ~ $2,000/monthAt small and medium scale, managed wins by a wide margin. The crossover comes at large scale, where a dedicated team spreads its cost across hundreds of nodes. It also comes when you need an extension the provider does not support, or kernel-level tuning.
Lock-in
Managed Postgres has low lock-in, because you can pg_dump your data out. DynamoDB, Spanner, BigQuery and SQS are higher. Their APIs and data models are proprietary, so leaving means rewriting code.
Lock-in is a cost to price in, not a reason to refuse. Most companies never switch clouds. The engineering time spent staying portable is often more than a migration that never happens.
Common mistakes
- Comparing hourly rates. The cheap VM bill leaves out the engineers who run it.
- Refusing managed services to avoid lock-in. Usually the cost of avoiding it is larger than the risk.
- Self-hosting with no owner. A database nobody is on call for will fail at night.
Check yourself
- Why does the self-hosted total include engineer time? Answer: Because the people who run the database are often the largest cost, larger than the servers.
- Is lock-in a reason to avoid a managed service? Answer: Not by itself. Price it in, and weigh it against the cost of staying portable.
Key takeaways
- Compare total cost, including the engineer time to run the service.
- Default to managed databases, caches, queues and Kubernetes or serverless compute.
- Self-hosting makes sense at large scale, or with a need the provider cannot meet, and only with a clear owner.
- Treat lock-in as a cost to price in.
Further learning
Next, see how the networks that these services sit in are built: cloud networking and VPCs.
Related
Cloud primitives on AWS and GCP
Regions, zones, compute, storage, managed databases and messaging, how the services map between AWS and GCP, and how to decide what to run yourself.
Cloud cost and FinOps
Where cloud money goes, the levers that usually cut a bill, and how engineers own unit cost without waiting for a finance spreadsheet. Start here for the map of cost pages.
Kubernetes in production
Requests and limits, probes, autoscaling, disruption budgets, packaging and the mistakes that cause outages.