{"id":3447,"date":"2014-01-26T00:58:32","date_gmt":"2014-01-26T06:58:32","guid":{"rendered":"http:\/\/icesquare.com\/wordpress\/?p=3447"},"modified":"2019-02-17T15:29:49","modified_gmt":"2019-02-17T21:29:49","slug":"zfs-compression-lz4-vs-lzjb","status":"publish","type":"post","link":"https:\/\/icesquare.com\/wordpress\/zfs-compression-lz4-vs-lzjb\/","title":{"rendered":"ZFS Compression: lz4 VS lzjb"},"content":{"rendered":"<p>ZFS offers a new compression method in the latest version: lz4. It claims to be better than lzjb. Since lzjb is pretty good already, I am curious to find out how good will lz4 be comparing to lzjb. According to my tests, lz4 is performing better than lzjb in terms of spacing saving and I\/O, but not too much.<\/p>\n<h3>lz4 VS lzjb: Space Saving<\/h3>\n<p>\nLong story short, here is what I did. I set up two servers with brand new ZFS settings. One server is set to lzjb, and the other server is set to lz4. Both servers have exact the same hardware, software, operating system etc. Both of them are loaded with the same set of data (10TB) via rsync and rsyncd. These data are real data that I use everyday, which includes office documents (PDF, Word, Excel), photos(Raw and JPEG), music(mp3), video(mpeg), zip, source codes, binary applications, database (MySQL, Redis), webserver files (PHP, HTML, CSS), etc. Notice that some of these files are already compressed (such as jpeg, zip etc), and the file types are not evenly distributed (e.g., 40% of the files are jpeg, 25% are docs, 10% are zip, 5% are something else). I want to make a test in a more realistic scenario.\n<\/p>\n<p>Also, all ZFS settings are set BEFORE loading the data. This will ensure that all data on the same server share the same compression settings. Below is the summary of the used space. Keep in mind that the space saving test is independent to the hardware, such as CPU type, memory, speed of the disks, etc. Just like running the same command to compress the same set of files in two systems. We expect the result will have the same size. The only difference will be the time spent on compressing the data.<\/p>\n<pre>\r\n#ZFS with lzjb\r\ndf\r\nFilesystem    512-blocks        Used     Avail Capacity  Mounted on\r\nstorage\/data 23007987368 22996620466  11366902   100%    \/storage\/data\r\n\r\n#Used space: 22996620466 blocks = 10965.6 GB\r\n<\/pre>\n<pre>\r\n#ZFS with lz4\r\ndf\r\nFilesystem    512-blocks        Used      Avail Capacity  Mounted on\r\nstorage\/data 31527470077 22942284913 8585185164    73%    \/storage\/data\r\n\r\n#Used space: 22942284913 blocks = 10939 GB\r\n<\/pre>\n<p>I found that for 10TB of data, the server with lzjb uses 26GB more space than lz4, which translate to 0.23% (26GB out of 10TB). The difference is quite small and not too significant. However, when your ZFS is nearly full or you are too busy to upgrade your system, the extra saving may matter a lot.<\/p>\n<h3>lz4 VS lzjb: Time Saving<\/h3>\n<p>I am also curious to know how much time I will save by switching from lzjb to lz4. Therefore I did another simple test. First, I generated a 1GB of random data and wrote to the lzjb system. After that, I destroyed the zpool and rebuilt the zpool with lz4. This will eliminate other factors such as hardware, network traffic etc, because both tests were done within the same system.\n<\/p>\n<pre>\r\n#ZFS with lzjb\r\ntime dd if=\/dev\/random of=\/storage\/data\/file.out bs=1M count=1000\r\n1000+0 records in\r\n1000+0 records out\r\n1048576000 bytes transferred in 23.725955 secs (44195313 bytes\/sec)\r\n\r\nreal    0m24.144s\r\nuser    0m0.024s\r\nsys     0m18.326s\r\n<\/pre>\n<pre>\r\n#ZFS with lz4\r\ntime dd if=\/dev\/random of=\/storage\/data\/file.out bs=1M count=1000\r\n1000+0 records in\r\n1000+0 records out\r\n1048576000 bytes transferred in 22.589257 secs (46419234 bytes\/sec)\r\n\r\nreal    0m22.802s\r\nuser    0m0.016s\r\nsys     0m18.273s\r\n<\/pre>\n<p>P.S. The \/dev\/random in FreeBSD is nothing like the one in Linux. It is very fast.<\/p>\n<p>By just upgrading from lzjb to lz4, the time is reduced from 24.144 to 22.802 seconds, which translate to 5.5% (1.342s out of 24.144s) improvement.<\/p>\n<p>This result also agrees with my overall experience: The improvement is small and not noticeable. In fact, I barely notice any performance improvement after switching from lzjb to lz4, which primarily includes transferring the files between Windows and FreeBSD-based ZFS system via Samba on a gigabit network. The I\/O speed are about the same. However, if you are talking about a busy server with lots of traffic, a 5% improvement will be something.<\/p>\n<p>Anyway, this is what I recommend. If lz4 is available in your ZFS version, use it. It can&#8217;t be wrong.<\/p>\n<pre>\r\nsudo zfs set compression=lz4 myzpool\r\n<\/pre>\n<p>&#8211;Derrick<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ZFS offers a new compression method in the latest version: lz4. It claims to be better than lzjb. Since lzjb is pretty good already, I am curious to find out <a class=\"more-link\" href=\"https:\/\/icesquare.com\/wordpress\/zfs-compression-lz4-vs-lzjb\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[94,146,7,144,6,109],"tags":[177],"class_list":["post-3447","post","type-post","status-publish","format-standard","hentry","category-computer-problems-computer-help-pc-support","category-everyday-computer-problem","category-freebsd","category-sever-problem","category-technology","category-zfs","tag-zfs"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p1sqzr-TB","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1380,"url":"https:\/\/icesquare.com\/wordpress\/how-to-improve-zfs-performance\/","url_meta":{"origin":3447,"position":0},"title":"How to Improve ZFS performance","author":"Derrick","date":"August 24, 2014","format":false,"excerpt":"First Edition: March 14, 2010 Last Edited: January 10, 2026 \u00a0 In this tutorial, I will show you how to improve the performance of your ZFS using the affordable consumer-grade hardware (e.g., Gigabit network card, standard SATA non-SSD hard drives, consumer-grade motherboard etc.). Many people found a problem on their\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2011\/01\/zfs_logo.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3438,"url":"https:\/\/icesquare.com\/wordpress\/zfs-performance-boostimprovement-how-i-push-the-io-speed-to-126mbps\/","url_meta":{"origin":3447,"position":1},"title":"ZFS Performance Boost\/Improvement: How I push the I\/O speed to 126MBps","author":"Derrick","date":"January 25, 2014","format":false,"excerpt":"This article is part of my main ZFS tutorial: How to improve ZFS performance. That article covers everything you need. If you already have the basic knowledge, or you just want to know how I push the I\/O speed to 120+ MBps, you can skip that article and read this\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":4798,"url":"https:\/\/icesquare.com\/wordpress\/vmvirtual-machine-file-vs-shared-folder-performance\/","url_meta":{"origin":3447,"position":2},"title":"[VM]Virtual Machine &#8211; File vs Shared Folder &#8211; Performance","author":"Derrick","date":"August 4, 2020","format":false,"excerpt":"I decide to move my Windows 10 system from a physical environment to a Linux based virtual environment. I am curious about what is the I\/O performance difference between VM image and Shared Folder. The reason why I prefer putting the data at Linux level because I can rsync the\u2026","rel":"","context":"In &quot;Technology&quot;","block_context":{"text":"Technology","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/"},"img":{"alt_text":"","src":"\/wordpress\/wp-content\/uploads\/2020\/08\/Windows10-on-ZFS-Wrote-on-File-on-ZFS.png","width":350,"height":200,"srcset":"\/wordpress\/wp-content\/uploads\/2020\/08\/Windows10-on-ZFS-Wrote-on-File-on-ZFS.png 1x, \/wordpress\/wp-content\/uploads\/2020\/08\/Windows10-on-ZFS-Wrote-on-File-on-ZFS.png 1.5x"},"classes":[]},{"id":4286,"url":"https:\/\/icesquare.com\/wordpress\/how-to-install-zfs-on-rhel-centos-7\/","url_meta":{"origin":3447,"position":3},"title":"How to install ZFS on RHEL \/ CentOS 7","author":"Derrick","date":"January 4, 2017","format":false,"excerpt":"A friend of mine likes to try ZFS on CentOS 7, therefore I decide to make a guide for him. The following instructions have been well tested on CentOS 7. Before you decide to put ZFS in a production use, you should be aware of the following: ZFS is originally\u2026","rel":"","context":"In &quot;Everyday Computer Problem&quot;","block_context":{"text":"Everyday Computer Problem","link":"https:\/\/icesquare.com\/wordpress\/category\/everyday-computer-problem\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2011\/01\/zfs_logo.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2689,"url":"https:\/\/icesquare.com\/wordpress\/zfs-compression-vs-deduplication-dedup-in-simple-english\/","url_meta":{"origin":3447,"position":4},"title":"ZFS: Compression VS Deduplication (Dedup) in Simple English","author":"Derrick","date":"February 14, 2012","format":false,"excerpt":"Last Edited: Jan 17, 2021 Many people are confused between the ZFS compression and ZFS deduplication because they are so similar. Both of them are designed to reduce the size of the data being stored in the storage. Let me explain the difference between them in simple English. 1. This\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1214,"url":"https:\/\/icesquare.com\/wordpress\/building-a-super-large-and-reliable-file-server-with-mixed-size-of-harddisks\/","url_meta":{"origin":3447,"position":5},"title":"Building a Super Large and Reliable File Server with Mixed Size of Harddisks","author":"Derrick","date":"January 17, 2011","format":false,"excerpt":"In this article, I am going to show you how to build a super large, ultra reliable, expandable file server with mixed size of hard drives. Here is my criteria: Large Storage Capacity. At this moment, the largest hard drive is 2TB. I am looking for at least 10TB. Great\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"\/wordpress\/wp-content\/uploads\/2011\/01\/zfs_logo-150x150.jpg","width":350,"height":200},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/3447","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/comments?post=3447"}],"version-history":[{"count":18,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/3447\/revisions"}],"predecessor-version":[{"id":4587,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/3447\/revisions\/4587"}],"wp:attachment":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}