pg_basebackup and backup speed: In the past couple of years, replication has been made easier and easier. Setting up streaming replication is pretty easy these days. When I train people I get a lot of positive feedback. People seem to like the way entire database instances can be cloned.

In many cases, DBAs use a straightforward approach to creating base backups: pg_basebackup.

Potential showstoppers on the way

While this is simple, there can be a small issue which pops up. What if the I/O capacity of two servers is low, while the network bandwidth is large? In case of a simple base backup, that can lead to high disk wait on both servers. The problem is that pg_basebackup running at full speed can easily cause response times to go up, because the disk is just too busy reading all the data.

Some customers have reported that this kind of problem even feels like downtime.

The solution to the problem is to control the speed of pg_basebackup. By reducing the backup speed to a reasonable level, the disk on the master has enough time to serve normal requests.

The -r flag of pg_basebackup can be used for exactly that:

-r, --max-rate=RATE    maximum transfer rate to transfer data directory

Controlling the speed of your base backups can be a good idea if I/O bandwidth is an issue on your systems. It makes sure that your systems stay responsive all the time – even during a backup.

 


In order to receive regular updates on important changes in PostgreSQL, subscribe to our newsletter, or follow us on Twitter, Facebook, or LinkedIn.