Thursday, January 09, 2014

What is BBU for RAID?

BBU, which stands for “battery backup unit.” This awesome device protects and maintains the cached data that is on your server’s raid card. A BBU is essentially a data fail-safe.

Here’s a scary scenario: say for one reason or another, your dedicated server loses power before changes have left the cache and are committed to disk. You are now left with an non-completed query, or worse, corrupted data.

The battery backup unit allows the RAID card to remember what hasn’t yet been synced to disk. The BBU can provide enough backup power to preserve the data for up to 72 hours without power. When the machine powers back up, the BBU will write the cache contents on the disk. All contents on the RAID card buffer become unrecoverable if there is no BBU. The worst part is, you may not even know what files were damaged or corrupted.

Most operating systems have a system call that allows a so-called "synchronous write". This means that during a write operation, if a write has completed then it's guaranteed that it was committed to disk. Synchronous write is therefore non-cached. It blocks the application until it has completed. This kind of operation is obviously slower than cached write which keeps data in OS memory until disk is idle enough and then writes the data. Some critical software, such as database software, perform synchronous writes for critical data because a half-written update in case of a power loss can be detrimental to the database integrity.

If your application software uses a lot of synchronous write, RAID can be slow. For this reason, RAID controllers are equipped with their own caches. What RAID controller does is it writes the data to its cacge instead and LIES to the OS, telling it that it committed the data to disk whereas the data is actually still in RAID cache. When there is a power failure, the BBU can keep the cache alive for 72 hours. After the power caomes back and the hard disks spin up and initialize, the RAID controller can finish writing to disk.

A RAID card can have 1 GB of cache; even though it will not usually be all used for write cache.

If your “write cache” option is set to “write through” or “off”, then you should be fine without a BBU on your raid card. Many RAID cards will have the write cache setting “on” only if the BBU is installed. The downside to having “write cache” turned off is RAID performance will be sub-optimal. This is very important for users who frequently save their database from certain types of corruption or need high data integrity.

No comments: