---
title: "How We Built Fly Postgres"
description: "Fly.io describes how it built Fly Postgres as an automated database app rather than a managed database service. After initially resisting durable storage and database work, the company added attached disk storage and designed a deployable Postgres application with convenience commands, using Postgres streaming replication, Stolon, and Consul to support high availability. A two-node cluster can designate a writable leader and asynchronous standby, while Stolon’s sentinels, keepers, and proxies coordinate state, elect a replacement leader, and route connections; Consul introduces an additional failure mode. Backups use point-in-time, block-level snapshots of the volume, a platform capability that can also support other file-system databases. The post concludes that automated Postgres serves many apps, while managed database partnerships may suit users seeking a simpler experience."
---

# How We Built Fly Postgres

[Fly.io](https://yomu.fyi/company/fly-io) · Nov 29, 2022

**Type:** Explainer

## Summary

Fly.io describes how it built Fly Postgres as an automated database app rather than a managed database service. After initially resisting durable storage and database work, the company added attached disk storage and designed a deployable Postgres application with convenience commands, using Postgres streaming replication, Stolon, and Consul to support high availability. A two-node cluster can designate a writable leader and asynchronous standby, while Stolon’s sentinels, keepers, and proxies coordinate state, elect a replacement leader, and route connections; Consul introduces an additional failure mode. Backups use point-in-time, block-level snapshots of the volume, a platform capability that can also support other file-system databases. The post concludes that automated Postgres serves many apps, while managed database partnerships may suit users seeking a simpler experience.

## Context

Fly.io began as a platform for edge applications without durable storage, expecting applications to use off-platform databases. As customers wanted complete applications on Fly.io and the appeal of maintaining a stateless platform diminished, the company needed a way to support reliable database workloads without replicating a managed service such as RDS.

## Approach / What changed

Fly.io built a deployable Postgres application around persistent volumes, asynchronous streaming replication, Stolon, and Consul. Stolon uses sentinels, keepers, and proxies to manage cluster state, promote a replica, and route connections, while convenience commands automate deployment and management. Database recovery uses point-in-time block-level volume snapshots restored onto new block devices.

## Takeaways

- Fly Postgres is an automated application customers deploy on Fly.io, not a fully managed database service.
- Stolon’s sentinels, keepers, and proxies use Consul to coordinate leader election, replica management, and routing to the healthy leader.
- Point-in-time snapshots of raw volume block devices provide Postgres restores and can generalize to other file-system-based databases.

**Tags:** [Consul](https://yomu.fyi/topic/consul), [High Availability](https://yomu.fyi/topic/high-availability), [Postgres](https://yomu.fyi/topic/postgres)

- Source: [Fly.io](https://fly.io/blog/how-we-built-fly-postgres)
- Source URL: https://fly.io/blog/how-we-built-fly-postgres
- Ingested by Yomu: 2026-09-03T01:26:33.607Z

[Read original post](https://fly.io/blog/how-we-built-fly-postgres)
