ZFS Compression

You can do the exercises described below on any Oracle Solaris 11 machine, but we recommend using The Easiest Way to Start Learning About Oracle Solaris.

It is recommended that you make yourself familiar with ZFS Basics using our previous lab.

Exercise Z.3: ZFS Compression

Task: You are becoming low on your disk space. Now you know how to add more disks to your pool and expand your file system. What other ZFS features can help you to solve this problem?

Lab: In our lab we will compress our Solaris manuals directory and see if we are able to use it after that. Create a separate filesystem for this on our 'labpool' ZFS pool (created in the previous lab):

root@solaris:~# zfs create labpool/zman 
root@solaris:~# zfs list | grep zman 
labpool/zman                31K  7.78G    31K  /labpool/zman

Set compression to "gzip" (there are options to gzip and other algorithms too--check the manual). You can do that also while creating the filesystem.

root@solaris:~# zfs set compression=gzip labpool/zman 

Copy the first part of Solaris manuals there (it will take some time, be patient):

root@solaris:~# cp -rp /usr/share/man/man1 /labpool/zman/ 

Compare the sizes:

root@solaris:~# du -sh /usr/share/man/man1 /labpool/zman/man1
 15.2M 	/usr/share/man/man1
  6.8M	   /labpool/zman/man1
 

We just have saved about 55% of disk space. Not bad! Check if you are able to use the manuals after compression:

root@solaris:~# export MANPATH=/labpool/zman ; man ls 

It works! No need to decompress files, it's all done automatically and transparently for you on the fly. You can turn compression on and off, ZFS is smart enough to take care of that without remounting or rebooting.

Interesting to note: it may sound counterintuitive, but using compression actually increases file system's performance. You may think: "Compression uses extra CPU time, so it should slow down file system operations, right?". But try to think further. Imagine a file that takes two blocks on your disk. To write this file you have to write two blocks, right? If you compress this file by 50% you have to write only one block. Now the question is: "What is faster, your disk or your CPU?". Of course, it takes much less time to compress a block of data than to write it on the disk. OK, it's easy to explain, but is it confirmed by practice? Yes, it is! Take a look at the blog of Don MacAsksill and see how he had confirmed that ZFS compression increases performance: http://don.blogs.smugmug.com/2008/10/13/zfs-mysqlinnodb-compression-update/. Note that it works best when you use the default LZJB algorithm by using plain "compression=on" parameter. You might consider it a good default practice when creating ZFS file systems. There are exceptions, of course: image, video, encrypted and already compressed data will not give you this advantage as they will not be compressed.

In the next lab we will learn about ZFS Deduplication and compare these two ways of saving your disk space.

Comments:

Post a Comment:
Comments are closed for this entry.
About

"I hear and I forget; I see and I remember; I do and I understand" -- Confucius

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today