Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlnZG-00048K-4t for pgsql-admin@arkaria.postgresql.org; Sun, 27 Aug 2017 02:44:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dlnZF-0003gV-JL for pgsql-admin@arkaria.postgresql.org; Sun, 27 Aug 2017 02:44:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dlnXQ-0000Tz-W8 for pgsql-admin@postgresql.org; Sun, 27 Aug 2017 02:43:01 +0000 Received: from mout.perfora.net ([74.208.4.196]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dlnXN-0000uE-Kb for pgsql-admin@postgresql.org; Sun, 27 Aug 2017 02:43:00 +0000 Received: from [192.168.1.101] ([98.169.212.183]) by mrelay.perfora.net (mreueus003 [74.208.5.2]) with ESMTPSA (Nemesis) id 0MXoiP-1dzqRO0SGd-00Wp6V; Sun, 27 Aug 2017 04:42:53 +0200 Message-ID: <59A231AF.3070107@sqlexec.com> Date: Sat, 26 Aug 2017 22:42:55 -0400 From: MichaelDBA User-Agent: Postbox 5.0.17 (Windows/20170804) MIME-Version: 1.0 To: Don Seiler CC: pgsql-admin Subject: Re: Standby Mechanics: WAL vs Streaming References: In-Reply-To: Content-Type: multipart/alternative; boundary="------------090404010805040904010105" X-Provags-ID: V03:K0:kl+VKoDo6DPVEKJMrglGgqY0UTyRkg4fVSiHprrUMlJV/KMN7uy Vg/SlolDhWQakZbr7Q5yCrvtx5v9jZpAA7zWKsboHFtYeh00kjj3CKcLr2LMgRjk49Kgw5H 1w48IYOddrVAl+bPAdgT4QtbB/wzGYLCcZ3cwRh1URC5PDzCYyXJ4bK70yEMaIPLuvBlIY9 5ewtYIgEmleoB8AKIWzww== X-UI-Out-Filterresults: notjunk:1;V01:K0:v7CwxgkvIpU=:DVHsvlshmE8bQ+JpQ8/B1I MixklHkHkHrRyIc+QgSTCowSXAj0fuPCR7xbI5x9X49CGcm689OH/Dv3xZI5d7KcS4ajWOLWK OyZVi2ooMpVmNrvJuRHNqsLjOra80RD+gEKFYpBLM/ZJT1s7wBQJgVUY5/ZFIMbQYWq89kn9+ muG4WdqUX4OcjMbewF+Ym/wU3WlJiXH7+/BmJiLLhwh1pxj9H5+ujxht3Q8JePuFYtzY7nWLw 12SFKoXJLRQEbEj/un/abudjV+lbzFIMrjQCdB+agfC/s40HDI0SlIyF10thMU/ls9NzuzCtY Qldu7MdkkS6X9dq1HvCZ0xdvMPzPjFQhKghRrc+x9HZTols0y/KcZ+tQfbQQtuIs5D0VdIHxX YI4MTJO8yQb3SBS/nfS1UsghjV9Bub8Zc2W4Addk/Hhq55rucLFNE0l8tQ9oGv88A+fDTU3nd uyCpvF9FDrRvMay4pLK22HoX/pxBmDVI8J+RX1VhJdsWSOV9lYrNcrQhdKpCS6/ex7GzajPuY N+zrUWVrFZWtf+92uga+YUuU1G8eiGFf0dhApsxp6hV6vQvBeJurp1DKUUqsWfao8+dfsDgk7 dvRP8AovyHuwURUeEv+n43OEg+77zd0uCiIJNB/R1zZpiFfpD/3lpBvlhvUdkyOLLLziBhvBz E0i0jrhd3s5HKlMJrYipooe33Pmu5EcKSYBhPkmYQIgAzYm9PbOD/srtruabNInFvY81TSeMW tjvjOgv2aiRsrMYH+ONMJ26VWihZeq7YgvpO+yaP14e8zQMyP+M4TlAmGus= List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org This is a multi-part message in MIME format. --------------090404010805040904010105 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit pgbackrest archives WALs faster than a custom archive_command command. I use pgbackrest to automate archiving of WALs from primary to pgbackrest server. From there, my restore_command on the slave pulls WALs if needed to catch up to SR (streaming replication). Some of your other questions.... The standby will recover from the streaming xlog data if local WAL files are not available. (So the standby prefers local WAL files to streaming?) The other way around: The standby prefers streaming replication. It only pulls WALs (restore_command) if it is too far behind. I saw that the WAL archives were being removed from the archive directory. If the standby was already ahead of the WAL files because of streaming replication, would it still use the restore_command to restore WAL files from archive to px_log directory? Or would it just delete the archive files? The archived files in your case (stored on the standby) would only be removed if you had pg_archivecleanup command also in your recovery.conf file for WAL cleanup (archive_cleanup_command). As far as the lag goes, what can we do to increase the throughput for streaming replication? We tried to give it almost all of our 100Mb pipe between data centers and there was still significant lag until it recovered past the point of my manual vacuums. What do you expect? Manual vacuum full on big tables will generate a lot of WAL thereby causing SR lag. The archive_command on the primary seemed to run serial and wait, since it took 4-5 seconds to rsync each 16Mb WAL file from primary to standby. Is there any way to parallelize this? I guess we could just have archive_command do a local copy and then have a separate script in cron to handle some multiple rsync calls (with a max concurrency, of course)? See my solution using pgbackrest above. I'm going to assume that having both streaming replication and WAL rsyncing are going to compete for bandwidth. Would it be advisable to only do streaming most of the day and then maybe rsync WAL files in a nightly batch? Now that I think of it, we do hourly snapmirrors of that WAL storage already (also using the same bandwidth), perhaps we just use that for the WAL replication. How about doing your manual vacuums at night time during low load times? Regards, Michael Vitale --------------090404010805040904010105 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit pgbackrest archives WALs faster than a custom archive_command command.  I use pgbackrest to automate archiving of WALs from primary to pgbackrest server.  From there, my restore_command on the slave pulls WALs if needed to catch up to SR (streaming replication).

Some of your other questions....

The standby will recover from the streaming xlog data if local WAL files are not available. (So the standby prefers local WAL files to streaming?)
The other way around: The standby prefers streaming replication.  It only pulls WALs (restore_command) if it is too far behind.

I saw that the WAL archives were being removed from the archive directory. If the standby was already ahead of the WAL files because of streaming replication, would it still use the restore_command to restore WAL files from archive to px_log directory? Or would it just delete the archive files?
The archived files in your case (stored on the standby) would only be removed if you had  pg_archivecleanup command also in your recovery.conf file for WAL cleanup (archive_cleanup_command).

As far as the lag goes, what can we do to increase the throughput for streaming replication? We tried to give it almost all of our 100Mb pipe between data centers and there was still significant lag until it recovered past the point of my manual vacuums.
What do you expect?  Manual vacuum full on big tables will generate a lot of WAL thereby causing SR lag.

The archive_command on the primary seemed to run serial and wait, since it took 4-5 seconds to rsync each 16Mb WAL file from primary to standby. Is there any way to parallelize this? I guess we could just have archive_command do a local copy and then have a separate script in cron to handle some multiple rsync calls (with a max concurrency, of course)?
See my solution using pgbackrest above.

I'm going to assume that having both streaming replication and WAL rsyncing are going to compete for bandwidth. Would it be advisable to only do streaming most of the day and then maybe rsync WAL files in a nightly batch? Now that I think of it, we do hourly snapmirrors of that WAL storage already (also using the same bandwidth), perhaps we just use that for the WAL replication.
How about doing your manual vacuums at night time during low load times?

Regards,
Michael Vitale

--------------090404010805040904010105--