X
X
xxx44yyy2020-02-01 05:13:31
PostgreSQL
xxx44yyy, 2020-02-01 05:13:31

How many slots do I need to create for 10 replicas with streaming replication?

Do I understand correctly that 1 slot = 1 replication? Those. if I need to have 10 replications, then I need to make 10 slots. So?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2020-02-01
@xxx44yyy

Depends on the layout of the replicas.
Each replication connection uses one of the allowed max_wal_senders of the host it connects to. If you are configuring replication slots, then you also need the appropriate number of max_replication_slots on that host.
pg_basebackup, in turn, uses up to two max_wal_senders connections and up to one max_replication_slots (depends on launch options and version)
So if you copy all 10 replicas at the same time using basebackup from one master base, you will need 20 max_wal_senders and 10 max_replication_slots. After starting the replicas, 10 max_wal_senders and 0 to 10 max_replication_slots will be used - depending on how you set it up. Each replica has a separate replication slot if you want to use replication slots.
But this is if you configure replication without a cascade.
Replication connections are not counted by cluster, but connected to a specific instance. In the case of a cascade, you can easily have a scheme, for example:
3 replicas read replication from the master, 3 more replicas receive replication from each of them - now 9 replicas, and only 3 walsenders per host were used.
And with such a number of replicas, I highly recommend making a cascade. And save the network on the master, and in case of switching the master, fewer databases will have to be restarted (primary_conninfo still changes only by restarting the entire database, the chance for my patch to be accepted in pg13 is very ghostly)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question