Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eoC3y-0006C9-HZ for pgsql-general@arkaria.postgresql.org; Tue, 20 Feb 2018 17:50:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eoC3x-0005HN-0Q for pgsql-general@arkaria.postgresql.org; Tue, 20 Feb 2018 17:50:45 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eoC3w-0005HD-LP for pgsql-general@lists.postgresql.org; Tue, 20 Feb 2018 17:50:44 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eoC3p-000260-5c for pgsql-general@lists.postgresql.org; Tue, 20 Feb 2018 17:50:43 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 863DE5F79C; Tue, 20 Feb 2018 12:50:35 -0500 (EST) Date: Tue, 20 Feb 2018 12:50:35 -0500 From: Stephen Frost To: Dylan Luong Cc: "pgsql-general@lists.postgresql.org" Subject: Re: Performance issues during backup Message-ID: <20180220175035.GM2416@tamriel.snowman.net> References: <7cf3e053324e4946a8468f4a5989fc3b@ITUPW-EXMBOX3B.UniNet.unisa.edu.au> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="L3m6W0M5T3bXetAS" Content-Disposition: inline In-Reply-To: <7cf3e053324e4946a8468f4a5989fc3b@ITUPW-EXMBOX3B.UniNet.unisa.edu.au> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --L3m6W0M5T3bXetAS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Dylan Luong (Dylan.Luong@unisa.edu.au) wrote: > We perform nighty base backup of our production PostgreSQL instance. We h= ave a script that basically puts the instance into back mode and then backs= up (tar) the /Data directory and then takes it out of backup mode. > Ie, > psql -c "SELECT pg_start_backup('${DATE}');" > tar -cvf - ${DATA_DIR} --exclude ${DATA_DIR}/pg_log | split -d -b $TAR_SP= LIT_SIZE - ${BACKUP_DIR}/${BACKUP_NAME} > psql -c "SELECT pg_stop_backup();" This doesn't do anything to ensure that the backup files were actually written out to disk, meaning that you might lose files or portions of files if the system crashed shortly after this completed. You don't mention anything about archive_command or how you are handling WAL? Note that you must have the WAL generated between the start backup and the stop backup for the backup to be valid. If you do have an archive command and it looks anything like what you have for your backup command, you likely have the same issue there where the WAL isn't being synced out to disk and therefore you might lose some WAL on a crash and not be able to do PITR or possibly utilize a given backup. You also don't meniton anything about checking that you have all of the WAL needed between the start/stop before considering the backup valid. I'd strongly suggest you look into a designed-for-PG backup solution instead of trying to roll your own and trying to fix all of these issues. There's a few of them out there that I'd suggest considering- pgBackRest being favorite (but I'm biased), barman, or wal-e (maybe wal-g). > The size of our database is about 250GB and it usually takes about 1 hour= to backup. > During this time, we have performance issue where queries can take up to = 15secs to return where normally it takes 2 to 3 seconds. > During this time (1:30am) usage is low (less than 10 users) on the system. >=20 > Has anyone experience the same problem and any suggestions where to look = at to resolve the problem? Some of the backup tools for PG support throttling to slow down the backup, but my recommendation here would be to stand up a replica and have the bulk of the data pulled from the replica for a given backup instead of doing it from the primary. As mentioned down-thread, you're likely saturating either your i/o bandwidth or your network bandwidth (if you're going to an NFS mount or similar). Thanks! Stephen --L3m6W0M5T3bXetAS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJajF/rAAoJEO1sijiDR2RVrFIQAK3SbKFnEBJEtJcnhEbW18Z1 qW5s4mS6+z23mjs80Nyq6cPHuYL8ooqDFr21AbD8R25aSOcdUz3X0N5Y2Jej1TXN WzxN5L/Xn68PH78rx+d56RSR+kp519/Eehxi9+NcZyDwmLeNlfr/F/bUJ+iqR+O8 2r4Yq4y/tYNLniU6Dx88iFuTfMO56ChOfRIhB1BZyQzR+ScFFvXHCUan2vzMD9fN cDj4RB8Xl4T6wkasLGwDsIvxDTibIzQ8opyfSZJRDJWJldtwFm1u1vKRhmOLVLdG ZJKN9g6G476AnEF8d0HDQlMwsHsjjEVSauuk2EOpY6PETagkyY0AuoJu2fIgWZwU +6PTO4h8j2cItPJIB/wUzk6U8sg+PMGdhwMk4n7wfIRADS5919duKd6PMID2TNtj DHaie9zKqFkUx2dXBsfPfOxRhM47MBFW+56XtK5ukcJNq5UY07puIe6Z8OlYNT4S yH+J2CZhCHWy2sEB2Lgs1UMhyEWr0NWM4fpTmFmJZUsAFqWzfDZ9rQwJf7gCzwbN kyUjk44CrMVGM05moV3l/JacvJLDyZ2sOwzIh+uKW2G0GRjFnED9+o2WpfZGQgZM +itzZks4E1Y5JUZIPbeN11B4yDwheIyEsuRW+xZ0J/v8koBB9FANnOBUajyvETw8 pIn4DImpEtORPOBKpjyo =HLUf -----END PGP SIGNATURE----- --L3m6W0M5T3bXetAS--