[HACKERS] Slow synchronous logical replication - Mailing list pgsql-hackers

From konstantin knizhnik
Subject [HACKERS] Slow synchronous logical replication
Date
Msg-id 0FC72B49-AEDE-46F1-862C-1161496A0B2D@postgrespro.ru
Whole thread Raw
Responses Re: [HACKERS] Slow synchronous logical replication
List pgsql-hackers
In our sharded cluster project we are trying to use logical relication for providing HA (maintaining redundant shard
copies).
Using asynchronous logical replication has not so much sense in context of HA. This is why we try to use synchronous
logicalreplication. 
Unfortunately it shows very bad performance. With 50 shards and level of redundancy=1 (just one copy) cluster is 20
timesslower then without logical replication. 
With asynchronous replication it is "only" two times slower.

As far as I understand, the reason of such bad performance is that synchronous replication mechanism was originally
developedfor streaming replication, when all replicas have the same content and LSNs. When it is used for logical
replication,it behaves very inefficiently. Commit has to wait confirmations from all receivers mentioned in
"synchronous_standby_names"list. So we are waiting not only for our own single logical replication standby, but all
otherstandbys as well. Number of synchronous standbyes is equal to number of shards divided by number of nodes. To
provideuniform distribution number of shards should >> than number of nodes, for example for 10 nodes we usually create
100shards. As a result we get awful performance and blocking of any replication channel blocks all backends. 

So my question is whether my understanding is correct and synchronous logical replication can not be efficiently used
insuch manner. 
If so, the next question is how difficult it will be to make synchronous replication mechanism for logical replication
moreefficient and are there some plans to  work in this direction? 

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

pgsql-hackers by date:

Previous
From: Daniele Varrazzo
Date:
Subject: [HACKERS] Help required to debug pg_repack breaking logical replication
Next
From: Andres Freund
Date:
Subject: Re: [HACKERS] Slow synchronous logical replication