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

From Andres Freund
Subject Re: [HACKERS] Slow synchronous logical replication
Date
Msg-id 20171007194212.2i4gmi4l7vgamcyo@alap3.anarazel.de
Whole thread Raw
In response to [HACKERS] Slow synchronous logical replication  (konstantin knizhnik <k.knizhnik@postgrespro.ru>)
Responses Re: [HACKERS] Slow synchronous logical replication
List pgsql-hackers
Hi,

On 2017-10-07 22:39:09 +0300, konstantin knizhnik wrote:
> 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
replicationmore efficient and are there some plans to  work in this direction?
 

This seems to be a question that is a) about a commercial project we
don't know much about b) hasn't received a lot of investigation.

Greetings,

Andres Freund


-- 
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: konstantin knizhnik
Date:
Subject: [HACKERS] Slow synchronous logical replication
Next
From: Konstantin Knizhnik
Date:
Subject: Re: [HACKERS] Slow synchronous logical replication