Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyC1y-0003Cp-6C for pgsql-general@arkaria.postgresql.org; Mon, 25 Feb 2019 08:54:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gyC1w-0005qN-Uh for pgsql-general@arkaria.postgresql.org; Mon, 25 Feb 2019 08:54:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyBz2-00080Q-KH for pgsql-general@lists.postgresql.org; Mon, 25 Feb 2019 08:51:32 +0000 Received: from hermes.gatewaynet.com ([193.92.121.98]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyByy-0008Hz-CJ for pgsql-general@lists.postgresql.org; Mon, 25 Feb 2019 08:51:31 +0000 Received: from smadev.internal.net (pc131.internal.net [10.9.200.131]) by hermes.gatewaynet.com (8.15.2/8.15.2/Debian-8) with ESMTPS id x1P8pJp0027426 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 25 Feb 2019 10:51:24 +0200 Received: from smadev.internal.net (smadev [10.9.200.131]) by smadev.internal.net (8.15.2/8.15.2) with ESMTP id x1P8pI2M032679 for ; Mon, 25 Feb 2019 10:51:19 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) Subject: Re: Logical replication very slow To: pgsql-general@lists.postgresql.org References: <858111e7-37a1-d55c-099a-c80b20aea76a@matrix.gatewaynet.com> From: Achilleas Mantzios Message-ID: Date: Mon, 25 Feb 2019 10:51:18 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.3.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------E894604BEE3D1A5FFBFF6C25" Content-Language: en-US X-Virus-Scanned: clamav-milter 0.100.2 at hermes X-Virus-Status: Clean X-Spam-Status: No, score=-37.0 required=5.0 tests=ALL_TRUSTED,DYN_HAM_COORD, DYN_HAM_IT,DYN_HAM_IT_PARTNERS,DYN_HAM_NAUTICAL,DYN_SPAM_WATCHES8, HTML_MESSAGE autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on hermes.gatewaynet.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------E894604BEE3D1A5FFBFF6C25 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 25/2/19 9:59 π.μ., Boris Sagadin wrote: > > Doing an initial replica. > > postgres 119454 93.5 25.9 34613692 32649656 ?   Rs   07:16  32:45  \_ postgres: 10/main: bgworker: logical replication worker for subscription 24783 sync 16500 > > I've cancelled the sync, set the tables to unlogged type and started it again. I think it helped, still much slower than binary, but better, about 40MB/s. Will set them back to logged type after > initial replica is done. Will this work at all? Doesn't unlogged mean no changes are written to the WAL? What if you just copy by dump and then just add and refresh without |copy_data ? | > > After the initial replica, there aren't that many updates, so it's OK then. But if a need for a new slave arises, waiting a few days for initial replica to finish, which in binary replication case > is just hours, can be a big problem for us. > > Boris > > > > On Mon, Feb 25, 2019 at 8:08 AM Achilleas Mantzios > wrote: > > On 25/2/19 8:52 π.μ., Boris Sagadin wrote: >> Doing an initial replica and trying to find a bottleneck, Ubuntu 16.04, NVMe disks, PgSQL v10.7, AWS. With binary replication, DB is replicated at good speed, around 500MB/s. Trying LR now for >> a big table (about 1.4TB with 2 indexes) and the speed is only about 2MB/s. >> > Is logical replication subscriber in "streaming" state or in initial snapshot? What's the behavior after the initial snapshot, when it gets into streaming state? >> Checked disk util with iostat and only about 20% utilized on master, 15% on target, CPU load on master is low. On slave I can see the "logical replication worker" process is taking about 70% >> CPU time on a single core, machine has 16 cores. >> >> Is there a setting I am missing here? Any ideas appreciated. >> >> Boris >> >> >> > > > -- > Achilleas Mantzios > IT DEV Lead > IT DEPT > Dynacom Tankers Mgmt > -- Achilleas Mantzios IT DEV Lead IT DEPT Dynacom Tankers Mgmt --------------E894604BEE3D1A5FFBFF6C25 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 25/2/19 9:59 π.μ., Boris Sagadin wrote:

Doing an initial replica.

postgres 119454 93.5 25.9 34613692 32649656 ?   Rs   07:16  32:45  \_ postgres: 10/main: bgworker: logical replication worker for subscription 24783 sync 16500

I've cancelled the sync, set the tables to unlogged type and started it again. I think it helped, still much slower than binary, but better, about 40MB/s. Will set them back to logged type after initial replica is done.
Will this work at all? Doesn't unlogged mean no changes are written to the WAL? What if you just copy by dump and then just add and refresh without copy_data ?

After the initial replica, there aren't that many updates, so it's OK then. But if a need for a new slave arises, waiting a few days for initial replica to finish, which in binary replication case is just hours, can be a big problem for us.

Boris


On Mon, Feb 25, 2019 at 8:08 AM Achilleas Mantzios <achill@matrix.gatewaynet.com> wrote:
On 25/2/19 8:52 π.μ., Boris Sagadin wrote:
Doing an initial replica and trying to find a bottleneck, Ubuntu 16.04, NVMe disks, PgSQL v10.7, AWS. With binary replication, DB is replicated at good speed, around 500MB/s. Trying LR now for a big table (about 1.4TB with 2 indexes) and the speed is only about 2MB/s.

Is logical replication subscriber in "streaming" state or in initial snapshot? What's the behavior after the initial snapshot, when it gets into streaming state?
Checked disk util with iostat and only about 20% utilized on master, 15% on target, CPU load on master is low. On slave I can see the "logical replication worker" process is taking about 70% CPU time on a single core, machine has 16 cores.

Is there a setting I am missing here? Any ideas appreciated.

Boris





-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt


-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt
--------------E894604BEE3D1A5FFBFF6C25--