Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1udwAO-002dam-HW for pgsql-general@arkaria.postgresql.org; Mon, 21 Jul 2025 19:27:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1udwAN-002VRy-H0 for pgsql-general@arkaria.postgresql.org; Mon, 21 Jul 2025 19:27:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1udwAN-002VRp-6Z for pgsql-general@lists.postgresql.org; Mon, 21 Jul 2025 19:27:15 +0000 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1udwAL-0004X1-0m for pgsql-general@lists.postgresql.org; Mon, 21 Jul 2025 19:27:14 +0000 Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-87c04c907eeso239799539f.0 for ; Mon, 21 Jul 2025 12:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753126032; x=1753730832; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=f0/Q5K+1GPcoiJlJnn9wxmqWpy9ZBUvamZGXjN5cW90=; b=J/qyM81VUGd/BkWjZ/YLQ6tHGAcglrN9QTBSY6eicxOD5fP46Rv+vJ0kcyVNEPVNLU uN8TJijWXeNIV7N0sJsl2u6Fr4OM2wXl8Vtr0ll7qIsx/UZJyCWE7hEnE8qdkb4/T77i 9XTVXQWIN3ULjDOffuSheMugYFo5vaGpMILT4iJBajOHsLRJ80JiFQysu4wcqu7Qm3Ee lWhG/l4gwSGKRCXlVQk83EC/E1toiyVXkDp97WvMwK20vzpilwKOcTYAfULSnCgUxzUa 0NTyTjF6o3yFMgcZIxc320mJUg7m5WVjf7/JU7HlZHVYWJ8hVUPfpVJpZCpo/uPUWdC0 zSuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753126032; x=1753730832; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=f0/Q5K+1GPcoiJlJnn9wxmqWpy9ZBUvamZGXjN5cW90=; b=XhHHOroWyO3rgpRICFTPr1ugYcJDrlGfWDkttwEzTY752/6+6d6BWgVuHePw4Y+mkA 8NhsSPcUzYf0NONHYk/g1R4F0114uKfs3JGmNnRDKLo3W+67XjWuvvlvspJBOf97CRmq 50RPb5O5RgcNXZHthJ48TQ65/kCh9OTwUHqpbExyVOIXQdf6px3DnogvAuC4ZqX7dtBl JZ7gVJ7OMceE8hlzTOu7QO/3rtxo1KwqPkCTEeLIU/EvsPyngnxCpuPiipxzxAnA9o5z lKRoaE57YpzWvQtYIZaZVJcrobsV0PlhgHvNzCe9Er7SonVniNc988vGW0xG0eJYOOjk M9SQ== X-Gm-Message-State: AOJu0YykI/BEXidHTRjZS62icQ2iKuP6up30LLBVv1TutbCDwwkLAUA3 Y0tAQqW0kl1tKrb70Gv4bUpinlLJj7MIzkBfcrxvPY5U84n4XkzdVswy63PUAbz33VV7pVN6une iDfl6custBFM6Znov5FoPepAnk/32wLY= X-Gm-Gg: ASbGncvPabt+xx+A5jKPMl5ETHejoSzYi0v7DMgMQydveRVOnyJxsJ+fnE8VZaOYhLK IwalJTWGukfn7XmkLADG40q1SHN9pfP+vLjRgwHxD8Z2Y0+LG7R4asvfC+tjjzIwkqEPKQ+T0Of gzvt/q83hWmnNh+AO//3ivNEA6d7GtWq/HgrrbkWhSu/nYRXLkWzPn/QBm/5xrXpgqk0oLs1cNG UCAkF/CE+yYrcNN1tCY7H+z07YVCX87rH4P9b1z2Q== X-Google-Smtp-Source: AGHT+IG4IYHB8KYYwHdEGOFjlLH5xp9bVgsZ7jQv/3B356jJyGtaRs6JrAfQU7lzU3zVq0cy4t+/GWj61vqWBp6aLrw= X-Received: by 2002:a05:6e02:1686:b0:3df:3222:278e with SMTP id e9e14a558f8ab-3e282d8e4a1mr279929135ab.1.1753126032236; Mon, 21 Jul 2025 12:27:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Mon, 21 Jul 2025 15:26:37 -0400 X-Gm-Features: Ac12FXznybM7e3Pf43nllaFjJ_Hpc2ENZjQ-Dzo3tac-0BmxRALsM8FqJvXCWGw Message-ID: Subject: Re: Request for Feedback on PostgreSQL HA + Load Balancing Architecture To: vijay patil Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000065e4e8063a757611" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000065e4e8063a757611 Content-Type: text/plain; charset="UTF-8" > > Is this architecture considered a best practice within the PostgreSQL > community? I would say Patroni is probably "best practice", but there are other people out there happy with, and expert with, repmgr as well. Are there any potential bottlenecks or failure points I should be aware of? How is pgbouncer supposed to know which db to go to?I would think since HAProxy has some way to tell, that pgbouncer should go on other side of haproxy (between the app and haproxy) Would you recommend any improvements or alternative tools for achieving > better reliability and performance? Seems you need a witness server or some sort. Your HA system should have a few main goals: * Immediately fail over to a replica should the primary go down * Reroute the application traffic * Rebuild the old primary as a replica * Never, ever allow there to be more than one primary server Secondary goals: * make the non-Postgres things redundant (as with keepalived and haproxy) * provide read/write traffic routing (as you kind of have here) * some sort of backup system (don't see any here) Your design will also depend on how bulletproof you want your HA system to be, and how much data your application is allowed to lose. Cheers, Greg -- Crunchy Data - https://www.crunchydata.com Enterprise Postgres Software Products & Tech Support --00000000000065e4e8063a757611 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Is this architecture considered a best practice within the Po= stgreSQL community?

I would say Patro= ni is probably "best practice", but there are other people out th= ere happy with, and expert with, repmgr as well.

Are there any potential bottlen= ecks or failure points I should be aware of?

How is pgbouncer supposed=C2=A0= to know which db to go to?I would think since HAProxy has some way to tell,= that pgbouncer should go on other side of haproxy (between the app and hap= roxy)

Would you recommend any improvements or alternative tools for achieving be= tter reliability and performance?

Seems you= need a witness server or some sort. Your HA system should have a few main = goals:

* Immediately fail over to a replica should= =C2=A0the primary go down
* Reroute the application traffic
=
* Rebuild the old primary as a replica
* Never, ever allow t= here to be more than one primary server

Secondary = goals:
* make the non-Postgres things redundant (as with keepaliv= ed and haproxy)
* provide read/write traffic routing (as you kind= of have here)
* some sort of backup system (don't see any he= re)

Your design will also depend on how bulletproo= f you want your HA system to be, and how much data your application is allo= wed to lose.

Cheers,
Greg

--
Enterprise Postgres = Software Products & Tech Support

--00000000000065e4e8063a757611--