TABLE OF CONTENTS
- •Get a production-ready high-availability PostgreSQL environment
- •At a Glance: What Is Autobase?
- •Components Autobase Installs
- •Choose the Right Architecture: Three Deployment Schemes
- •10 Things We Check Before Going to Production
- •1. DCS: an odd number of members, separate servers, separate disks
- •2. Synchronous replication: define your tolerance for data loss
- •3. Backups: off by default
- •4. Firewall: close it at the network layer
- •5. Locale: get language-specific data right from day one
- •6. PgBouncer: choose the pool mode for the application
- •7. Memory settings: calculate them together with the connection count
- •8. TLS: plan your certificate
- •9. Passwords: never leave them as plain text in the variables file
- •10. Test before go-live
- •Command-Line Deployment in Outline
- •After Deployment: Maintenance and Upgrades
- •What Automation Does Not Replace
- •High-Availability PostgreSQL with Aryasoft
- •Frequently Asked Questions
- •Sources
- •Let’s build a PostgreSQL environment that rides out failures
Autobase is an open source automation platform that builds and manages high-availability (HA) PostgreSQL environments on your own servers or in your cloud account. It installs Patroni, etcd, PgBouncer, HAProxy, pgBackRest and related components in one consistent Ansible workflow. Its defaults do not suit every environment, though: synchronous replication, backups and the firewall are all off by default. In this article we explain what we check before taking a high-availability environment built with Autobase to production.
At Aryasoft we use Autobase to build high-availability PostgreSQL environments. The typical risks of hand-built environments, such as configuration drifting between servers, inconsistent timeout settings and skipped steps, largely disappear with repeatable automation. Automation does not replace the right decisions, however, and this article goes through those decisions one by one. The details are based on Autobase 2.11.0 and its official documentation.
Get a production-ready high-availability PostgreSQL environment
Aryasoft's senior PostgreSQL experts design and deploy your high-availability cluster with Autobase, test failover and restores, and hand over every decision in writing.
At a Glance: What Is Autobase?
| Topic | Summary |
|---|---|
| What it does | Builds high-availability PostgreSQL environments and manages their life cycle: deployment, failover, backup and restore, version upgrades, scaling. |
| Technology | Ansible-based automation. Used through a web UI (Console), the command line (Docker image or Ansible Collection) or GitOps. |
| License | The automation core is MIT-licensed open source; the Console UI is under a separate proprietary license. |
| PostgreSQL versions | 10 to 18; PostgreSQL 18 by default. |
| Operating systems | Debian 11–13, Ubuntu 22.04–26.04, Rocky Linux, AlmaLinux and Oracle Linux 8–10, CentOS Stream 9–10 (x86_64 and arm64) |
| Environments | Your own servers (physical or virtual) and AWS, Azure, GCP, DigitalOcean, Hetzner Cloud |
| Deployment time | About 10–15 minutes according to the documentation |
Components Autobase Installs
A high-availability PostgreSQL environment is not a single piece of software. Autobase installs the following parts, wired together with consistent settings:
| Component | Role | Autobase default |
|---|---|---|
| Patroni | Manages cluster state; promotes a replica automatically when the primary fails. | Always installed |
| etcd or Consul | Distributed configuration store (DCS). Makes sure every server agrees on who the leader is. | etcd |
| PgBouncer | Connection pooler. Funnels many application connections into a small number of database connections. | Installed (port 6432) |
| HAProxy | Routes writes to the primary and reads to the replicas. | Off; enabled by the chosen scheme |
| vip-manager / keepalived | Manages the virtual IP address applications connect to. | Optional; not available in cloud environments |
| pgBackRest or WAL-G | Physical backups, WAL archiving and point-in-time recovery (PITR). | Off |
Choose the Right Architecture: Three Deployment Schemes
Autobase offers three architectures. The first decision is how your applications will connect.
| Scheme | How the application connects | When to choose it |
|---|---|---|
| 1. High availability only | Virtual IP (vip-manager) or a direct server address | One write address is enough and there is no need to spread read load |
| 2. With load balancing | In the cloud, the provider’s load balancer; on your own servers, HAProxy ports: 5000 (writes), 5001 (all replicas), 5002 (synchronous replica), 5003 (asynchronous replicas) | You want to move reporting and read-heavy workloads to replicas |
| 3. Service discovery with Consul | DNS names such as primary.<cluster>.service.consul |
You have several data centers and applications should use the replica in their own location |
To get value from the load-balancing scheme, the application must be able to send read queries to a separate address. Without that capability the replicas stay standby servers only, so make the architecture decision together with the application team.
Warning
Virtual IP solutions (vip-manager and keepalived) do not work in cloud environments. If you deploy on AWS, Azure or GCP, solve the connection address with the provider’s load balancer or Consul DNS. Changing this decision after deployment also means changing the applications’ connection settings.
10 Things We Check Before Going to Production
Autobase’s defaults are designed for a quick start. The table below summarizes the settings we review on every production deployment and why.
| # | Topic | Default | Our recommendation |
|---|---|---|---|
| 1 | DCS member count and placement | The servers defined in the inventory | 3 or 5 etcd members; where possible on servers separate from the database and in different failure domains |
| 2 | Synchronous replication | Off | synchronous_mode on if data loss tolerance is zero |
| 3 | Backups | Off (no WAL archiving) | pgBackRest on, to a repository outside the cluster |
| 4 | Firewall | Off (firewalld and ufw are disabled) | Only the required ports open on the network firewall |
| 5 | Locale | en_US.UTF-8 |
The right locale for your data’s language |
| 6 | Connection pooling | PgBouncer, session mode, pool size 100 | Mode and pool size sized for the workload |
| 7 | Memory settings | shared_buffers 25% of RAM, work_mem 64 MB |
Recalculated together with the connection count |
| 8 | TLS certificate | Self-signed, valid for 10 years | A certificate from your corporate CA if needed |
| 9 | Passwords | Not generated automatically | Strong passwords in an encrypted variables file |
| 10 | Failover and restore tests | Not run | Planned switchover, failure scenario and restore before go-live |
We explain each one below.
1. DCS: an odd number of members, separate servers, separate disks
etcd is the “brain” of the cluster: it decides which server is the primary. To make decisions, a majority of its members (a quorum) must be up. That is why the member count should be odd: 3 members survive one failure, 5 members survive two.
The Autobase documentation makes three recommendations: keep DCS data on a disk separate from PostgreSQL data (SSD if possible), deploy the DCS cluster on servers separate from the database servers, and do not place all DCS members in a single data center. In small environments etcd can run on the database servers; a busy database, however, can keep etcd from responding in time and trigger unnecessary failovers.
2. Synchronous replication: define your tolerance for data loss
For performance reasons, Autobase deploys with synchronous replication off. If the primary goes down unexpectedly in that state, the last transactions that had not yet reached a replica can be lost. Patroni limits this risk by not promoting a replica that is more than 1 MB behind (maximum_lag_on_failover), but it does not remove it.
| Setting | Data loss risk | Cost |
|---|---|---|
| Asynchronous (default) | The last transactions can be lost at failover | Highest write performance |
synchronous_mode: true |
Every acknowledged transaction exists on at least one replica | Each commit waits for the replica’s response |
synchronous_mode_strict: true |
No writes are accepted without a synchronous replica | Writes stop if the replica fails |
We recommend synchronous mode where data loss is unacceptable, such as finance and payment systems. We use strict mode only in environments with at least two replicas; otherwise a single replica failure stops the application.
3. Backups: off by default
This is the setting that costs the most when it is overlooked. If neither pgBackRest nor WAL-G is installed, Autobase sets the archive command to a no-op, so WAL is not archived and point-in-time recovery is impossible. Replication is not a backup: a table dropped by mistake on the primary disappears from every replica within seconds.
Turn on pgBackRest with pgbackrest_install: true and send backups to a repository outside the cluster: a separate backup server, S3-compatible object storage, Azure Blob or Google Cloud Storage. The example schedule in the documentation is a full backup on Sundays, differential backups on the other days and incremental backups every four hours. Set retention according to your RPO target and regulatory obligations.
Critical
A PostgreSQL environment taken to production without backups cannot bring data back after the first logical error, such as a wrong DELETE or a faulty application release. Make a restore test part of the deployment’s acceptance criteria.
4. Firewall: close it at the network layer
By default Autobase does not enable the operating system firewall and disables firewalld and ufw. This assumes network security is provided at another layer. In enterprise environments that layer is usually the network firewall or cloud security groups. Whichever you use, open only the required ports, and only to the sources that need them:
| Port | Service | Who needs access? |
|---|---|---|
| 5432 | PostgreSQL | Cluster members, management servers |
| 6432 | PgBouncer | Application servers |
| 5000–5003 | HAProxy (load-balancing scheme) | Application servers |
| 8008 | Patroni REST API | Cluster members and load balancers |
| 2379, 2380 | etcd | Cluster members only |
The Patroni REST API and the etcd ports are the cluster’s control plane; do not expose them to the application network or the internet.
5. Locale: get language-specific data right from day one
Autobase creates the cluster with the en_US.UTF-8 locale by default. For many languages this is fine; for Turkish, for example, it converts “i” and “ı” to the wrong upper and lower case and does not sort in Turkish alphabetical order. Because a database’s locale cannot be changed later, decide before deployment: set the postgresql_locale variable accordingly, or create application databases with an ICU collation for the language. We cover the details with examples in our What Is PostgreSQL? guide.
6. PgBouncer: choose the pool mode for the application
PgBouncer is installed in session mode with a pool of 100 connections per database. Session mode is the most compatible option, but each client connection holds a database connection for the whole session. If you have many clients running short transactions, transaction mode is far more efficient; however, features that keep session-level state (such as SET commands meant to last for the session, or temporary tables) may not behave as expected in that mode. Choose the mode by testing the application’s behavior.
7. Memory settings: calculate them together with the connection count
Autobase sets shared_buffers to 25% of RAM and effective_cache_size to 75%, in line with the PostgreSQL documentation. The setting to watch is work_mem: the 64 MB default can be used separately by each sort or hash operation in a single query. With max_connections at 1000 by default, total memory use at peak can exceed the server’s capacity. Size these two values together, based on the real number of concurrent connections and the query profile.
8. TLS: plan your certificate
Autobase generates a self-signed certificate valid for 10 years to encrypt connections and sets the minimum TLS version to 1.2. Encryption works as it is. If clients must verify the server’s identity (sslmode=verify-full), replace it with a certificate issued by your organization’s certificate authority.
9. Passwords: never leave them as plain text in the variables file
Autobase does not generate user passwords; you define them in the group_vars file. Because these files usually live in a Git repository, do not leave passwords in plain text; manage them with an encryption method such as Ansible Vault or your corporate password manager.
10. Test before go-live
Automation builds the environment, but it does not prove that it behaves as expected. Our acceptance tests include:
- Planned switchover: measuring how many seconds of interruption a leader change causes on the application side.
- Failure scenario: shutting down the primary unexpectedly and confirming automatic failover.
- DCS failure: shutting down one etcd member and confirming that the cluster keeps running.
- Restore: point-in-time recovery from a pgBackRest backup to a separate server.
Command-Line Deployment in Outline
Besides the web UI, you can run Autobase from the command line with a Docker image that bundles every dependency. The flow has three steps:
- Prepare the inventory file. Download the example file and place your servers in groups:
[etcd_cluster](DCS members),[master](the initial primary),[replica](replicas), and if needed[balancers](HAProxy) and[pgbackrest](backup server). - Set the variables. Define the decisions above in
group_vars/all.yml: scheme, synchronous mode, backups, locale, passwords. - Run the deployment.
curl -fsSL \
https://raw.githubusercontent.com/autobase-tech/autobase/refs/tags/2.11.0/automation/inventory.example \
--output ./inventory
mkdir -p ./group_vars
nano ./group_vars/all.yml
docker run --rm -it \
-e ANSIBLE_SSH_ARGS="-F none" \
-e ANSIBLE_INVENTORY=/project/inventory \
-v $PWD:/project \
-v $HOME/.ssh:/root/.ssh \
autobase/automation:2.11.0 \
ansible-playbook deploy_pgcluster.yml
A starting group_vars/all.yml that reflects our decisions could look like this:
postgresql_version: "18"
synchronous_mode: true
synchronous_mode_strict: false
pgbackrest_install: true
pgbouncer_install: true
ntp_enabled: true
Add the values specific to your environment (server addresses, backup repository, locale, passwords) following the comments in the default variables file.
After Deployment: Maintenance and Upgrades
Autobase’s real value shows after deployment. The riskiest day-to-day operations come as ready, controlled workflows:
| Operation | Autobase workflow | Interruption |
|---|---|---|
| Minor update (18.1 → 18.2) | update_pgcluster.yml: replicas are updated one by one, then the primary after a switchover. |
No read interruption (with more than one replica); about 5–10 seconds for writes |
| Major upgrade, in place (17 → 18) | pg_upgrade.yml: pre-check, upgrade with hard links, automatic rollback on error |
Connection pools paused for about 30–60 seconds |
| Major upgrade, blue-green | pg_logical_upgrade.yml: a separate target cluster fed by logical replication; reverse replication after cutover allows a way back |
About 10–15 seconds for writes |
| Scaling | Add a replica or load balancer by adding a server to the inventory | None |
Before a minor update starts, Autobase runs safety checks: replication is working, lag is below 10 MB and no transaction has been running for more than 15 seconds. For a major upgrade we recommend running the pre-check first, which changes nothing. In environments without PgBouncer, traffic is not redirected to the new primary automatically; applications must be stopped and the connection address changed by hand.
Note
If you are leaving a version whose support has ended (PostgreSQL 14, for example), see our PostgreSQL 14 end of life guide for version choice and a comparison of methods.
What Automation Does Not Replace
Autobase greatly reduces human error in deployment and maintenance. Some decisions and responsibilities always stay with your team, though:
- Architecture decisions: RPO and RTO targets, data center placement, the choice of synchronous replication.
- Monitoring and alerting: alerts for replication lag, disk usage, backup success, transaction ID age (wraparound) and slow queries.
- Performance: query and index tuning, autovacuum settings, capacity planning.
- Regular drills: repeating failover and restore tests periodically.
For the broader rules of running PostgreSQL in production, see our PostgreSQL best practices guide.
High-Availability PostgreSQL with Aryasoft
Aryasoft’s senior-only team builds high-availability PostgreSQL environments with Autobase end to end: architecture design, DCS placement, synchronous replication and backup decisions, security hardening, failover and restore tests. Every decision and test result is handed over in writing. If you want your environment looked after once it is live, see our managed database services, which include a remote DBA service.
Frequently Asked Questions
postgresql_exists). Even so, we recommend a full backup and a trial run on a copy before bringing an existing production server into the environment.Sources
The details in this article were checked against the Autobase 2.11.0 documentation and source code in November 2026. Default values can change in new releases; check the variables file of the version you use before deploying.
- Autobase: GitHub repository
- Autobase: default variables (defaults/main.yml)
- Autobase documentation: Architecture
- Autobase documentation: Requirements
- Autobase documentation: Recommendations
- Autobase documentation: Your Own Machines
- Autobase documentation: Backup
- Autobase documentation: Upgrades
- Patroni documentation
- etcd: FAQ (cluster size and quorum)
- PostgreSQL documentation: Resource Consumption
- PgBouncer: Features (pool modes)
PostgreSQL High Availability
Let’s build a PostgreSQL environment that rides out failures
Aryasoft’s senior PostgreSQL team designs and deploys your high-availability environment with Autobase, runs failover and restore tests and hands over every decision in writing.