A new MySQL backups temperature scale, with showers

June 26, 2012

We're used to Cold, Warm and Hot backups. This scale of three temperatures does not quite reflect the impact of backups on your MySQL database.

In this post I offer a new backup temperature scale, and (somewhat seriously) compare it with showers. Call it the backup shower scale.

A database backup is like a shower: the colder it is, the less time you want to spend doing it.

Cold

A cold backup requires taking your database down (i.e. stop the service).

Example: file system copy

This can work well for replicating slaves, which may not be required for normal operation. You take the slave down, turn off the service, make your backup, turn everything on again, and let the backup catch up. Just make sure its master has all the necessary binary logs.

A friend was staying at my place and was lecturing me on the benefits of cold showers; how it was good for your health. A couple hours later, preparing for bed, I hear him exclaiming from the bathroom: "Whaaaaa! There's no hot water!"

Warm

A backup which requires locking down your database as read-only.

Examples: MyDumper, mysqlhotcopy (MyISAM only), mysqldump (non-transactional)

Again, this may do well on slaves. As for working out a warm backup on the master: I don't know. Is a mildly-warm shower really any better than a cold one?

Not quite hot

A backup which is supposedly non-interruptive to normal operation. You are allowed to keep writes to the database. But, things are not quite as they seem.

Example: mysqldump --single-transaction

mysqldump can make a backup in an open transaction. With InnoDB this means a consistent snapshot of the data. But open transactions lead to locks. These accumulate. MVCC makes for changes unable to fall back into the baseline, waiting for the backup's transaction to complete. Eventually, there are so many locks that your database is as good as dead. mysqldump doesn't work well for very large databases under heavy load.

[UPDATE: As per Domas' clarification, MyDumper falls under this category, as well]

In terms of shower, you have reasonably hot water for some time, but they eventually run cold.

Hot

A hot backup is such that does not impose any constraints on the database itself. But it may impose load on other components, such as the disks, memory, CPU. This leads to an implicit impact on MySQL's performance.

An LVM snapshot works this way. With LVM snapshots, writes to the database cause for blocks copy-on-write. The disk is busier. MySQL has to compete for disk use. An LVM backup works just well, but has a noticeable impact on the database's ability to keep up as before.

You may have enough hot water for your shower, but there's not enough pressure. The minute the dishwasher starts working, your shower turns to a sad dripping.

Searing hot

A searing hot backup is one that does not interfere with database operation, explicitly or implicitly, to a reasonable extent.

Xtrabackup with throttling is such a backup. The impact can be made low such that it is unnoticeable. You are willing to have the backup take longer time to complete.

tags:
posted in MySQL by shlomi

« | »

Follow comments via the RSS Feed | Leave a comment | Trackback URL

5 Comments to "A new MySQL backups temperature scale, with showers"

  1. Daniƫl van Eeden wrote:

    And restore is like taking a bath? (mysqldump without exteded inserts can take ages)

  2. shlomi wrote:

    :D

  3. domas wrote:

    do note, that mydumper releases read lock when it is dumping tables, it uses read lock only to establish multiple consistent snapshots for parallel dump.

    also, xtrabackup gets all your family (secondary indexes) into backups, not talking about all other per-page or per-row overhead.

    you also get to shower pretty much every internal cavity too, and just washing hands is pain :)

  4. shlomi wrote:

    @domas,
    duely noted on MyDumper. I didn't know that. My own attempt showed lockdown -- apparently wasn't paying attention.

  5. Sean Hull wrote:

    Great post Shlomi. I like using analogies, but wouldn't the perfect backup ie xtrabackup with throttling be a shower with a temperature gauge that always delivered the water the way you like it? LOL

    Btw, I wrote a 10 things to remember article about MySQL backups a few weeks back: http://www.iheavy.com/2012/05/03/ten-things-remember-mysql-backups/

Leave Your Comment

 

 
Powered by Wordpress and MySQL. Theme by openark.org