Tuning Backup Compression Part 2

Rate This
  • Comments 11

Authors: Sanjay Mishra, Mike Ruthruff

Technical Reviewers: Steve Schmidt, Mike Purtell, Mark Souza, Juergen Thomas, Peter Scharlock, Burzin Patel, Prem Mehra, James Podgorski, Joseph Sack, Alexey Yeltsov, Tom Davidson, Thomas Kejser, Lindsey Allen, Yuriy Toropov, Glenn Berry (SQL Server MVP)

Overview

This is the second part of the article Tuning the Performance of Backup Compression in SQL Server 2008. In the first part we described the benefits of backup compression, a methodology on how to tune backup compression for best performance, and shared some best practices. In this second part, we describe some more considerations in tuning backup compression, and how backup compression interacts with other important features in Microsoft SQL Server 2008. Specifically, we will discuss the following:

  • Tuning BUFFERCOUNT and MAXTRANSFERSIZE
  • Memory used by backup compression
  • Backup compression and log shipping
  • Backup compression and data compression
  • Backup compression and transparent data encryption

Understanding the tuning techniques and the interoperability of backup compression with other features discussed in this article can help you get the best out of the backup compression feature.

Tuning BUFFERCOUNT

As described in Part 1 of the article, default BUFFERCOUNT is determined by SQL Server based on the number of database volumes and backup devices. If the database files are spread across several disk volumes and/or there are a large number of backup devices, the default BUFFERCOUNT value may provide optimal backup performance, and you may not need to tune BUFFERCOUNT further. As discussed in Part 1, you can use the trace flags 3605 and 3213 to find out the default BUFFERCOUNT value used in your backup. However, if the database files are spread across too few disk volumes and/or there are a small number of backup devices, the default BUFFERCOUNT value may not provide optimal backup performance. Tuning BUFFERCOUNT explicitly may improve backup performance.

Part2Fig1

Figure 1: Backup time and CPU utilization with varying BUFFERCOUNT

As illustrated in Figure 1, increasing BUFFERCOUNT results in reduced backup time, at the cost of higher CPU utilization. Your results may vary depending upon your database size, storage layout, and server capacity; however, you will notice that the impact of increasing BUFFERCOUNT on backup performance tends to reduce as BUFFERCOUNT is increased beyond a certain value. In our test, the curve tends to flatten out as we increase BUFFERCOUNT beyond 50.

BUFFERCOUNT value impacts the amount of memory used for backup (discussed later in the section “Memory Utilization by Backup”). Keep this in mind if you explicitly specify the BUFFERCOUNT value.

Tuning MAXTRANSFERSIZE

MAXTRANSFERSIZE refers to the size of the I/O operation issued to read data from the database files. The default value of MAXTRANSFERSIZE is 1 MB. Performance of sequential I/O operations generally benefit from larger block sizes, which is the reason the value is set to 1 MB by default. One drawback of larger I/O sizes is the potential impact on performance of the smaller I/Os being issued concurrently by an OLTP workload. Because I/O queue structures are shared, intermixing large I/O sizes with smaller concurrent I/O requests results in increased latency for both. In today’s shared storage network environments, there is potential for these operations to also impact other hosts sharing the same physical devices. Tuning this parameter is likely unnecessary in hardware configurations using dedicated storage, and it may be necessary only if it is determined that the backup operations impact concurrent workloads. As recommended in Part 1 of the article, tuning MAXTRANSFERSIZE should be considered as a secondary tuning option, and it should only to be utilized when it is determined to be beneficial through testing. In the majority of deployments, the default value will be acceptable.

Figure 2 illustrates observations of backup performance using various transfer sizes.

Part2Fig2

Figure 2: Backup time and throughput with varying MAXTRANSFERSIZE (BUFFERCOUNT = 50, 1 Backup Device)

As illustrated in Figure 2, smaller MAXTRANSFERSIZE (64 KB) results in lower backup throughput and hence longer backup time, and as you increase MAXTRANSFERSIZE, you observe reduced backup time and higher throughput. However, the impact of increasing MAXTRANSFERSIZE on backup performance tends to reduce as MAXTRANSFERSIZE is increased beyond a certain value. In our tests, we observed optimal backup performance when MAXTRANSFERSIZE was between 128 KB and 512 KB. Your results may vary based on your I/O configuration (throughput and latency of your I/O subsystem).

Similar to the BUFFERCOUNT setting, the value chosen for MAXTRANSFERSIZE will also impact the amount of memory used for backup operation (discussed later).

Memory Utilization by Backup

As discussed in Part 1 of the article, memory used by backup buffers comes from virtual address space outside the buffer pool. On 32-bit systems, there is a fixed amount of virtual address space set aside outside of the buffer pool (default of 384 MB); increasing BUFFERCOUNT and MAXTRANSFERSIZE options to high values may fail because the memory for backup operations is calculated and set aside at the beginning of the operation.

On 64-bit systems, the virtual address space for any process can be up to 8 TB which is far beyond the physical memory supported on current 64-bit version of Windows. As a result, memory for allocations outside the buffer pool does not have to be set aside at the time SQL Server is started and is potentially unlimited. Setting an appropriate value for ‘max server memory’ using SP_CONFIGURE is recommended on 64-bit deployments of SQL Server to ensure that enough physical memory will be available to support allocations outside the buffer pool for backup operations.

Trace flags 3605 and 3213 can be used to report the number of buffers used for backup operations to the SQL Server ERRORLOG. The following example shows the information that is reported in the ERRORLOG when these trace flags are enabled.

LogDate                 ProcessInfo Text

2009-01-16 12:42:13.700 spid53      Backup/Restore buffer configuration parameters

2009-01-16 12:42:13.700 spid53      Memory limit: 32761MB

2009-01-16 12:42:13.700 spid53      BufferCount: 100

2009-01-16 12:42:13.700 spid53      MaxTransferSize: 2048 KB

2009-01-16 12:42:13.700 spid53      Min MaxTransferSize: 64 KB

2009-01-16 12:42:13.700 spid53      Total buffer space: 200 MB

2009-01-16 12:42:13.700 spid53      Tabular data device count: 1

2009-01-16 12:42:13.700 spid53      Fulltext data device count: 0

2009-01-16 12:42:13.700 spid53      Filestream device count: 0

2009-01-16 12:42:13.700 spid53      TXF device count: 0

2009-01-16 12:42:13.700 spid53      Filesystem i/o alignment: 512

2009-01-16 12:42:13.700 spid53      Media Buffer count: 100

2009-01-16 12:42:13.700 spid53      Media Buffer size: 2048KB

2009-01-16 12:42:13.700 spid53      Encode Buffer count: 100

2009-01-16 12:45:41.820 Backup      Database backed up. Database: TESTPART, creation date(time): 2008/11/06(12:31:03), pages dumped: 1295126, first LSN: 158:223:37, last LSN: 158:239:1, number of dump devices: 1, device information: (FILE=1, TYPE=DISK: {'R:\Backup\TESTPART_Compressed.bak'}). This is an informational message only. No user action is required.

For an uncompressed backup, the total memory used by the backup buffers can be computed as BUFFERCOUNT multiplied by MAXTRANSFERSIZE. Compressed backup needs three sets of buffers – one set of buffers are used to read from the database files, the second set of buffers are used to compress the data, and the third set of buffers are used to write to the backup media. Therefore, a compressed backup will utilize three times as much memory as the uncompressed backup.

You can observe the memory used by the backup task by monitoring the “Process:Private Bytes” counter for the “sqlservr” process in the Reliability and Performance Monitor (also known as Perfmon). Figure 3 displays this Perfmon counter for a compressed backup, with no other workload. As illustrated in Figure 3, you will see an increase in the Private Bytes counter during the backup task. This increase is equal to (BUFFERCOUNT * MAXTRANSFERSIZE) for uncompressed backups, and equal to (3 * BUFFERCOUNT * MAXTRANSFERSIZE) for compressed backups.

Part2Fig3

Figure 3: Memory used by a backup compression operation, as measured by Perfmon

Another observation from Figure 3 is that this memory is allocated at the beginning of the backup operation, and it is released when the backup is complete.

Backup Compression and Log Shipping

Performance of log shipping will also benefit from compressed backups. Log shipping sends transaction log backups from a primary server to a secondary server by copying log backup files to a network share to be applied to the secondary server. When backup compression is used, transaction log backups are compressed. The reduction in file size for log backups improves performance of all the operations performed by log shipping:

  1. Backup the transaction log on the primary server.
  2. Copy the transaction log backup file to the secondary server over the network.
  3. Restore the log backup on the secondary server.

The transaction log backups during log shipping can be compressed in one of the following two ways:

  • If you are using SQL Server Management Studio to setup log shipping, set the backup compression setting by selecting Compress backup from the Set backup compression list, as shown in Figure 4. If you have set backup compression as the default server level setting (sp_configure option backup compression default), you can pick the “Use default server setting” option as well.
  • If you are using the stored procedures to set up log shipping, set the parameter @backup_compression of stored procedure sp_add_log_shipping_primary_database to 1. If you have set backup compression as the default server level setting, you can set this parameter to 2.

Part2Fig4

Figure 4: Compressing transaction log backups for log shipping

Figure 5 provides a data point from a customer deployment. The compressed log backup is significantly smaller and faster.

Part2Fig5

Figure 5: Compression of transaction log backup for log shipping (default values for BUFFERCOUNT and MAXTRANSFERSIZE, 1 backup device)

Backup Compression and Data Compression

Data compression is a feature of SQL Server 2008 that can save disk space by compressing data pages within the database. A commonly asked question is “Are there additional benefits realized by the use of compressed backup operations when data compression is used (both compression ratio and performance of the backup operation)?”

In this test, all tables and indexes were compressed in the database, and then the performance of backup compression was measured. Separate tests were run with no compression, ROW compression applied to all tables/indexes, and PAGE compression applied to all tables/indexes. Figure 6 compares the size of the compressed backup, backup compression ratio, and backup time for databases that contain NONE, ROW, and PAGE compressed tables and indexes.

Part2Fig6

Figure 6: Backup compression with data compression (BUFFERCOUNT = 50, MAXTRANSFERSIZE = default, 4 backup devices)

Some observations from the results of Figure 6:

  • Backup compression can result in additional disk space savings even on databases that contain ROW or PAGE compressed tables or indexes. The size of the compressed backup and the backup compression ratio depend upon the characteristics of the data in the database, and they can vary from the results shown in these examples.
  • Backup operations on databases that use ROW or PAGE compression will likely result in shorter backup times, because the smaller database size translates into less I/O.
  • CPU consumption during the backup operation for databases that use ROW or PAGE compression may be higher as a result of less I/O, which results in more CPU time for compression operations.

 

Backup Compression and Transparent Data Encryption

Transparent data encryption (TDE) is another very useful feature in SQL Server 2008. TDE provides encryption of data in a database at the storage level without requiring any application changes. A common question related to this is “How does backup compression perform against an encrypted database?”

In the example below, backup compression was performed against a database with TDE enabled. Figure 7 compares the size of the backup, CPU consumption, and backup time for compressed and uncompressed backups on the TDE-enabled database.

Part2Fig7

Figure 7: Backup compression with TDE (BUFFERCOUNT = default, MAXTRANSFERSIZE = default, 1 backup device)

We made the following observations when we performed compressed backup against TDE-enabled databases:

  • On a TDE-enabled database, backup compression doesn’t help reduce the size of the backup. The backup compression ratio is nearly 1.0, independent of the data in the database. This is due to the fact that encrypted data does not lend itself well to backup compression.
  • CPU utilization for the compressed backup is higher than the uncompressed backup, even though the backup size is not much different. This is because CPU resources are wasted in the compressed backup operation, because it attempts to compress the data, even though the data is not very compressible.
  • On a TDE-enabled database, it takes longer to perform a compressed backup than it takes to perform an uncompressed backup. This is due to the fact that I/O operations are not reduced, because the data does not compress well. However, there is time spent attempting to compress the incoming data.

For these reasons, we do not recommend the use of backup compression on a TDE-enabled database.

Conclusion

Backup compression is one of the most popular features in SQL Server 2008 Enterprise. Most SQL Server deployments will benefit from this feature; it can reduce both the time taken to perform the backup operation and the disk space required to store database backups. Understanding the tuning techniques and considerations described in Part 1 of the article as well as the interoperability of backup compression with other features discussed in this article can help you get the best out of the backup compression feature.

Appendix A: Test Hardware and Software

All tests (except those in Figure 4 and Figure 6) were performed on the following hardware and software environment.

Server

HP DL380G5 with:

  • 2 socket quad core
  • Intel Xeon CPU E5345 @2.33 GHz
  • 16 GB RAM

Storage

EMC Symmetrix DMX-4 2500

  • Data volumes
    • 4 data volumes from a disk group with
      • 32 disk drives, 300 GB each @15K RPM
      • RAID 1+0
  • Backup volume
    • 1 backup volume from a disk group (separate from data volumes) with
      • 32 disk drives, 300 GB each @15K RPM
      • RAID 1+0
  • ~2 HBAs (4 Gb Fiber Channel)

Software

  • The 64-bit edition of Windows Server 2008 Enterprise
  • The 64-bit edition of SQL Server 2008 Enterprise
Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Post
Page 1 of 1 (11 items)
Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Post