What does total cost of ownership mean for managed vs self-hosted Postgres?
Total cost of ownership (TCO) is everything you pay to run a Postgres fleet over a fixed horizon, usually three years. The comparison here is a cloud provider's managed Postgres service versus Postgres run by an operator on your own Kubernetes clusters. Comparing only the hourly instance price misleads, because the managed premium mostly replaces work your team would otherwise do.
The model uses four buckets:
| Bucket | What it includes | Managed | Self-hosted on Kubernetes |
|---|---|---|---|
| Infrastructure | Compute, storage, IOPS, cross-zone replication traffic, backup storage | Higher unit price, fewer line items | Lower unit price, more line items to track |
| Engineering labor | Build, operate, version upgrades, on-call | Mostly configuration and review | Operator setup, runbooks, upgrade testing, pager rotation |
| Risk | Expected downtime and data-loss exposure × business impact | Provider owns failover and backup mechanics | Your team owns them and their failure modes |
| Opportunity | Platform-team time not spent on other work | Low | Can be substantial |
The horizon also includes migration cost in both directions: the cost of moving onto the chosen option and the cost of leaving it later. Lock-in shows up as the exit cost.
The formula is:
TCO(H) = Infra(H) + Labor(H) + Risk(H) + Opportunity(H) + Migration_in + Migration_out
where Risk(H) = Σ P(incident) × impact(incident).
The thesis of this article: for most teams, labor and risk decide the outcome. The compute line is the easiest to measure, but it is rarely the largest.
Why does managed Postgres cost more, and what does the premium buy?
Price a managed instance against the bare node it runs on and the managed line is noticeably higher. That gap pays for operational machinery you would otherwise build, test and keep running yourself:
- Backups: scheduled base backups plus continuous WAL archiving.
- Point-in-time recovery: restore to any timestamp in the retention window.
- Failover: a standby replica with automated promotion.
- Patching: minor-version updates applied for you.
- Monitoring: baseline metrics and logs.
Each item is a system with its own failure modes, and the provider carries the on-call burden for everything below the Postgres process.
What the premium does not buy
The premium does not buy control. Typical restrictions include:
- No true superuser. You get a privileged role that cannot touch the filesystem or load arbitrary shared libraries.
- A curated extension list. If the extension you need is missing, you wait or redesign.
- Fixed maintenance windows. You can shift the window but not remove it, and some patches land on the provider's schedule.
- Limited tuning. Many parameters are exposed, some are locked, and OS-level settings such as kernel parameters, huge pages and filesystem choice are off the table.
Linear pricing and the consolidation trap
Managed pricing scales per instance. Ten databases with standbys cost roughly ten times one. The obvious fix is consolidation: pack many small databases onto one large instance. That trades a cost problem for two others:
- Noisy neighbors. One tenant's runaway query or heavy vacuum starves the others of I/O and connections.
- Blast radius. A failover, maintenance restart or bad migration now hits every service at once. Point-in-time recovery also usually restores the whole instance, so recovering one tenant's data means restoring everything and extracting the piece you need.
How does a Postgres operator like CloudNativePG work on Kubernetes?
With an operator, you describe the database as a Kubernetes resource and a controller keeps reality matching it. In CloudNativePG you declare a Cluster with a number of instances, a storage size and storageClass, and a backup section that points at an object storage bucket. The operator then creates one primary and N-1 streaming replicas, each with its own PersistentVolumeClaim. It watches instance health and promotes a replica when the primary fails. It ships WAL continuously to the bucket so you can do point-in-time recovery, and it rolls minor updates through the replicas first, finishing with a switchover. In a typical layout, the primary sits in one zone, the replicas sit in the others, and every instance's WAL ends up in the same bucket.
The operator automates these workflows. It does not run your infrastructure. Your team still owns:
- Storage class selection, including volume type, provisioned IOPS, and expansion support.
- Node placement and anti-affinity, so that two instances never share a node or zone.
- Operator upgrades and CRD changes, which can change defaults across every cluster at once.
- Backup restore testing, because an archive you have never restored is unproven.
- Kubernetes upgrades, where node drains and API removals hit stateful pods hardest.
Storage is the weak point. Network-attached volumes can follow a pod to another node, but they can cap IOPS. They can also slow failover while the volume detaches and reattaches. Local NVMe disks are faster, but losing a node means losing that disk. The replacement replica must then rebuild from a peer or from object storage before redundancy is back.
# Minimal CloudNativePG Cluster: one primary plus two streaming replicas,
# with WAL archiving and base backups going to an S3-compatible bucket.
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: orders-db
namespace: databases
spec:
# 1 primary + 2 replicas. The operator handles replication and failover.
instances: 3
# Each instance gets its own PVC. The storage class is your decision:
# it sets volume type, IOPS ceiling and whether volumes can expand.
storage:
size: 100Gi
storageClass: fast-ssd-zonal # placeholder; must exist in your cluster
# Continuous WAL archiving plus base backups enable point-in-time recovery.
# These backups are unproven until you have restored from them.
backup:
retentionPolicy: "14d"
barmanObjectStore:
destinationPath: s3://example-pg-backups/orders-db
s3Credentials:
# Reference a Kubernetes Secret; never inline credentials here.
accessKeyId:
name: pg-backup-creds
key: ACCESS_KEY_ID
secretAccessKey:
name: pg-backup-creds
key: SECRET_ACCESS_KEY
wal:
compression: gzip
A minimal CloudNativePG Cluster with three instances, a chosen storage class and size, and WAL archiving to object storage. Storage class choice and restore testing stay with your team.
What hidden infrastructure costs show up on both sides?
That rebuild traffic is one of several costs that never appear on a pricing page. Some apply to both models, and some apply to only one.
| Cost | Managed | Self-hosted | Why it grows |
|---|---|---|---|
| Cross-AZ replication traffic | Partly: standby replication is often bundled, but app-to-database traffic across zones is still billed | Yes: billed as inter-zone transfer | WAL volume tracks write rate, and each replica rebuild copies the full dataset again |
| Provisioned IOPS | Yes | Yes | You pay for peak throughput, not average |
| Snapshot and backup retention | Yes | Yes | Retention windows rarely shrink, and stored volume grows with data size and change rate |
| Idle standby replicas | Yes | Yes | A failover standby costs a full instance whether or not it serves reads |
| Fixed instance-size steps | Yes | No | Instance classes come in fixed sizes, so you round up to the next one |
| Spare node capacity | No | Yes | Dedicated pools need free room to reschedule a failed pod |
The usual argument for self-hosting is bin-packing. Databases share nodes with other workloads and fill the gaps that fixed instance sizes leave unused. That works for dev and staging. Production databases erode most of the saving, for three reasons:
- Guaranteed resources. Guaranteed QoS sets requests equal to limits. The database reserves its full memory even when it isn't using it, so the scheduler can't give that memory to other pods.
- Anti-affinity rules. Spreading the primary and replicas across nodes and zones forces each pod onto a separate host. This leaves unusable fragments of capacity on those hosts.
- Dedicated node pools. Tainting nodes to keep noisy neighbors away brings back the same fixed-size steps that managed services charge for. You also pay for the headroom needed to reschedule a failed pod.
The result is that bin-packing saves real money across many small databases. For a few large production clusters, the saving is close to zero.
How do you estimate the engineering labor cost honestly?
Labor is usually the largest line item on the self-hosted side, and it is the easiest one to underestimate. Start by listing the recurring work for each cluster:
| Task | Assumed hours/month/cluster | Why it recurs |
|---|---|---|
| Minor version upgrades | 1 | Rolling restarts, extension checks |
| Major version upgrades (amortized) | 2 | Rehearsal, compatibility testing, cutover |
| Restore drills | 2 | A backup you have not restored is unproven |
| Capacity changes | 1 | Storage expansion, resizing, connection limits |
| Incident response | 3 | Replication lag, failed failovers, disk pressure |
| Security patching and operator upgrades | 1.5 | Images, CRDs, and operator releases change together |
On-call is a separate cost. At least two people need to understand the operator, WAL archiving, and failover well enough to act at 3 a.m. Below two, every vacation is an outage risk.
These estimates usually run optimistic for three reasons:
- On-call load is undercounted. Pages that resolve themselves still interrupt someone's work.
- Knowledge sits with one or two people. Their time is scarce and their departure is expensive.
- Failover edge cases take longer than planned. Debugging split-brain fencing, or a replica that will not rejoin, consumes days that never appear in a task list.
Illustrative estimate (assumed numbers, not a benchmark): Labor = clusters × Σ task hours × optimism factor × loaded hourly rate, plus an on-call stipend × the number of people on the rotation. With 4 clusters, 10.5 h, a factor of 1.5, and $100/h: 4 × 10.5 × 1.5 × 100 = $6,300/month, before on-call.
Running this calculation before you commit makes the toil visible on paper. Discovering it during a 2 a.m. incident costs far more.
# Illustrative estimate only: every input below is an assumption, not a measurement.
TASK_HOURS = { # hours per month per cluster
"minor_upgrades": 1.0,
"major_upgrades_amortized": 2.0,
"restore_drills": 2.0,
"capacity_changes": 1.0,
"incident_response": 3.0,
"patching_and_operator_upgrades": 1.5,
}
CLUSTERS = 4
OPTIMISM_FACTOR = 1.5 # corrects for undercounted pages and failover debugging
LOADED_RATE = 100.0 # USD per engineer-hour, salary plus overhead
ONCALL_STIPEND = 500.0 # USD per person per month (assumed)
ONCALL_PEOPLE = 2 # minimum so one absence is not a single point of failure
# Risk bucket: expected monthly cost of a bad incident = probability x impact.
INCIDENT_PROB_PER_MONTH = 0.05 # assumed chance of a multi-day failover problem
INCIDENT_HOURS = 40 # assumed engineer-hours to diagnose and recover
def monthly_labor() -> float:
hours = sum(TASK_HOURS.values()) # 10.5
return CLUSTERS * hours * OPTIMISM_FACTOR * LOADED_RATE
def monthly_oncall() -> float:
return ONCALL_STIPEND * max(ONCALL_PEOPLE, 2)
def monthly_risk() -> float:
return INCIDENT_PROB_PER_MONTH * INCIDENT_HOURS * LOADED_RATE
if __name__ == "__main__":
labor, oncall, risk = monthly_labor(), monthly_oncall(), monthly_risk()
print(f"Labor: ${labor:,.0f}/month") # $6,300
print(f"On-call: ${oncall:,.0f}/month") # $1,000
print(f"Risk: ${risk:,.0f}/month") # $200
print(f"Total: ${labor + oncall + risk:,.0f}/month")
A small Python model that computes the monthly labor, on-call, and expected-incident risk buckets for self-hosted Postgres from explicitly assumed inputs, reproducing the section's $6,300/month labor figure.
Where is the break-even point? An illustrative small-fleet vs large-fleet estimate
Illustrative estimate (assumed numbers, not a benchmark). These inputs are assumed. Replace them with your own.
- Managed instance: $1.20/h. Equivalent raw compute and storage: $0.60/h. Both use 730 h/month.
- Engineer cost: $100/h.
- Fixed platform build (operator, backups, monitoring, runbooks): $60,000, amortized over 24 months, which gives $2,500/month.
- Ongoing toil: 2 h per cluster per month. This assumes the platform already exists.
- Small fleet: 5 clusters. Large fleet: 60 clusters.
Use these formulas:
- Managed = N × managed rate × 730
- Self-hosted = N × raw rate × 730 + amortized platform + N × hours × labor rate + R
R is the risk cost: the probability of a failed recovery multiplied by its business cost. For now, set R = 0.
| Fleet | Managed | Self-hosted (R = 0) | Difference |
|---|---|---|---|
| 5 clusters | $4,380 | $5,690 | Managed cheaper by $1,310 |
| 60 clusters | $52,560 | $40,780 | Self-hosted cheaper by $11,780 |
Self-hosting saves $238 per cluster per month ($876 − $438 − $200). The $2,500 fixed cost is recovered at roughly 11 clusters. Below that, the platform investment never pays back.
The break-even point moves with the inputs. At $150/h, the saving drops to $138 per cluster, and break-even rises to about 18 clusters.
Now add risk. Assume your restores are untested, and you estimate a 10% annual chance of an unrecoverable incident costing $1.5M. That is $150,000 per year, or R = $12,500/month. It erases the large fleet's entire saving.
The model has no universal answer. Self-hosting wins only when the fixed cost is spread across many databases and restore drills keep R close to zero.
When should you choose managed Postgres, and when should you avoid self-hosting?
Treat the checklist below as a tiebreaker after you run the numbers, not a replacement for them.
| Signal | Favors managed | Favors self-hosting with an operator |
|---|---|---|
| Fleet size | A handful of databases | Dozens or more, so fixed platform cost is shared |
| Team | Small, no Postgres specialist | Existing Kubernetes platform team on call |
| Uptime needs | Strict, with no one to own failover | Met by a tested in-house runbook |
| Extensions and access | Provider's extension list is enough | Need custom extensions or superuser |
| Environments | Production-only concern | Same setup required in dev, CI and prod |
Several non-cost factors can override the totals. Compliance and data residency may require a region or on-prem site that a provider doesn't offer, which rules out managed regardless of price. Extension availability fails in a binary way. If the extension you need isn't allowed, no discount fixes that. Portability matters when you run across clouds or on-prem, because an operator gives you one control plane everywhere. Lock-in builds up quietly through proprietary features such as custom storage engines, provider-specific replication and IAM-based authentication, and each one makes a later exit harder.
There are three other options to consider:
- Postgres on plain VMs managed with configuration tooling suits teams that have strong Linux skills but no Kubernetes platform.
- A hybrid approach runs production on managed Postgres and uses the operator for disposable dev and test clusters.
- Other Kubernetes Postgres operators differ in their backup, failover and upgrade models, so evaluate them on the same criteria.
Whichever you choose, account for the cost of switching later. Moving production data means planning logical replication or a dump-and-restore cutover window, revalidating extensions and rewriting operational runbooks. That one-time cost belongs in the original TCO model.
How OneEnv can help
Disclosure: OneEnv is the product behind this blog.
OneEnv (oneenv.io) is a workspace-based governance platform for the things services share — environment variables, database structure, API routes and validation rules. A change to a shared value is staged on a branch, reviewed once, and then every affected service explicitly approves or rejects it before it goes live, so you can see who a change touches before it ships instead of finding out in production.
Applied to managed postgres vs self hosted cost, this is where it helps:
Saves time
- Every service that inherits a shared value is listed in one place, so nobody searches repos and chats to find out who is affected.
- One review per branch replaces coordinating each team separately; each service still keeps its own approve/reject.
- Reviewers see the exact diff and the list of affected services up front, so approval is a decision rather than an investigation.
Saves cost
- Fewer production incidents and rollbacks caused by a shared value, route or column changing under a consumer unannounced.
- Less duplicated configuration to maintain: one shared definition inherited by many services.
- Per-service approve/reject means a bad shared value can be refused where it would break something, before it is live.
- OneEnv has a free plan (1 workspace, unlimited services and members, full governance), so trying it costs nothing.
These are qualitative benefits, not measured results — how much you save depends on how many services share the value.
Want to try it? Start at oneenv.io.