Patroni: High Availability

Created on 18 Feb 2020  路  8Comments  路  Source: zalando/patroni

Prior to a poc, will the below work ? is it a good practice or not?

I want to have DC1 (Active) and DC2 (hot standby) - same infrastructure
One HAProxy, Cluster o f 3 ETCD as the DCS, 2 VM's, each includes PG (12v/11.6v) &Patroni
(Since ETCD needs odd num' of nodes, what is the best for me to pick in this scenario below?)
latency between DC's < 5ms.
I don't want lose data, therefore i want that DC2 will be sync.

Can i set on DC1 that its two PG&Patroni to work in sync and on DC2, one PG&Patroni as sync
and the other as Async.

  • Is it possible to change the Async one from async to sync on the fly using the dynamic configuration?

Most helpful comment

Won't i lose some of my data, as the Vacuum is cleaning / compressing and on the other hand i am sending the replication stream ?

Patroni is niether implementing or triggering the autovacuum, so I really don't understand why you are asking a general postgres question here.

or should i have at least 3 PG&Patroni + x etcd?

It is up to you. Having only two postgres/patroni is enough for HA. Etcd is a different story, you must have at least 3 of them.

All 8 comments

3 etcd nodes must be geographically distributed across 3 DC.
Since you have only 2 DC, your setup will not work.

  1. thanks. So 2 DC isn't an option only 1 DC or 3 DC, in the 3DC you would put ETCD to 'solve' the split brain right ? .
  2. No solution possible in case of 2 DC ?
  3. Per 3 DC as i mentioned in (1). can < 5ms allow me using sync on one of the two instances on DC2 and async on the other one. Or < 5ms latency is still bad, therefore both of them should be async ?
  4. Does Postgres Vacuum procedure my interrupt patroni ?
  5. Can i work in DC1 with 2 PG&Patroni + one more instance with Patroni ? does it make sense ?

That's quite a lot of questions.
If you have only two DC there is no way to distinguish between DC is being down or network between them is down. So yes, if one DC can't see another one you will get read-only in both of them in order to avoid split-brain.

5ms latency is quite a lot for sync replication, it will be added to every transaction. Think about it. Do you really want your app to become so slow?

Why vacuum should interrupt Patroni? Just be careful, give Patroni enough resources and don't share the same storage between etcd and postgres.

  1. What do you consider as good latency between DC to maintain sync ? or
    would you say, that between DC better use Async?
  2. If a vacuum / auto vacuum happens During the sync replication, it can't interfere ?
  1. By your example, let's assume 3 DC. on DC1 and DC2 , 2 instances of PG&Patroni + 1 ETCD and in the DC3 only ETCD . Async between one of DC1 instances to the parallel one on DC2, will it work this way ?
    Or do i require to have 3 patroni per each DC (while one can reside alone on one vm)?

The third location is only necessary for Etcd, you don't have to run Patroni/Postgres there.

From my experience, 5ms latency isn't a problem for etcd with the default settings, but I would still recommend you to read about etcd tuning.

I would personally consider doing a sync replication only when RTT between DC is around 1ms or less.

Your concern about autovacuum I don't really understand, it is a part of normal postgres activity.

Regard vacuum - if it happens during replication to the other DC, assuming the other DC is working in async. Won't i lose some of my data, as the Vacuum is cleaning / compressing and on the other hand i am sending the replication stream ?

Regard the same DC, 2 PG&Patroni controlled by one etcd will work or should i have
at least 3 PG&Patroni + x etcd?

Won't i lose some of my data, as the Vacuum is cleaning / compressing and on the other hand i am sending the replication stream ?

Patroni is niether implementing or triggering the autovacuum, so I really don't understand why you are asking a general postgres question here.

or should i have at least 3 PG&Patroni + x etcd?

It is up to you. Having only two postgres/patroni is enough for HA. Etcd is a different story, you must have at least 3 of them.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

biarocha picture biarocha  路  9Comments

oleg9301 picture oleg9301  路  8Comments

phemmer picture phemmer  路  5Comments

Tekchanddagar picture Tekchanddagar  路  4Comments

alexeyklyukin picture alexeyklyukin  路  3Comments