Tuesday, January 15, 2013

compression, dedup, and compression + dedup test results




So, I ran some test results with some VHD and VHDX vm files I had from a backup, and
 it was interesting to see the results of deduplication vs compression vs both at the same time.

I did 3 tests, each time copying the same set of 166 GB worth of VHD and VHDX backup files.

First option was dedup only, RECSIZE=16K
This required at least 2.6 GB of RAM in your arc_meta_limit and had a poor dedup ratio.

Second option was compression only, COMPRESSION=LZJB
This does use arc_meta_limit, obviously, but its not imperative that you be able to fit all of it in memory at once.

Third option was dedup on AND compression on. You can see that the compression interfered with the deduplication ratio. I would assume that is partly because the parts of the VHD that are highly compressible are also the ones that are dedup-able. The interesting thing here is that turning compression AND dedup on resulted in a faster write speed than just dedup. I would assume because it is trying to dedup 77.4G of data instead of deduping 166G of data.  The deletion time was also faster.

You can see the detailed results from the XLS screenshot:



The conclusion here (imho) is that dedup is VERY situational and typically is not going to be worth your while compared to LZJB or GZIP-X compression.

I supposed if you are storing multiple copies of the exact same files dedup + compression would come in handy, but I can't think of any situations that would come into play where a snapshot + clone wouldn't work better.

If you have a specific situation where dedup or dedup + compression wins over just compression for you, please let me know what that was.

Monday, January 14, 2013

To DEDUP or not to DEDUP, that is the question



To Dedup or Not to Dedup??

In additional to compression, ZFS offers deduplication functionality. It (potentially) allows you to use less disk space to store the same amount of data. Nothing comes for free, as the say, and in this case deduplication does not either.
You need to provide ZFS with massive amounts of RAM to store its deduplication tables in memory or you can kiss any kind of write performance goodbye (and in worst cases make your fileserver unresponsive for significant periods of time).
Even if you throw plenty of RAM at deduplication, it is still best to treat it as a “backup” device like a tape drive. That is to say, you do backups to it and:

DO NOT USE IT FOR VM STORAGE. LZJB is probably fine, but deduplication will kill VMs responsiveness.
DO NOT USE IT FOR A PRODUCTION DATABASE. Testing databases where response time/processing speed are not a factor could be a possible use.

There, I warned you.

Now, here are some (half-assed) numbers you can use as a rough guide to
Pre-allocating your RAM for a deduplicating pool.

I’m testing with ZFS on Ubuntu. For ZFS on Solaris or Openindiana, the procedure
to change the zfs_meta_limit is slightly different.

Testing Setup:

root@ubuntuzfs03:~# uname -a
Linux ubuntuzfs03 3.2.0-35-generic #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Ubuntu-zfs
spl-0.6.0-rc13
zfs-0.6.0-rc13

VM with 2 virtual CPUs and 8GB of RAM


Set our ARC max size to ~3Gb
Set our ARC meta limit to ~2Gb

Edit /etc/modprobe.d/zfs.conf, the number is # of bytes:

root@ubuntuzfs03:~# cat /etc/modprobe.d/zfs.conf
options zfs zfs_arc_max=3000000000 zfs_arc_meta_limit=2900000000

YOU MUST REBOOT for those changes to take effect.

I use a small script to check the status of my config and running values:
zfs_show.sh
------------------
#!/bin/bash

echo "config"
echo "---------------------"
cat /etc/modprobe.d/zfs.conf
echo " "
echo " "
echo "runtime values"
echo "---------------------"
grep -E arc\|c_max /proc/spl/kstat/zfs/arcstats



now check that your settings (AFTER REBOOTING) have actually taken effect:

root@ubuntuzfs03:~# ~/zfs_show.sh
config
---------------------
options zfs zfs_arc_max=3000000000 zfs_arc_meta_limit=2900000000



runtime values
---------------------
c_max                           4    3000000000
arc_no_grow                     4    0
arc_tempreserve                 4    0
arc_loaned_bytes                4    0
arc_prune                       4    0
arc_meta_used                   4    132929416
arc_meta_limit                  4    2900000000
arc_meta_max                    4    1457235528
root@ubuntuzfs03:~#

The config options in /etc/modprobe.d/zfs.conf should match the
runtime values, or something went wrong.

Now, for our test, we explicitly set the recordsize to 4K:

root@ubuntuzfs03:~# zfs set recsize=4K zpool1/cifs/dedup_storage
root@ubuntuzfs03:~# zfs set dedup=on zpool1/cifs/dedup_storage


I’m copying the files over 100mbit LAN connection, so the 11.1 MB/s is reasonable:



Total size of files (same 2 large files copied multiple times)




Math
----
47698814976 bytes of data (files and folders included)
47698814976 / 4096 = 11,645,219 data blocks

1279193040 bytes arc_meta_used
1279193040 meta bytes / 11645219 data blocks           =  109 meta bytes/per 4k data block
1279193040 meta bytes / 47698814976 bytes of data      =  0.0268181304010097 bytes of meta /per bytes of data  (2.7%)

So by that math, 2TB of disk space
(depending on how manufacturer calculates 1TB)
2,199,023,255,552 bytes of data would require AT LEAST 59,373,627,900 bytes or about 55.3 Gigabytes of RAM allocated to arc_meta_limit.
(owch)

Deleting files (for some reason) sends the arc_meta_used up even higher.
I highlight all the files and delete them at once and arc_meta_used goes up to
1457235528 bytes arc_meta_used

So to recalculate,
1457235528 meta bytes / 11645219 data blocks           =  126 meta bytes/per 4k data block
1457235528 meta bytes / 47698814976 bytes of data      =  0.0305507700502249 bytes of meta /per bytes of data  (3.1%)

Just to be safe, if you are going to use 4k blocks, I would go with 5%
2,199,023,255,552 bytes of data would require AT LEAST 109,951,162,777.6 bytes or about 102.4 Gigabytes of RAM allocated to arc_meta_limit.
(super owch)

Change the record size to 16K:
root@ubuntuzfs03:~# zfs set recsize=16K zpool1/cifs/dedup_storage

After copying the files, dedup ratio and AVAIL space report the same values, but that is to be expected if you are just
copying the same files over and over again.

same total bytes in files, but arc_meta_used comes out different:
47698814976 bytes of data (files and folders included)
47698814976 / 4096 = 11,645,219 data blocks

bytes arc_meta_used
522642072 meta bytes / 11645219 data blocks            =  45 meta bytes/per 16k data block
522642072 meta bytes / 47698814976 bytes of data       =  0.0109571290662666 bytes of meta /per bytes of data  (1.1%)

Interestingly, the arc_meta_used value did not spike as much during the delete of the 16K blocks, it reported 524992920.

The math I’m using is a little flawed, because it does not take into account how much of the arc_meta_used is not related
to dedup. Probably I could turn off dedup, copy the same files again, and use that as a baseline, but I feel fairly comfortable
saying:

TLDR summary:
  • you need 5%   of total storage (or more) for 4K block size
  • you need 2.5% of total storage (or more) for 16K block sizes
  • deletes will always be slow, even if you have enough RAM. Imagine slow, and then multiply that times 10. Luckily it happens in the background, but if you are on a quad core or less machine it will slow everything to a crawl. If you don't have enough RAM it is slow times 100. NOTE: I have experienced complete system locks deleting multi GB files on Ubuntu. I believe this was supposed to be fixed on Solaris, but apparently hasn't made it into the Ubuntu ZFS yet, so be warned. 
  • 97% of the time you will be better off using ONLY compression


Your mileage will definitely vary, so you will have to keep an eye on the reserved vs. runtime values and adjust accordingly.

ZFS supports larger block sizes, up to 128K, but the larger your block size the lower dedup ratio you are
going to see. (Unless you are ONLY storing multiple copies of the same large files, in which case just
go with 128K the max.)

<edit 2013-08-07> as David pointed out, you can see memory usage reported by ZFS by using 'zpool status -D'


Friday, January 11, 2013

ZFS Windows Monitor / Replication Tool version 1.0

https://sourceforge.net/projects/windowszfsadmin/


Its in an early stage, but the functionality was enough that it seemed to warrant a v1.0 release.
At this stage in the project, you can:

Monitor zpools for errors across multiple servers
Get email notification/alert if an error is detected on any zpool
View ZFS filesystems for a zpool
View snapshots for a ZFS filesystem (with multi-select delete option)

Replication a filesystem from one machine to another continuously using ZFS send/receive.

I'm not particularly happy about having to scrape text from a (minimized) ssh command in a cmd shell but I don't have a viable alternative at this point.


Making Gumbo with Hyper-V, ZFS, Ubuntu, and Windows



Use case: HTPC/fileserver
ZFS (kernel mode) inside Ubuntu 12.04 VM on Hyper-V on Windows 8 connected to physical drives

Advantages:
·         samba server software on Ubuntu: $0
·         Ubuntu 12.04 cost: $0
·         ZFS (www.zfsonlinux.org) cost: $0
·         No raid card required (if all drives can connect to motherboard via SATA/eSATA/USB) $0
·         Keep your HTPC media files safe and secure with ZFS snapshots, checksums (scrub), rsync backups, etc. “previous versions” from windows explorer still works with a network drive as long as you have snapshots in ZFS.
·         Play media files through windows mapped network drive (samba) from Ubuntu VM
without any additional network traffic on your home network
·         Share media files through FTP/samba with your mobile/handheld devices over wifi in your house
·         Rest easier with ZFS raidz/mirror filesystems behind your media files.
·         xrdp in Ubuntu 12.04 is very functional and lets you have a Windows and Ubuntu desktop running simultaneously (especially true if you have 2+ monitors)
·         lower energy costs by combining fileserver, gaming pc, media player in one box
·         You can use USB drives as mirrored/raidz backups that are portable to any server running ZFS (USB 2.0 has slow read/write but it works)

Disadvantages:
·         Complexity of setting up and installing everything increased – average home user cannot handle setting up Hyper-V, VM’s, Ubuntu, or ZFS command line administration.
·         No commercial application for this, due to nightmare of supporting so many moving parts and licensing issues

Use case:
ZFS (kernel mode) inside Ubuntu 12.04 VM on Hyper-V Server 2008 R2/2012 connected to physical drives/RAID logical volumes

Advantages:
·         iscsitarget iSCSI server software on Ubuntu: $0
In our limited real world testing, iscsitarget on Ubuntu beats Windows iSCSI target and Starwind in terms of performance
·         nfs-kernel-server software on Ubuntu: $0
·         samba server software on Ubuntu: $0
·         Ubuntu 12.04 cost: $0
·         ZFS (www.zfsonlinux.org) cost: $0
·         Hyper-V Server (2008 R2 or 2012) cost : $0*
·         Replicating all your VHD’s, VHDX’s, and VMDK’s (if you are using the nfs server to host ESXi files) or entire iSCSI targets can be done with ZFS snapshots/send/receive for $0 at crash consistent states. Incremental block level changes to filesystem replication = much less network and disk overhead. Obviously not a replacement for Veeam (or similar product) but it’s free and not very complicated to set up.
·         Consolidate your hypervisor and fileserver on a single computer to reduce costs/network traffic and free up bandwidth for user connection to VMs. No need to buy expensive 10gb Ethernet connections, fiber channel SAN connections, or teaming aware switches.
·         Windows drivers are used to control hardware, which means increased compatibility over native Ubuntu or (even worse) Solaris and gives you more options when it comes to hardware RAID controllers (including those awful HP ones they love to put in low end server hardware) and tape libraries.
·         Most VM’s are fairly compressible. ZFS allows your iSCSI target to be hosted on a compressed ZFS filesystem (lzjb, gzip) without windows knowing about it. This allows you to “over commit” your NTFS iSCSI targets to some degree vs physical ZFS storage space. This is especially true for VMs with large SQL Server, Sybase, or Oracle databases. LZJB compression in ZFS performs very well (it runs circles around Windows folder compression).
·         Hyper-V Server (either version) is easier to get installed on whiteboxes / non-server hardware you may have leftover or extra lying around that you want to turn into a test environment
·         ZFS will allow you to turn a couple fast SSD’s into a ZIL log device and ARC2 cache device and reduce the amount of “file i/o” cache RAM required for decent performance.
·         The ability to create copies of entire filesystems as clones (ZFS snapshot -> ZFS clone) makes it really easy to create a test copy of any VM(s) without requiring much additional disk space for testing updates/upgrades/patches or creating a testing/qa environment
·         Easy to make a backup of your fileserver’s boot/root drive since it’s a VHD file.


Disadvantages:

·         Speed is slower than a dedicated hypervisor and a dedicated fileserver over fast (10gb/fiber) connection
·         Clustering in Hyper-V is designed around a SAN solution physically separate from your hypervisors (iSCSI or fiber connected)
·         Large scale production environments would be much better off with an enterprise SAN with commercial support (Solaris/Oracle, EMC, HP, etc) but that is (usually) a prohibitively expensive investment for small to medium size businesses in a down economy
·         * Hyper-V Server does not have a GUI and is a pain in the buttocks to manage. If you’re going to spend money on anything, Windows Server Datacenter edition would be my choice here. (about $4k to $5k per socket) The benefit of datacenter also being unlimited windows server VM’s (license covered via datacenter licenses of hypervisor). Also Hyper-V Server does not (as far as I can tell) allow you to set up network teaming like Server 2012 does.