{"id":1380,"date":"2014-08-24T23:17:53","date_gmt":"2014-08-25T04:17:53","guid":{"rendered":"http:\/\/icesquare.com\/wordpress\/?p=1380"},"modified":"2026-01-10T00:21:46","modified_gmt":"2026-01-10T06:21:46","slug":"how-to-improve-zfs-performance","status":"publish","type":"post","link":"https:\/\/icesquare.com\/wordpress\/how-to-improve-zfs-performance\/","title":{"rendered":"How to Improve ZFS performance"},"content":{"rendered":"<style>\nh3{<br \/>\nfont-weight:bold;<br \/>\n}<br \/>\n<\/style>\n<div><strong>First Edition:<\/strong> March 14, 2010<\/div>\n<div><strong>Last Edited:<\/strong> January 10, 2026<\/div>\n<p>&nbsp;<\/p>\n<p>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.).<\/p>\n<p>Many people found a problem on their ZFS system. The speed is slow! It is slow to read or write files to the system. In this article, I am going to show you some tips on improving the speed of your ZFS file system.<\/p>\n<p>Notice that this article was originally based on ZFS on FreeBSD. Although most concepts can be applied to Linux, you may want to check out these two articles: <a href=\"\/wordpress\/zfs-linux-vs-freebsd\/\" target=\"_blank\" rel=\"noopener noreferrer\">ZFS: Linux VS FreeBSD<\/a> and <a href=\"\/wordpress\/how-to-fix-the-mess-created-by-zfs-on-linux-after-update\/\" target=\"_blank\" rel=\"noopener noreferrer\">ZFS On Linux Emergency Recovery Guide<\/a>. I always go back to the second article to rescure my ZFS data after rebooting my Linux server to a newer kernel.<\/p>\n<p>This article is about how to build a single node ZFS server. If you are interested in implementing multiple-nodes ZFS system \/ ZFS clusters, please check <a href=\"\/wordpress\/a-zfs-cluster-using-nfs\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a> for details.<\/p>\n<fieldset style=\"border: 1px solid #999; margin: 80px 10px 10px 10px; padding: 10px;\">\n<legend>Table of Content<\/legend>\n<ol>\n<li><a href=\"#section1\">A Good 64-bit CPU + Lots of Memory<\/a><\/li>\n<li><a href=\"#section2\">Tweaking the Boot Loader<\/a><\/li>\n<li><a href=\"#section3\">Use Disks with the Same Specifications<\/a><\/li>\n<li><a href=\"#section4\">Use a Powerful Power Supply <\/a><\/li>\n<li><a href=\"#section5\">Enable Compression<\/a><\/li>\n<li><a href=\"#section6\">Identify the Bottleneck<\/a><\/li>\n<li><a href=\"#section7\">Keep Your ZFS up to Date<\/a><\/li>\n<li><a href=\"#section8\">Understand How the ZFS Caching Works<\/a><\/li>\n<li><a href=\"#section9\">More Disk = Faster<\/a><\/li>\n<li><a href=\"#section10\">Use a Combination of Strip and RAIDZ If Speed Is Your First Concern.<\/a><\/li>\n<li><a href=\"#section11\">Distribute Your Free Space Evenly (How to Rebalance ZFS)<\/a><\/li>\n<li><a href=\"#section12\">Make Your Zpool Expandable<\/a><\/li>\n<li><a href=\"#section13\">Backup the Data on a Different Machine, Not on the Same Zpool<\/a><\/li>\n<li><a href=\"#section14\">Rsync or ZFS Send? <\/a><\/li>\n<li><a href=\"#section15\">Did You Enable Dedup? Disable It! <\/a><\/li>\n<li><a href=\"#section16\">Reinstall Your Old System<\/a><\/li>\n<li><a href=\"#section17\">Connect Your Disks via High Speed Interface <\/a><\/li>\n<li><a href=\"#section18\">Do Not Use up All Spaces<\/a><\/li>\n<li><a href=\"#section19\">Use AHCI, Not IDE <\/a><\/li>\n<li><a href=\"#section20\">Refresh Your Zpool<\/a><\/li>\n<li><a href=\"#section21\">Great Performance Settings<\/a><\/li>\n<li><a href=\"#section22\">My Settings<\/a><\/li>\n<\/ol>\n<\/fieldset>\n<p><a name=\"section1\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 1<\/p>\n<p>A Good 64-bit CPU + Lots of Memory<\/h3>\n<div class=\"alignright\"><\/div>\n<p style=\"padding-right: 20px; margin-right: 20px;\">Traditionally, we are told to use a less powerful computer for a file\/data server. That&#8217;s not true for ZFS. ZFS is more than a file system. It uses a lot of resources to improve the performance of the input\/output, such as compressing data on the fly. For example, suppose you need to write a 1GB file. Without enabling the compression, the system will write the entire 1GB file on the disk. With the compression being enabled, the CPU will compress the data first, and write the data on the disk after that. Since the compressed data is smaller, it takes shorter time to write to the disk, which results a higher writing speed. The same thing can be applied for reading. ZFS can cache the file for you in the memory, it will result a higher reading speed.<\/p>\n<p>That&#8217;s why a 64-bit CPU and higher amount of memory is recommended. I recommended at least a Quad Core CPU with 4GB of memory (Personally I use Xeon and i7, with at least 20GB of memory).<\/p>\n<p>Please make sure that the memory modules should have the same frequencies\/speed. If you mix them with different speed, try to group the memories with same speed together., e.g., Channel 1 and Channel 2: 1333 MHz, Channel 3 and Channel 4: 1600 MHz.<\/p>\n<p>Let&#8217;s do a test. Suppose I am going to create a 10GB file with all zero. Let&#8217;s see how long does it take to write on the disk:<\/p>\n<pre>#CPU: i7 920 (A 4 cores\/8 threads CPU from 2009) + 24GB Memory + FreeBSD 9.3 64-bit\r\n#dd if=\/dev\/zero of=.\/file.out bs=1M count=10k\r\n10737418240 bytes transferred in 6.138918 secs (1749073364 bytes\/sec)\r\n<\/pre>\n<p>That&#8217;s <strong>1.6GB\/s<\/strong>! Why is it so fast? That&#8217;s because it is a zero based file. After the compression, a compressed 10GB file may result in few bytes only. Since the performance of the compression is highly depended on the CPU, that&#8217;s why a fast CPU matters.<\/p>\n<p>Now, let&#8217;s do the same thing on a not-so-fast CPU:<\/p>\n<pre>#CPU: AMD 4600 (2 cores) + 5GB Memory + FreeBSD 9.3 64-bit\r\n#dd if=\/dev\/zero of=.\/file.out bs=1M count=10k\r\n10737418240 bytes transferred in 23.672373 secs (453584362 bytes\/sec)\r\n<\/pre>\n<p>That&#8217;s <strong>434MB\/s<\/strong> only. See the difference?<\/p>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section2\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 2<\/p>\n<p>Tweaking the Boot Loader Parameters<\/h3>\n<div class=\"alignright\"><\/div>\n<p><strong>Update<\/strong>: This section was written based on FreeBSD 8. As of today (February 12, 2017), the latest version is FreeBSD 11. I noticed that my FreeBSD\/ZFS works very stable even <strong>without any tweaking<\/strong>! In the other words, you may skip this section if you are using FreeBSD 8.2 or later.<\/p>\n<p>Many people complain about ZFS for its stability issues, such as kernel panic, reboot randomly, crash when copying large files (&gt; 2GB) at full speed etc. It may have something to do with the boot loader settings. By default, ZFS will not work smoothly without tweaking the system parameters system. Even FreeBSD (9.1 or earlier) claims that no tweaking is necessary for 64-bit system, my FreeBSD server crashes very often when writing large files to the pool. After trial and error for many times, I figure out few equations. You can tweak your boot loader (<strong>\/boot\/loader.conf<\/strong>) using the following parameters. Notice that I only tested the following on FreeBSD. Please let me know whether the following tweaks work on other operating systems.<\/p>\n<p>If you experiences kernel panic, crash or something similar, it could be the hardware problem, such as memory. I encourage to test all memory modules by using <a href=\"http:\/\/www.memtest.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Memtest86+<\/a> first. I wish someone told me about this few years ago. That would make my life a lot easier.<\/p>\n<p><strong>Warning:<\/strong> Make sure that you save a copy before doing anything to the boot loader. Also, if you experience anything unusual, please remove your changes and go back to the original settings.<\/p>\n<pre>#Assuming 8GB of memory\r\n\r\n#If Ram = 4GB, set the value to 512M\r\n#If Ram = 8GB, set the value to 1024M\r\nvfs.zfs.arc_min=\"1024M\"\r\n\r\n#Ram x 0.5 - 512 MB\r\nvfs.zfs.arc_max=\"3584M\"\r\n\r\n#Ram x 2\r\nvm.kmem_size_max=\"16G\"\r\n\r\n#Ram x 1.5\r\nvm.kmem_size=\"12G\"\r\n\r\n#The following were copied from FreeBSD ZFS Tuning Guide\r\n#https:\/\/wiki.freebsd.org\/ZFSTuningGuide\r\n\r\n# Disable ZFS prefetching\r\n# http:\/\/southbrain.com\/south\/2008\/04\/the-nightmare-comes-slowly-zfs.html\r\n# Increases overall speed of ZFS, but when disk flushing\/writes occur,\r\n# system is less responsive (due to extreme disk I\/O).\r\n# NOTE: Systems with 4 GB of RAM or more have prefetch enabled by default.\r\nvfs.zfs.prefetch_disable=\"1\"\r\n\r\n# Decrease ZFS txg timeout value from 30 (default) to 5 seconds.  This\r\n# should increase throughput and decrease the \"bursty\" stalls that\r\n# happen during immense I\/O with ZFS.\r\n# http:\/\/lists.freebsd.org\/pipermail\/freebsd-fs\/2009-December\/007343.html\r\n# http:\/\/lists.freebsd.org\/pipermail\/freebsd-fs\/2009-December\/007355.html\r\n# default in FreeBSD since ZFS v28\r\nvfs.zfs.txg.timeout=\"5\"\r\n\r\n# Increase number of vnodes; we've seen vfs.numvnodes reach 115,000\r\n# at times.  Default max is a little over 200,000.  Playing it safe...\r\n# If numvnodes reaches maxvnode performance substantially decreases.\r\nkern.maxvnodes=250000\r\n\r\n# Set TXG write limit to a lower threshold.  This helps \"level out\"\r\n# the throughput rate (see \"zpool iostat\").  A value of 256MB works well\r\n# for systems with 4 GB of RAM, while 1 GB works well for us w\/ 8 GB on\r\n# disks which have 64 MB cache.\r\n\r\n# NOTE: in v27 or below , this tunable is called 'vfs.zfs.txg.write_limit_override'.\r\nvfs.zfs.write_limit_override=1073741824\r\n<\/pre>\n<p>Don&#8217;t forget to reboot your system after making any changes. After changing to the new settings, the writing speed improves from 60MB\/s to 80MB\/s, sometimes it even goes above 110MB\/s! That&#8217;s a 33% improvement!<\/p>\n<p>By the way, if you found that the system still crashes often, the problem could be an uncleaned file system.<\/p>\n<p>After a system crashes, it may cause the file links to be broken (e.g., the system sees the file tag, but unable to locate the files). Usually FreeBSD will automatically run <strong>fsck<\/strong> after the crash. However, it will not fix the problem for you. In fact, there is no way to clean up the file system when the system is running (because the partition is mounted). The only way to clean up the file system is by entering the Single User Mode (a reboot is required).<\/p>\n<p>After you enter the single user mode, make sure that each partition is cleaned. For example, here is my <strong>df<\/strong> result:<\/p>\n<pre>Filesystem    Size    Used   Avail Capacity  Mounted on\r\n\/dev\/ad8s1a   989M    418M    491M    46%    \/          \r\ndevfs         1.0k    1.0k      0B   100%    \/dev       \r\n\/dev\/ad8s1e   989M     23M    887M     3%    \/tmp       \r\n\/dev\/ad8s1f   159G     11G    134G     8%    \/usr       \r\n\/dev\/ad8s1d    15G    1.9G     12G    13%    \/var        \r\n<\/pre>\n<p>Try running the following commands:<\/p>\n<pre>#-y: All yes\r\n#-f: Force\r\nfsck -y -f \/dev\/ad8s1a\r\nfsck -y -f \/dev\/ad8s1d\r\nfsck -y -f \/dev\/ad8s1e\r\nfsck -y -f \/dev\/ad8s1f\r\n<\/pre>\n<p>These command will clean up the affected file systems.<\/p>\n<p>After the clean-up is done, type <strong>reboot <\/strong>and let the system to boot to the normal mode.<\/p>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section3\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 3<\/p>\n<p>Use disks with the same specifications<\/h3>\n<div class=\"alignright\"><\/div>\n<p>A lot of people may not realize the importance of using exact the same hardware. Mixing different disks of different models\/manufacturers can bring performance penalty. For example, if you are mixing a slow disk (e.g., green disk) and a fast disk(e.g., performance disk) in the same virtual device (vdev), the overall speed will depend on the slowest disk. Also, different hard drives may have different sector size. For example, Western Digital releases a hard drive with 4k sector, while the older models use 512 byte. Mixing hard drives with different sectors can bring performance penalty too. Here is a quick way to check the model of your hard drive:<\/p>\n<pre>sudo smartctl -a \/dev\/sda | grep 'Sector Size'\r\n<\/pre>\n<p>Here is an example output:<\/p>\n<pre>Sector Sizes:     512 bytes logical, 4096 bytes physical\r\n<\/pre>\n<p>If you don&#8217;t have enough budget to replace all disks with the same specifications, try to group the disks with similar specifications in the same vdev, e.g.,<\/p>\n<pre>sudo zpool create myzpool \r\n   raidz \/dev\/slow_disk1 \/dev\/slow_disk2 \/dev\/slow_disk3 ...\r\n   raidz \/dev\/fast_disk1 \/dev\/fast_disk2 \/dev\/fast_disk3 ...\r\n<\/pre>\n<p>Suppose I have a group of hard drives with 4k sector (i.e., 4k = 4096 bytes = 2^12 bytes), which translate to ashift=12:<\/p>\n<pre>sudo zpool create myzpool -o ashift=12 raidz1 \/dev\/disk1 \/dev\/disk2 ...\r\n<\/pre>\n<p>You can also verify the ashift value using this command:<\/p>\n<pre>sudo zdb | grep shift\r\n<\/pre>\n<p>Let&#8217;s say we have a group of hard drives with 4k sector, we create two ZFS, one with ashift=12, and another one with the default value (ashift=9), here is the difference:<\/p>\n<pre>#Using default block size:\r\ndd if=\/myzpool\/data\/file.out of=\/dev\/null\r\n40960000000 bytes (41 GB) copied, 163.046 s, 251 MB\/s\r\n\r\n#Using native block size:\r\ndd if=\/myzpool\/data\/file.out of=\/dev\/null\r\n40960000000 bytes (41 GB) copied, 58.111 s, 705 MB\/s\r\n<\/pre>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section4\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 4<\/p>\n<p>Use a Powerful Power Supply<\/h3>\n<div class=\"alignright\"><\/div>\n<p>I recently built a Linux-based ZFS file system with 12 hard disks. For some reasons, it was pretty unstable. When I tried filling the pool with 12TB of data, the ZFS system crashed randomly. When I rebooted the machine, the error was gone. However, when I resumed the copy process again, the error happened on a different disk. In short, the disks failed randomly. When I checked the dmesg, I found something like the following. Since I didn&#8217;t have the exact copy, I grabbed something similar from the web:<\/p>\n<pre>[  412.575724] ata10.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6\r\n[  412.576452] ata10.00: BMDMA stat 0x64\r\n[  412.577201] ata10.00: failed command: WRITE DMA EXT\r\n[  412.577897] ata10.00: cmd 35\/00:08:97:19:e4\/00:00:18:00:00\/e0 tag 0 dma 4096 out\r\n[  412.577901]          res 51\/84:01:9e:19:e4\/84:00:18:00:00\/e0 Emask 0x10 (ATA bus error)\r\n[  412.579294] ata10.00: status: { DRDY ERR }\r\n[  412.579996] ata10.00: error: { ICRC ABRT }\r\n[  412.580724] ata10: soft resetting link\r\n[  412.844876] ata10.00: configured for UDMA\/133\r\n[  412.844899] ata10: EH complete\r\n[  980.304788] ata10.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6\r\n[  980.305311] ata10.00: BMDMA stat 0x64\r\n[  980.305817] ata10.00: failed command: WRITE DMA EXT\r\n[  980.306351] ata10.00: cmd 35\/00:08:c7:00:ce\/00:00:18:00:00\/e0 tag 0 dma 4096 out\r\n[  980.306354]          res 51\/84:01:ce:00:ce\/84:00:18:00:00\/e0 Emask 0x10 (ATA bus error)\r\n[  980.307425] ata10.00: status: { DRDY ERR }\r\n[  980.307948] ata10.00: error: { ICRC ABRT }\r\n[  980.308529] ata10: soft resetting link\r\n[  980.572523] ata10.00: configured for UDMA\/133\r\n<\/pre>\n<p>Basically, this message means the disk was failed during writing the data. Initially I thought it could be the SMART\/bad sectors. However, since the problem happened randomly on random disks, I think the problem could be something else. I have tried to replacing the SATA cable, power cable etc. None of them worked. Finally, I upgraded my power supply (450W to 600W), and the error was gone.<\/p>\n<p>FYI, here is the specs of my affected system. Notice that I didn&#8217;t use any component that required high-power such as graphic card etc.<\/p>\n<ul>\n<li>CPU: Intel Q6600<\/li>\n<li>Standard motherboard<\/li>\n<li>PCI RAID Controller Card with 4 SATA ports<\/li>\n<li>WD Green Drive x 12<\/li>\n<li>CPU fan x 1<\/li>\n<li>12&#8243; case fan x 3<\/li>\n<\/ul>\n<p>And yes, you will need a 600W power supply for such a simple system. Also, another thing worth to check is the power cable. Sometimes, using 15 pin power cable (the one for SATA drive) is better than 4pin to 15 pin converter (IDE to SATA converter).<\/p>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section5\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 5<\/p>\n<p>Compression<\/h3>\n<div class=\"alignright\"><\/div>\n<p>ZFS supports compressing the data on the fly. This is a nice feature that improves the I\/O speed &#8211; only if you have a high speed CPU (such as Quad core or higher). If your CPU is not fast enough, I don&#8217;t recommend you to turn on the compression feature, because the benefit from reducing the file size is smaller than the time spent on the CPU computation. Also, the compression algorithm plays an important role here. ZFS supports two compression algorithms, LZJB and GZIP. I personally use lz4 (See <a href=\"\/wordpress\/zfs-compression-lz4-vs-lzjb\/\" target=\"_blank\" rel=\"noopener noreferrer\">LZ4 vs LZJB<\/a> for more information) because it gives a better balance between the compression radio and the performance. You can also use GZIP and specify your own compression ratio (i.e., GZIP-N). FYI, I tried GZIP-9 (The maximum compression ratio available) and I found that the overall performance gets worse even on my i7 with 12GB of memory.<\/p>\n<p>There is no solid answer here because it all depends on what kind of files you store. Different files such as large file, small files, already compressed files (such as mp4 video) need different compression settings.<\/p>\n<p>If you cannot decide, just go with lz4. It can&#8217;t be wrong:<\/p>\n<pre>\r\n#Try to use lz4 first.\r\nsudo zfs set compression=lz4 mypool\r\n\r\n#If you system does not support lz4, try to use lzjb\r\nsudo zfs set compression=lzjb mypool\r\n<\/pre>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section6\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 6<\/p>\n<p>Identify the bottle neck<\/h3>\n<p>Sometimes, the limit of the ZFS I\/O speed is closely related to the hardware. For example, I set up a network file system (NFS) that is based on ZFS. Most of the time, I mainly transfer the data in between the servers, rather than within the same server. Therefore, the maximum I\/O speed I could get is the capacity of my network card, which is 125MB\/s. On average, I can reach to 100-110 MB\/s, which is pretty good for consumer grade network adapter.<\/p>\n<p>One day, I decide to explore the options on network bonding, which combines multiple network adapters together on the same server. In theory, it multiplies the bandwidth, and it will increase the ZFS I\/O speed.<\/p>\n<p>I set up network bonding on a machine with two network cards. It was a CentOS 7 box with bonding mode: 6 (adaptive load balancing). I was able to double the I\/O speed in both network and ZFS.<\/p>\n<pre>sudo cat \/proc\/net\/bonding\/bond0\r\nEthernet Channel Bonding Driver: v3.7.1 (April 27, 2011)\r\n\r\nBonding Mode: adaptive load balancing\r\nPrimary Slave: None\r\nCurrently Active Slave: em2\r\nMII Status: up\r\nMII Polling Interval (ms): 1\r\nUp Delay (ms): 0\r\nDown Delay (ms): 0\r\n\r\nSlave Interface: em1\r\nMII Status: up\r\nSpeed: 1000 Mbps\r\nDuplex: full\r\nLink Failure Count: 0\r\nPermanent HW addr: 20:27:47:91:a3:a8\r\nSlave queue ID: 0\r\n\r\nSlave Interface: em2\r\nMII Status: up\r\nSpeed: 1000 Mbps\r\nDuplex: full\r\nLink Failure Count: 0\r\nPermanent HW addr: 20:27:47:91:a3:aa\r\nSlave queue ID: 0\r\n\r\n<\/pre>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section7\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 7<\/p>\n<p>Keep your ZFS up to date<\/h3>\n<p>By default, ZFS will not update the file system itself even if a newer version is available on the system. For example, I created a ZFS file system on FreeBSD 8.1 with ZFS version 14. After upgrading to FreeBSD 8.2 (which supports ZFS version 15), my ZFS file system was still on version 14. I needed to upgrade it manually using the following commands:<\/p>\n<pre>sudo zfs upgrade my_pool\r\nsudo zpool upgrade my_pool\r\n<\/pre>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section8\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 8<\/p>\n<p>Understand How the ZFS Caching Works<\/h3>\n<p>ZFS has three types of cache, ARC and L2ARC. ARC is a ram-based cache, and L2ARC is disk-based cache. If you want to have a super-fast ZFS system, you will need A LOT OF memory. How much? I have a RHEL 7 based data center running NFS on top of a ZFS file system. Its the storage capacity is 48TB (8 x 8TB, running RAIDZ1), and I have 96GB of memory. The I\/O is about 1.5TB a day. Is the memory too much? I can tell you that sometimes it causes kernel problem because of running out of memory.<\/p>\n<p>In general, you will need lots of memory for ARC cache (ram-based), and L2ARC (disk-based) is optional. Depending on which operating system you are using (in my case, I use RHEL 7 and FreeBSD), the settings can be very different. Let&#8217;s talk about the arc cache first.<\/p>\n<p>By default, when you read a file from ZFS for the first time, ZFS will read the file from the disk. However if it is frequently used, ZFS will put the file in the ARC cache, which is your memory. Now we have something interesting. How much memory should you allow ZFS to use for ARC caching? You don&#8217;t want to use too little because it will increase accessing the disk, which will slow down the system. On the other hand, you don&#8217;t want to use too much because you want to reserve the memory for your operating system and other services. For FreeBSD, depend on which version you are using, it will either use 90% of the memory for ARC, or use all but 1GB of memory. For ZFS on Linux with RHEL 7, it will use about 50% of the memory.<\/p>\n<p>You can monitor the ARC usage here:<\/p>\n<pre>#FreeBSD\r\nzfs-stats -A\r\n\r\n------------------------------------------------------------------------\r\nZFS Subsystem Report                            Sun Feb 12 22:34:19 2017\r\n------------------------------------------------------------------------\r\n\r\nARC Summary: (HEALTHY)\r\n        Memory Throttle Count:                  0\r\n\r\nARC Misc:\r\n        Deleted:                                247.52m\r\n        Recycle Misses:                         0\r\n        Mutex Misses:                           68.86k\r\n        Evict Skips:                            778.88k\r\n\r\nARC Size:                               75.04%  16.76   GiB\r\n        Target Size: (Adaptive)         74.94%  16.74   GiB\r\n        Min Size (Hard Limit):          12.50%  2.79    GiB\r\n        Max Size (High Water):          8:1     22.33   GiB\r\n\r\nARC Size Breakdown:\r\n        Recently Used Cache Size:       73.41%  12.30   GiB\r\n        Frequently Used Cache Size:     26.59%  4.46    GiB\r\n\r\nARC Hash Breakdown:\r\n        Elements Max:                           1.40m\r\n        Elements Current:               68.50%  956.10k\r\n        Collisions:                             50.63m\r\n        Chain Max:                              7\r\n        Chains:                                 94.61k\r\n\r\n------------------------------------------------------------------------\r\n\r\n\r\n\r\n#ZFS on Linux\r\narcstat\r\n\r\n    time  read  miss  miss%  dmis  dm%  pmis  pm%  mmis  mm%  arcsz     c\r\n22:33:36     0     0      0     0    0     0    0     0    0    53G   53G\r\n\r\n\r\n<\/pre>\n<p>If you are using FreeBSD (the most advanced operating system in the world), you don&#8217;t need to tweak your system settings at all. ZFS is part of the FreeBSD kernel, and FreeBSD has excellent memory management. Therefore, you do not need to worry about ZFS using too much memory of your system. In fact, I&#8217;ve never crashed a FreeBSD system because of using too much memory. If you know how to do it, please show me how to do it.<\/p>\n<p>If you want to tweak the ARC size, you can do it via \/boot\/loader.conf:<\/p>\n<pre>#Min: 10GB\r\nvfs.zfs.arc_min=\"10000M\"\r\n\r\n#Max: 16GB\r\nvfs.zfs.arc_max=\"16000M\"\r\n<\/pre>\n<p>If you are using Linux, you may want to do some extra work to make your system stable. The default settings will get you to the bottom of the mountain, and you will need to do some climbing to reach the peak.<\/p>\n<p>First, you want to check the arc size:<\/p>\n<pre>arcstat (or arcstat.py depending on the version of your ZFS on Linux)\r\n\r\n<\/pre>\n<p>Now you will need to think about how much memory you want to reserve for ZFS. This is a tough question, and you can&#8217;t really expect Linux works like FreeBSD. Remember, Linux does not have a good memory management system like FreeBSD. It is very easy to crash the system if you do something wrong. That is one of the reasons why ZFS on Linux uses only 50% of the memory by default, because they know Linux (Linux is not a high performance operating system without some tweaking). This could be the reason why Red Hat (the maker of RHEL) does not support ZFS on Linux. Anyway, here is how to tweak the memory:<\/p>\n<pre>sudo nano \/etc\/modprobe.d\/zfs.conf\r\n\r\n#Min: 4GB\r\noptions zfs zfs_arc_min=4000000000\r\n\r\n#Max: 8GB (Don't exceed maximum amount of ram minus 4GB)\r\noptions zfs zfs_arc_max=8000000000\r\n<\/pre>\n<p>Don&#8217;t forget to reboot the server.<\/p>\n<p>Many people suggest using a 2GB rule, i.e., you reserve 2GB of memory for your system, and you leave the rest to ZFS. For example, if you have 32GB of memory, you may set the maximum to 30GB. Personally I don&#8217;t recommend this as it is too risky. I have multiple Linux boxes running as light NFS servers (each NFS server has 32GB of memory, four HDD with SSD disk as ZFS read cache, serves no more than 3 clients). For some odd reasons, I&#8217;ve noticed low memory warning and relatively high swap usage. Of course, this is casuing the kenel OOM killer to step in, killing my running processes until the Linux kernel can allocate memory again. Some people think this is a Linux kernel bug and they hope it will be fixed.<\/p>\n<p>When I set up Linux, I highly recommend having at least 20GB for the swap. If for any reason the ZFS is eating all of your available memory, you still have swap as backup. Otherwise your system will crash.<\/p>\n<p>FYI, tweaking the memory usage of ZFS ARC is more than entering some numbers. You need to think of the whole picture. Memory is a very valuable resource. You will need to decide how do use them effectively and efficiently. You can&#8217;t expect a single server running web server, database, NFS, virtual machine host all together on top of a ZFS system, and giving you a very high performance at the mean time. You need to distribute the workload across multiple servers. For example, here is what I use in a production environment:<\/p>\n<p>Server 1: A NFS host<br \/>\n&#8211; Running NFS only<br \/>\n&#8211; Have network bonding based on multiple network interfaces. This will multiply the bandwidth.<br \/>\n&#8211; Support other servers such as web server, databases, virtual machine host etc.<\/p>\n<p>Server 2: A virtual machine host<br \/>\n&#8211; Running Virtual Box<br \/>\n&#8211; Guest systems that have higher I\/O requirement are hosted in a local SSD drive with standard partitions (non-ZFS).<br \/>\n&#8211; Guest systems that have lower I\/O requirement are hosted on a different ZFS server, connected via NFS.<br \/>\n&#8211; All of the system memory will be used for running virtual machines.<\/p>\n<p>Server 3: A web server<br \/>\n&#8211; Running Apache + PHP + MySQL<br \/>\n&#8211; The PHP code is hosted locally.<br \/>\n&#8211; The large static files is hosted on the NFS server. In my case, I have over 20TB static content.<br \/>\n&#8211; All of the system memory will be used for running Apache \/ PHP \/ MySQL executions.<\/p>\n<p>Of course, I am not talking about ZFS does not work well with Apache \/ PHP \/ MySQL. I am just saying that in some extreme environments, the services should be hosted across multiple machines instead of one single machine.<\/p>\n<p>Now if you have extra resources (budget and extra SATA ports), you may consider using L2ARC cache. Basically L2ARC cache is a very fast hard drive (i.e., SSD). Think of it as a hybrid hard drive, it is a buffer for reading and writing.<\/p>\n<p>So what is the role of L2ARC to ARC? In general, the most frequently used files are stored in the ARC cache (ram). For the less frequently used files, or if the files are too large to fit in the arc cache, they will be stored in the L2ARC cache.<\/p>\n<p>To improve the reading performance:<\/p>\n<pre>sudo zpool add myzpool cache 'ssd device name'\r\n<\/pre>\n<p>To improve the writing performance:<\/p>\n<pre>sudo zpool add myzpool log \/dev\/ssd_drive\r\n<\/pre>\n<p>It was impossible to remove the log devices without losing the data until ZFS v.19 (FreeBSD 8.3+\/9.0+). I highly recommend to add the log drives as a mirror, i.e.,<\/p>\n<pre>sudo zpool add myzpool log mirror \/dev\/log_drive1 \/dev\/log_drive2\r\n<\/pre>\n<p>Now you may ask a question. How about using a ram disk as log \/ cache devices? First, ZFS already uses your system memory for I\/O, so you don&#8217;t need to set up a dedicated ram disk by yourself. Also, using a ram disk for log (writing) devices is not a good idea. When somethings go wrong, such as power failure, you will end up losing your data during the writing.<\/p>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section9\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 9<\/p>\n<p>More Disk = Faster<\/h3>\n<p>Do you know ZFS works faster on multiple devices pool than single device pool, even they have the same storage size?<\/p>\n<p align=\"center\"><a href=\"\/wordpress\/wp-content\/uploads\/2011\/11\/ZFS-Improve_Performance-1.png\"><img decoding=\"async\" title=\"Two drives is better than one single drive\" src=\"\/wordpress\/wp-content\/uploads\/2011\/11\/ZFS-Improve_Performance-1.png\" alt=\"\" width=\"500\" \/><\/a><\/p>\n<p>In general, if you are using RAIZ1, the more disk you have, the better the overall performance. Imagine we have two different setups: One with many disks, and another one with few disks. Assuming the disk are standard consumer grade SATA HDD disk (i.e., the maximum achievable speed is around 100MB\/s). Let&#8217;s say we need to calculate a checksum of a large file (e.g., 10GB). Here are the steps:<\/p>\n<ul>\n<li>CPU tells the ZFS to get the file<\/li>\n<li>The ZFS gets the file from each disk.<\/li>\n<li>Each disk is looking for the file:\n<ul>\n<li>Setup #1: It has many disks. Each disk contains a small part of the file. It takes shorter time to return the file to the CPU.<\/li>\n<li>Setup #2: It has fewer disks. Each disk contains a larger part of the file. It takes longer time to return the file to the CPU.<\/li>\n<\/ul>\n<\/li>\n<li>The CPU joins the pieces together and calculates the checksum.<\/li>\n<\/ul>\n<p>As you can tell, the bottleneck of such simple operation is not the CPU, but retrieving the file. The maximum speed of standard HDD is around 100MB\/s. So the more disks you have, the faster the I\/O. This is the reason why we need to rebalance the ZFS every once a while, because we want to keep the data distributed evenly across all disks.<\/p>\n<p>Here is a quick comparison. I had two servers available. Both had exact the same software installed (same OS\/ZFS\/DKMS\/kernel). One had a slower CPU and one had a faster CPU. The main difference was the ZFS setup. I performed MD5 checksum on 10 files (these files are available on both systems. The total size is 70GB). They were not in the memory cache before running the checksum. Here is the result:<\/p>\n<pre>Setup #1: Slower CPU (4th generation i7) + ZFS with more disks.\r\nCPU: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz\r\nMemory: 32GB\r\nOS: CentOS 7\r\nZFS Setup: 16 HDDs: RAIDZ1 (8 HDDs) + RAIDZ1 (8 HDDs), no cache\/log.\r\n\r\ntime md5sum *\r\nreal    2m47.139s\r\nuser    1m58.631s\r\nsys     0m31.239s\r\n<\/pre>\n<pre>Setup #2: Faster CPU  (8th generation i7) + ZFS with fewer disks.\r\nCPU: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz\r\nMemory: 32GB\r\nOS: CentOS 7\r\nZFS Setup: 3 HDDs: RAIDZ1 (3 HDDs), no cache\/log.\r\n\r\ntime md5sum *\r\nreal    6m40.768s\r\nuser    3m18.477s\r\nsys     0m33.790s\r\n<\/pre>\n<p>As you can tell, a good ZFS design makes a big difference. The first setup leaves the second one in dust (2.38x faster) even it has a slower CPU (4th generation i7 vs. 8th generation i7).<\/p>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section10\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 10<\/p>\n<p>Use a combination of Striped and RAIDZ if speed is your first concern.<\/h3>\n<div class=\"alignright\"><\/div>\n<p>Striped design also gives the best performance. Since it offers no data protection at all, you may want to use RAIDZ (RAIDZ1, RAIDZ2, RAIDZ3) or mirror to handle the data protection. However, there are too many choices and each of them offer different degree of performance and protection level. If you want a quick answer, try to use a combination of striped and RAIDZ. I posted a very detail of comparison among <a href=\"\/wordpress\/zfs-performance-mirror-vs-raidz-vs-raidz2-vs-raidz3-vs-striped\/\" target=\"_blank\" rel=\"noopener noreferrer\">Mirror, RAIDZ, RAIDZ2, RAIDZ3 and Striped here<\/a>.<\/p>\n<p>Here is an example of striped with RAIDZ:<\/p>\n<pre>#Command\r\nzpool create -f myzpool raidz hd1 hd2 hd3 hd4 hd5 \\\r\n                        raidz hd6 hd7 hd8 hd9 hd10\r\n\r\n#zpool status -v\r\n        NAME        STATE     READ WRITE CKSUM\r\n        storage     ONLINE       0     0     0\r\n          raidz1-0  ONLINE       0     0     0\r\n            hd1     ONLINE       0     0     0\r\n            hd2     ONLINE       0     0     0\r\n            hd3     ONLINE       0     0     0\r\n            hd4     ONLINE       0     0     0\r\n            hd5     ONLINE       0     0     0\r\n          raidz1-1  ONLINE       0     0     0\r\n            hd6     ONLINE       0     0     0\r\n            hd7     ONLINE       0     0     0\r\n            hd8     ONLINE       0     0     0\r\n            hd9     ONLINE       0     0     0\r\n            hd10    ONLINE       0     0     0\r\n\r\n<\/pre>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section11\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 11<\/p>\n<p>Distribute your free space evenly (How to rebalance ZFS)<\/h3>\n<p>One of the important tricks to improve ZFS performance is to keep the free space evenly distributed across all devices.<\/p>\n<p>Technically, if the structure of a zpool has not been modified or alternated, you should not need to worry about the data distribution because ZFS takes care of that for you automatically. However, when you add new devices to an existing zpool, that will be a different story.<\/p>\n<p align=\"center\"><a href=\"\/wordpress\/wp-content\/uploads\/2011\/11\/ZFS-Improve_Performance-2.png\"><img decoding=\"async\" title=\"Two drives is better than one single drive\" src=\"\/wordpress\/wp-content\/uploads\/2011\/11\/ZFS-Improve_Performance-2.png\" alt=\"\" width=\"500\" \/><\/a><\/p>\n<p>The following example was retrieved from one of my newly created system. I first created a pool and filled with data first (first group with 93% full). Later I added another vdev (second group). As you can see, the first group of disks is 93% full, and the second group of disks are only 0.2% full. Keep in mind that this number shows the capacity at the vdev level. In the other words, these numbers may not add up to 100. A perfectly distributed pool may have 80%\/80% in two vdevs.<\/p>\n<pre>zpool list -v\r\n<\/pre>\n<pre>#This is a wide table. You may need to scroll to the right.\r\n\r\nNAME                                     SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT\r\nstorage                                  138T  95.2T  43.1T          -         -     0%    68%  1.00x    ONLINE  -\r\n  raidz1                                 102T  95.1T  6.77T          -         -     1%  93.3%      -  ONLINE\r\n  raidz1                                36.4T  78.0G  36.3T          -         -     0%  0.20%      -  ONLINE\r\n<\/pre>\n<p>So what is the problem here? When ZFS retrieves the old data (data that was stored before adding the second vdev), the data is retrieved from the first vdev. When ZFS adding new data, the data will be stored in the second vdev (because the first vdev is almost full). ZFS won&#8217;t be able to fix this problem until some old data is deleted from the first vdev to free up the space. Otherwise ZFS will keep using the second vdev. For performance reason, we want ZFS to store the data across all vdevs instead of just one or two vdev. We want all harddrives to work together rather than some harddrives are working hard while the rest of the harddrives are doing nothing. In the other words, the more devices ZFS writes, the better the performance.<\/p>\n<p>There are two ways to rebalance your ZFS data distribution.<\/p>\n<pre>1. Back up your data\r\n2. Destroy the pool\r\n3. Rebuild the pool\r\n4. Put your data back\r\n<\/pre>\n<p>or<\/p>\n<pre>1. Copy your folder\r\n2. Delete your original folder\r\n3. Rename your folder back to the original name\r\n<\/pre>\n<p>The first method is the best because ZFS will balance the data completely. Depending on how much data do you have, it may take days to weeks to copy your data from one server to another server over a gigabit network (8.64TB per day, assuming the average network transfer speed is 100MB\/s). You don&#8217;t want to use scp to do it because you will need to re-do everything again if the process is dropped. In my case, I use rsync:<\/p>\n<p>(One single line)<\/p>\n<pre>#Run this command on the production server:\r\nrsync -avzr --delete-before backup_server:\/path_to_zpool_in_backup_server\/ \/path_to_zpool_in_production_server\/\r\n<\/pre>\n<p>Of course, netcat is a faster way if you don&#8217;t care about the security. (scp \/ rsync will encrypt the data during transfer).<br \/>\nSee <a href=\"\/wordpress\/how-to-improve-rsync-performance\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a> for further information<\/p>\n<p>The second method offers great flexibility because it doesn&#8217;t require another server. It can be performed at any time as long as you have enough free space available. However it will take longer time and the result won&#8217;t be as good as the first one. Here is an example:<\/p>\n<pre>rsync -avr my_folder\/ my_folder_copied\/\r\nrm -Rf my_folder\/\r\nmv my_folder_copied my_folder\r\n<\/pre>\n<p>Let&#8217;s me give you an example. Suppose we have two vdevs. Both of them are 100TB. We started with the vdev#1 first, fill it with data and we added vdev#2 later.<\/p>\n<table>\n<thead>\n<tr>\n<td>Event<\/td>\n<td>vdev#1<\/td>\n<td>vdev#2<\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Original (TB)<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Free Space (TB)<\/td>\n<td>10<\/td>\n<td>90<\/td>\n<\/tr>\n<tr>\n<td>Used Space (TB)<\/td>\n<td>90<\/td>\n<td>10<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>After copying 10TB data<\/td>\n<td>5<\/td>\n<td>5<\/td>\n<\/tr>\n<tr>\n<td>Free Space (TB)<\/td>\n<td>5<\/td>\n<td>85<\/td>\n<\/tr>\n<tr>\n<td>Used Space (TB)<\/td>\n<td>95<\/td>\n<td>15<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>After deleting the original 10TB data<\/td>\n<td>10<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>Free Space (TB)<\/td>\n<td>15<\/td>\n<td>85<\/td>\n<\/tr>\n<tr>\n<td>Used Space (TB)<\/td>\n<td>85<\/td>\n<td>15<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>As you can see, the capacity of used space changes from 90%\/10% to 85%\/15% after these operations. It will take several trials to make these two numbers the same.<\/p>\n<p>Keep in mind that when you clone the data, you need to make sure that the vdev1 (the old vdev) has enough free space to store the data (ZFS always splits the data evenly and stores them in all vdevs). Otherwise the cloned data will be written in vdev2, which is not what we want.<\/p>\n<p>FYI, this is what I have after copying and deleting multiple large folders, one at a time. The capacities of both vdev had improved from from 93%\/0% to 72%\/60%.<\/p>\n<pre>#Original:\r\n#Group 1 capacity was 93%\r\n#Group 2 capacity was 0%\r\nNAME                                     SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT\r\nstorage                                  138T  95.2T  43.1T          -         -     0%    68%  1.00x    ONLINE  -\r\n  raidz1                                 102T  95.1T  6.77T          -         -     1%  93.3%      -  ONLINE\r\n  raidz1                                36.4T  78.0G  36.3T          -         -     0%  0.20%      -  ONLINE\r\n<\/pre>\n<pre>#After copying and deleting all larger folders one at a time\r\n#Group 1 capacity becomes 72%\r\n#Group 2 capacity becomes 60%\r\nNAME                                     SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT\r\nstorage                                  138T  94.8T  43.5T        -         -     0%    68%  1.00x    ONLINE  -\r\n  raidz1                                 102T  73.1T  28.8T        -         -     0%  71.8%      -  ONLINE\r\n  raidz1                                36.4T  21.7T  14.7T        -         -     0%  59.6%      -  ONLINE\r\n<\/pre>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section12\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 12<\/p>\n<p>Make your pool expandable<\/h3>\n<p>Setting up a ZFS system is more than a one-time job. Unless you take a very good care of your storage like how supermodels monitor their body weights, otherwise you will end up using all of the available space one day. Therefore, it is a good idea to come up a good design that it can grow in the future.<\/p>\n<p>Suppose we want to build a server with maximum storage capacity, how will we start? Typically we try to put as many hard drives on a single machine as possible, i.e., it will be around 12 to 14 hard drives, which is what a typical consumer grade full tower computer case can hold. Let&#8217;s say we have 12 disks, here are couple setups which maximize storage capacity with a decent level of data safety:<\/p>\n<p>Design #1: RAIDZ2<\/p>\n<p><a href=\"\/wordpress\/wp-content\/uploads\/2014\/01\/RAIDZ2.jpg\"><img decoding=\"async\" title=\"RAIDZ\" src=\"\/wordpress\/wp-content\/uploads\/2014\/01\/RAIDZ2.jpg\" alt=\"\" width=\"500\" \/><\/a><\/p>\n<p>In this design, we create a giant pool and let the ZFS to take care of the rest. This pool will offer n-2 storage capacity which will allow up to 2 hard drives fail without losing any data.<\/p>\n<p>Design #2: RAIDZ1 + RAIDZ1<\/p>\n<p><a href=\"\/wordpress\/wp-content\/uploads\/2014\/01\/RAIDZ2-2.jpg\"><img decoding=\"async\" title=\"RAIDZ\" src=\"\/wordpress\/wp-content\/uploads\/2014\/01\/RAIDZ2-2.jpg\" alt=\"\" width=\"500\" \/><\/a><\/p>\n<p>In the second design, it offers the same level of storage capacity and a similar level of data protection. It allows up to one failure disk in each vdev. Keep in mind that the first design offers a great data protection. However, the second design will offer a better performance and greater flexibility in terms of future upgrade. Check out <a title=\"ZFS Performance: Mirror VS RAIDZ VS RAIDZ2 vs RAIDZ3 vs Striped\" href=\"\/wordpress\/zfs-performance-mirror-vs-raidz-vs-raidz2-vs-raidz3-vs-striped\/\" target=\"_blank\" rel=\"noopener noreferrer\">this article<\/a> if you want to learn more about the difference in ZFS design.<\/p>\n<p>First, let&#8217;s talk about the good and bad of the first design. It offers a great data security because it allows ANY two disks in the zpool to fail. However, it has couple disadvantages. ZFS works great when the number of disk of vdev is small. Ideally, the number should be smaller than 8 (Personally, I will stick with 5). In the first design, we put 12 disks in one single vdev, which will be problematic when the storage is getting full (&gt;90%). Also, when we talk about upgrading the entire zpool, we will need to upgrade each disk one by one first. We won&#8217;t be able to use the extra space until we replace all 12 disks. This may be an issue for those who do not have budget to get 12 new disks at a time.<\/p>\n<p>For the second design, it does not have the problem mentioned in the first design. The number of disk in each vdev is small (6 disks in each vdev). For those who don&#8217;t have plenty of budgets, it is okay to get six disks at a time to expand the pool.<\/p>\n<p>Here is how to create the second design:<\/p>\n<pre>sudo zpool create myzpoolname raidz \/dev\/ada1 \/dev\/ada2 ... \/dev\/ada6 raidz \/dev\/ada7 \/dev\/ada8 \/dev\/ada9 ... \/dev\/ada12\r\n<\/pre>\n<p>Here is how to expand the pool by replacing the hard drive one by one without losing any data:<\/p>\n<pre>1. Shutdown the computer, replace the hard drive and turn on the computer.\r\n\r\n2. Tell ZFS to replace the hard drive. This will force it to fill in the new hard drive with the existing data based on the check sum.\r\nzpool replace mypool \/dev\/ada1\r\n\r\n3. Resilver the pool\r\nzpool scrub mypool \r\n\r\n4 Shutdown the server and replace the second ard drive again. Repeat the steps until everything is done.\r\n\r\n5. zpool set autoexpand=on mypool \r\n\r\n6. Resilve the pool if needed.\r\nzpool scrub mypool \r\n<\/pre>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section13\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 13<\/p>\n<p>Backup your data on a different machine, not on the same pool<\/h3>\n<p>ZFS comes with a very cool feature. It allows you to save multiple copies of the same data in the same pool. This adds an additional layer on data security. However, I don&#8217;t recommend using this feature for backup purpose because it adds more work when writing the data to the disks. Also, I don&#8217;t think this is a good way to secure the data. I prefer to set up a mirror on a different server (Master-Slave). Since the chance of two machines fail at the same time is much smaller than one machine fails. Therefore, the data is safer in this settings.<\/p>\n<p>Here is how I synchronize two machines together:<\/p>\n<p>(Check out <a href=\"\/wordpress\/how-to-improve-rsync-performance\/\" target=\"_blank\" rel=\"noopener noreferrer\">this<\/a> guide on how to use rsyncd)<\/p>\n<p>Create a script in the slave machine: getContentFromMaster.sh<br \/>\n(One single line)<\/p>\n<pre>rsync -avzr -e ssh --delete-before master:\/path\/to\/zpool\/in\/master\/machine \/path\/to\/zpool\/in\/slave\/machine\r\n<\/pre>\n<p>And put this file in a cronjob, i.e.,<br \/>\n\/etc\/crontab<\/p>\n<pre>@daily root \/path\/to\/getContentFromMaster.sh\r\n<\/pre>\n<p>Now, you may ask a question. Should I go with strip-only ZFS (i.e., stripping only. No mirror, RAIDZ, RAIDZ2) when I set up my pool? Yes or no. ZFS allows you to mix any size of hard drive in one single pool. Unlike RAID[0,1,5,10] and concatenation, it can be any size and there is no lost in the disk space, i.e., you can connect 1TB, 2TB, 3TB into one single pool while enjoying the data-stripping (Total usable space = 6TB). It is fast (because there is no overhead such as parity etc) and simple. The only down side is that the entire pool will stop working if at least one device fails.<\/p>\n<p>Let&#8217;s come back to the question, should we employ simple stripping in production environment? I prefer not. Strip-only ZFS divides all data into all vdev. If each vdev is simply a hard drive, and if one fails, there is NO WAY to get the original data back. If something screws up in the master machine, the only way is to destroy and rebuild the pool, and restore the data from the backup. (This process can takes hours to days if you have large amount of data, say 6TB.) Therefore, I strongly recommend to use at least RAIDZ in the production environment. If one device fails, the pool will keep working and no data is lost. Simply replace the bad hard drive with a good one and everything is good to go.<\/p>\n<p>To minimize the downtime when something goes wrong, go with at least RAIDZ in a production environment (ideally, RAIDZ or strip-mirror).<\/p>\n<p>For the backup machine, I think using simple stripping is completely fine.<\/p>\n<p>Here is how to build a pool with simple stripping, i.e., no parity, mirror or anything<\/p>\n<pre>zpool create mypool \/dev\/dev1 \/dev\/dev2 \/dev\/dev3\r\n<\/pre>\n<p>And here is how to monitor the health<\/p>\n<pre>zpool status\r\n<\/pre>\n<p>Some websites suggest to use the following command instead:<\/p>\n<pre>zpool status -x\r\n<\/pre>\n<p>Don&#8217;t believe it! This command will return &#8220;all pools are healthy&#8221; even if one device is failed in a RAIDZ pool. In the other words, your data is healthy doesn&#8217;t mean all devices in your pool are healthy. So go with &#8220;zpool status&#8221; at any time.<\/p>\n<p>FYI, it can easily takes few days to copy 10TB of data from one machine to another through a gigabit network. In case you need to restore large amount of data through the network, use rsync, not scp. I found that scp sometimes fail in the middle of transfer. Using rsync allows me to resume it at any time.<\/p>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section14\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 14<\/p>\n<p>rsync or ZFS send?<\/h3>\n<div class=\"alignright\"><\/div>\n<p>So what&#8217;s the main difference between rsync and ZFS send? What&#8217;s the advantage of one over the other?<\/p>\n<p>Rsync is a file level synchronization tool. It simply goes through the source, find out which files have been changed, and copy the corresponding files to the destination. Also rsync is portable and cross-platform. Unlike ZFS, rsync is available in most Unix platforms. If your backup platform does not support ZFS, you may want to go with rsync.<\/p>\n<p>ZFS send is doing something similar. First, it takes a snapshot on the ZFS pool first:<\/p>\n<p>&nbsp;<\/p>\n<pre>zfs snapshot mypool\/vdev@20120417\r\n<\/pre>\n<p>After that, you can generate a file that contains the pool and data information, copy to the new server to restore it:<\/p>\n<pre>#Method 1: Generate a file first\r\nzfs send mypool\/vdev@20120417 &gt; myZFSfile\r\nscp myZFSfile backupServer:~\/\r\nzfs receive mypool\/vdev@20120417 &lt; ~\/myZFSfile\r\n<\/pre>\n<p>Or you can do everything in one single command line:<\/p>\n<pre>#Method 2: Do everything over the pipe (One command)\r\nzfs send mypool\/vdev@20120417 | ssh backupServer zfs receive mypool\/vdev@20120417\r\n<\/pre>\n<p>In general, the preparation time of ZFS send is much shorter than rsync, because ZFS already knows which files have been modified. Unlike rsync, a file-level tool, ZFS send does not need to go through the entire pool and find out such information. In terms of the transfer speed, both of them are similar.<\/p>\n<p>So why do I prefer rsync over ZFS send (both methods)? It&#8217;s because the latter one is not practical! In method #1, the obvious issue is the storage space. Since it requires generating a file that contains your entire pool information. For example, suppose your pool is 10TB, and you have 8TB of data (i.e., 2TB of free space), if you go with method #1, you will need another 8TB of free space to store the file. In the other words, you will need to make sure that at least 50% of free space is available all the time. This is a quite expensive way to run ZFS.<\/p>\n<p>What about method #2? Yes, it does not have the storage problem because it copies everything over the pipe line. However, what if the process is interrupted? It is a common thing due to high traffic in the network, high I\/O to the disk etc. Worst worst case, you will need to re-do everything again, say, copying 8TB over the network, again.<\/p>\n<p>rsync does not have these two problems. In rsync, it uses relatively small space for temporary storage, and in case the rsync process is interrupted, you can easily resume the process without copying everything again.<\/p>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section15\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 15<\/p>\n<p>Disable dedup if you don&#8217;t have enough memory (5GB memory per 1TB storage)<\/h3>\n<div class=\"alignright\"><\/div>\n<p>Deduplication (dedup) is a space-saving technology. It works at the block level (a file can have many blocks). To explain it in simple English, if you have multiple copies of the same file in different places, it will store only one copy instead of multiple copies. Notice that dedup is not the same as compression. Check out this article: <a title=\"ZFS: Compression VS Deduplication(Dedup) in Simple English\" href=\"http:\/\/icesquare.com\/wordpress\/zfs-compression-vs-deduplication-dedup-in-simple-english\/\" target=\"_blank\" rel=\"noopener noreferrer\">ZFS: Compression VS Deduplication(Dedup) in Simple English<\/a> if you wan to learn more.<\/p>\n<p>The idea of dedup is very simple. ZFS maintains an index of your files. Before writing any incoming files to the pool, it checks whether the storage has a copy of this file or not. If the file already exists, it will skip the file. With dedup enabled, instead of store 10 identical files, it stores one only copy. Unfortunately, the drawback is that it needs to check every incoming file before making any decision.<\/p>\n<p>After upgrading my ZFS pool to version 28, I enabled dedup for testing. I found that it really caused <strong>huge performance hit<\/strong>. The writing speed over the network dropped from 80MB\/s to 5MB\/s!!! After disabling this feature, the speed goes up again.<\/p>\n<pre>sudo zfs set dedup=off your-zpool\r\n<\/pre>\n<p>In general, dedup is an expensive feature that requires a lot of hardware resources. You will need 5GB memory per 1TB of storage (<a href=\"https:\/\/wiki.freebsd.org\/ZFSTuningGuide\" target=\"_blank\" rel=\"noopener noreferrer\">Source<\/a>). For example, if zpool is 10TB, I will need 50GB of memory! (Which I only have 12GB). Therefore, think twice before enabling dedup!<\/p>\n<p>Notice that it won&#8217;t solve all the performance problem by disabling the dedup. For example, if you enable dedup before and disable it afterward, all files stored during this period are dedup dependent, even dedup is disabled. When you need to update these files (e.g., delete), the system still needs to check again the dedup index before any processing your file. Therefore, the performance issue still exists when working with these affected files. For the new files, it should be okay. Unfortunately, there is no way to find out the affected dedup files. The only way is to destroy and re-build the ZFS pool, which will clear the list of dedup files.<\/p>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section16\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 16<\/p>\n<p>Reinstall Your Old System<\/h3>\n<div class=\"alignright\"><\/div>\n<p>Sometimes, reinstalling your old system from scratch may help to improve the performance. Recently, I decided to reinstall my FreeBSD box. It was an old FreeBSD box that was started with FreeBSD 6 (released in 2005, about 8 years ago from today). Although I upgraded the system every release, it already accumulated many junk and unused files. So I decide to reinstall the system from scratch. After the installation, I can tell that the system is more responsive and stable.<\/p>\n<p>Before you wipe out the system, you can export the ZFS tank using the following command:<\/p>\n<pre>sudo zpool export mypool\r\n<\/pre>\n<p>After the work is done, you can import the data back:<\/p>\n<pre>sudo zpool import mypool\r\n<\/pre>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section17\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 17<\/p>\n<p>Connect your disks via high speed interface<\/h3>\n<div class=\"alignright\"><\/div>\n<p>Recently, I found that my overall ZFS system is slow no matter what I have done. After some investigations, I noticed that the bottle neck was my RAID card. Here are my suggestions:<\/p>\n<p>1. Connect your disks to the ports with highest speed. For example, my PCI-e RAID card deliveries higher speed than my PCI RAID card. One way to verify the speed is by using dmesg, e.g.,<\/p>\n<pre>dmesg | grep MB\r\n\r\n#Connected via PCI card. Speed is 1.5Gb\/s\r\nad4: 953869MB  at ata2-master UDMA100 SATA 1.5Gb\/s\r\n\r\n#Connected via PCI-e card. Speed is 3.0 Gb\/s\r\nad12: 953869MB  at ata6-master UDMA100 SATA 3Gb\/s\r\n<\/pre>\n<p>In this case, the overall speed limit is based on the slowest one (1.5Gb\/s), even the rest of my disks are 3Gb\/s.<\/p>\n<p>2. Some RAID cards come with some advanced features such as RAID, linear RAID, compression etc. Make sure that you disable these features first. You want to minimize the workload of the card and maximize the I\/O speed. It will only slow down the overall process if you enable these additional features. You can disable the settings in the BIOS of the card. FYI, most of the RAID cards in $100 ranges are &#8220;software RAID&#8221;, i.e., they are using the system CPU to do the work. Personally, I think these fancy features are designed for Windows users. You really don&#8217;t need any of these features in Unix world.<\/p>\n<p>3. Personally, I recommend any brand except Highpoint Rocketraid because of the driver issues. Some of the Highpoint Rocketraid products are not supported by FreeBSD natively. You will need to download the driver from their website first. Their driver is version-specified, e.g., they have two different set of drivers for FreeBSD 7 and 8, and both of them are not compatible with each other. One day if they decide to stop supporting the device, then you either need to stick with the old FreeBSD, or buy a new card. My conclusion: <strong>Stay away from Highpoint Rocketraid.<\/strong><\/p>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section18\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 18<\/p>\n<p>Do not use up all spaces<\/h3>\n<p>Depending on the settings \/ history of your zpool, you may want to maintain the free space at a certain level to avoid speed-drop issues.<\/p>\n<p>Recently, I found that my ZFS system is very slow in terms of reading and writing. The speed dropped from 60MB\/s to 5MB\/s over the network. After some investigations, I found that the available space was around 300GB (out of 10TB), which is 3% left. Someone suggest that the safe threshold is about 10%, i.e., the performance won&#8217;t be impacted if you have at least 10% of the free space. I would say 5% is the bottom line, because I haven&#8217;t noticed any performance issues until it hits 3%.<\/p>\n<p>After I free up some spaces, the speed comes back again.<\/p>\n<p>I think it doesn&#8217;t make any sense not to use all of my space. So I decide to find out what caused this problem. The answer is the zpool structure.<\/p>\n<p>In my old setup, I put set up a single RAIDZ vdev with 8 disks. This gives me basic data security (up to one disk fails), and maximum disk spaces (Usable space is 7 disks). However, I notice that the speed drops a lot when the available free space was 5%.<\/p>\n<p>In my experiment setup, I decide to do the same thing with RAIZ2, i.e., it allows up to two disks fail, and the usable space is down to 6 disks. After filling up the pool, I found that it does not have the speed-drop problem. The I\/O speed is still fast even the free space is 10GB (That&#8217;s 0.09%).<\/p>\n<p>My conclusion: RAIDZ is okay up to 6 devices. If you want to add more devices, either use RAIDZ2 or split them into multiple vdevs:<\/p>\n<pre>#Suppose I have 8 disks (\/dev\/hd1 ... \/dev\/hd8).\r\n\r\n#One vdev\r\nzpool create myzpool raidz2 \/dev\/hd1 \/dev\/hd2 ... \/dev\/hd8\r\n\r\n#Two vdevs\r\nzpool create myzpool raidz \/dev\/hd1 ... \/dev\/hd4 raidz \/dev\/hd5 ... \/dev\/hd8\r\n<\/pre>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section19\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 19<\/p>\n<p>Use AHCI, Not IDE<\/h3>\n<p>Typically, there is a setting to control how the motherboard interacts with the hard drives: IDE or AHCI. If your motherboard has IDE ports (or manufactured before 2009), it is likely that the default value is set to IDE. Try to change to AHCI. Believe me, this litter tweak can save you countless of hours on debugging.<\/p>\n<p>FYI, <a href=\"\/wordpress\/freebsd-zfs-faulted-kernel-ada0ahcich4000-lost-device\/\" target=\"_blank\" rel=\"noopener noreferrer\">here is my whole story<\/a>.<\/p>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section20\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 20<\/p>\n<p>Refresh your pool<\/h3>\n<p>I had set up my zpool for five years. Over the past five years, I had performed lots of upgrade and changed a lot of settings. For example, during the initial set up, I didn&#8217;t enable the compression. Later, I set the compression to lzjb and changed it to lz4. I also enabled and disabled the dedup. So you can imagine some part of the data is compressed using lzjb, some data has dedup enabled. In short, the data in my zpool has all kind of different settings. That&#8217;s dirty.<\/p>\n<p>The only thing I can clean up is to destroy the entire zpool and rebuild the whole thing. Depending on the size of your data, it can take 2-3 days to transfer 10TB of data from one to another server, i.e., 4-6 days round trip. However, you will see the performance gain in long run.<\/p>\n<p>Keep in mind that this step is completely optional, and it all depends on your current ZFS pool status. I have a ZFS server running on professional hardware for over 10 years, high I\/O traffic every day, with over 50TB of data, and it is still running strong.<\/p>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section21\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 21<\/p>\n<p>Great performance settings<\/h3>\n<p>The following settings will greatly improve the performance of your ZFS pool. However, each of them comes with a price tag. Its like removing the air bag from your car. Yes, it will save few pounds here and few pounds there. However, when something goes wrong, it could be a nightmare. Do it at your own risk.<\/p>\n<h4>Disable the sync option<\/h4>\n<pre>sudo zfs set sync=disabled mypool\r\n<\/pre>\n<p>From the man page:<\/p>\n<p>&#8220;File system transactions are only committed to stable storage periodically. This option will give the highest performance. However, it is very dangerous as ZFS would be ignoring the synchronous transaction demands of applications such as databases or NFS. Administrators should only use this option when the risks are understood.&#8221;<\/p>\n<p>Keep in mind that disabling the sysnc options will force the synchronous writes to be treated as asynchronous writes, i.e., this will eliminating any double write penality (e.g., ZIL). In the other words, if you have ZIL (ZFS logs device), you are virtually by passing it.<\/p>\n<h4>Disable the checksum<\/h4>\n<pre>sudo zfs set checksum=off mypool\r\n<\/pre>\n<p>Disabling the checksum is like removing air bag from your car. Most people don&#8217;t do it but some people do for their own reason (e.g., Formula 1). It will save some CPU computation time, but won&#8217;t be a lot for each operation. However if you have a lot of data to write to the pool, saving a little bit in every write operation will end up a lot. There is only a catch: your data is not important and you don&#8217;t care the data integrity. For example, I do a lot of genomic analyses. Each analysis is lengthy (may last several days) and it generate lots of temporary files (e.g., output logs). Since those files are not important information in my case, I store them in a compressed, checksum disabled zpool partition to speed up the write process. Long story short. If you care your data, enable the checksum. If you don&#8217;t, disable it.<\/p>\n<h4>Disable the access time<\/h4>\n<pre>sudo zfs set atime=off mypool\r\n<\/pre>\n<p>From the man page:<\/p>\n<p>&#8220;Turning this property off avoids producing write traffic when reading files and can result in significant performance gains, though it might confuse mailers and other similar utilities.&#8221;<\/p>\n<h4>Customize the record size<\/h4>\n<p>The default record size of ZFS is 128k, meaning that ZFS will write 128k of data to a logical block. Imagine if there is only few changes in a block, what ZFS will do is to read the whole chunk, make the changes, and write the changes back to the disk (plus other overhead such as compression, checksum etc). Most database program prefers smaller size. This magic number is different for different types of engine.<\/p>\n<pre>#For MySQL MyISAM Engines\r\nsudo zfs create -o recordsize=8k mypool\/mysql_myisam\r\n\r\n#For MySQL InnoDB\r\nsudo zfs create -o recordsize=16k mypool\/mysql_innodb\r\n<\/pre>\n<p>To keep things simple, I create symplic links within the MySQL folder and link to the right place, e.g.,<\/p>\n<pre>#ls -al \/var\/lib\/mysql\r\nlrwxrwxrwx   1 root  root    36 Oct 17  2019 database1-&gt; \/mypool\/mysql_myisam\/database1\/\r\nlrwxrwxrwx   1 root  root    36 Oct 17  2019 database2-&gt; \/mypool\/mysql_innodb\/database2\/\r\n<\/pre>\n<p>Since ZFS caches the data in RAM, it may be wise to increase the amount of reserved memory for ZFS, and reduce the memory used by the database program. This will avoid the double caching, which is a waste. Plus ZFS does a way better job in terms of using memory, e.g., it compresses the data using lz4 on the fly, which not all databases do it.<\/p>\n<p>Similarly, you can do the same thing for virtual machine images or other applications that write a lot of small changes to large files:<\/p>\n<pre>sudo zfs create -o recordsize=16k mypool\/vm\r\n<\/pre>\n<h4>Redundant Metadata<\/h4>\n<p>Set the redundant_metadata to most will improve the performance of random writes. The default value of redundant_metadata is all.<\/p>\n<pre>sudo zfs set redundant_metadata=most mypool\r\n<\/pre>\n<h4>Enable the system attribute based xattrs<\/h4>\n<p>Storing xattrs as system attributes significantly decreases the amount of disk I\/O. (Not available on FreeBSD)<\/p>\n<pre>sudo zfs set xattr=sa mypool\r\n<\/pre>\n<div style=\"border-bottom: 1px dotted #999; margin: 10px 0px 10px 0px;\"><\/div>\n<p><a name=\"section22\"><\/a><\/p>\n<h3>Improve ZFS Performance: Step 22<\/p>\n<p>My Settings &#8211; Simple and Clean<\/h3>\n<p>I have set up over 50 servers based on ZFS. They all have different purposes. In general, they all share the same ZFS settings, and they can reach the hardware limit, e.g., ARC cache uses about 90% of the system memory, the network transfer speed maxes out the limit of the network card etc.<\/p>\n<pre>sudo zpool history\r\n\r\n#I like to use raidz, and each raidz vdev contains no more than 5 disks.\r\nzpool create -f storage raidz \/dev\/hd1 \/dev\/hd2 ... raidz \/dev\/hd6 \/dev\/hd7 ... raidz \/dev\/hd11 \/dev\/hd12\r\n\r\n#A partition for general purposes\r\nzfs create storage\/data\r\n\r\n#A partition for general web\r\nzfs create storage\/web\r\n\r\n#A partition for MySQL \/ MYISAM tables\r\nzfs create -o recordsize=8k storage\/mysql (MYISAM tables)\r\n\r\n#Some common settings\r\nzfs set compression=lz4 storage\r\nzfs set atime=off storage\r\nzfs set redundant_metadata=most storage\r\n\r\n#For Linux server\r\nzfs set xattr=sa storage\r\n<\/pre>\n<p>A simple nload when running rsync over a gigabit LAN:<\/p>\n<pre>(Bonding mode: 6, based on two gigabit network cards)\r\n#nload -u M\r\n\r\nOutgoing:\r\nCurr: 209.48 MByte\/s\r\nAvg: 207.50 MByte\/s\r\nMin: 198.66 MByte\/s\r\nMax: 209.53 MByte\/s\r\nTtl: 3755.46 GByte\r\n<\/pre>\n<p>I only uses two operating systems:<\/p>\n<pre>#Personal\r\nFreeBSD 10.3-RELEASE-p11 FreeBSD 10.3-RELEASE-p11 #0: Mon Oct 24 18:49:24 UTC 2016     root@amd64-builder.daemonology.net:\/usr\/obj\/usr\/src\/sys\/GENERIC  amd64\r\n\r\n\r\n#Work\r\nCentOS Linux release 7.3.1611 (Core)\r\nLinux 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU\/Linux\r\n<\/pre>\n<p>Most of the hard drives I use are consumer-grade. Typically, I buy the external one and remove the hard drive from the enclosure because of the lower cost. Sometimes when I need to use all of the SATA ports, I will use USB flash drive for the operating system (I have some older machines with USB 2.0 port only). As long as all of the frequently used files are in the ZFS pool, the performance is not a problem. Another thing you can is to install card size SSD drive on the mSATA port, and connect a regular hard drive to the eSATA port on the back of the motherboard using a long eSATA-SATA cable. That will help to maximize the number of hard drives. Most computer cases will fit 10-12 3.5&#8243; hard drives, some of them (e.g., Rosewill RSV-R4000) can hold 15 3.5&#8243; hard drives for under USD 100. Personally I was able to hold 18 3.5&#8243; hard drives using Rosewill RSV-R4000 with some modifications, plus 3 2.5&#8243; hard drives. The most powerful one will fit 18 hard drives with a price tag of USD 200.<\/p>\n<p>The amount of the memory is going to be tricky, as it depends on what applications you want to run on your server and how much memory will be consumed by the service. It also depends on how large is your ZFS pool capacity. Here are some of the servers I have set up:<\/p>\n<pre>#A light weight web (Apache+MySQL+PHP), and file server (Samba)\r\nCPU: Intel(R) Xeon(R) CPU E5-2440 v2 @ 1.90GHz (A mid-level server grade CPU from 2014)\r\nMemory: 4GB\r\nZFS Pool Capacity: 1.6TB\r\nOS: CentOS 7\r\nKernel: 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU\/Linux\r\n\r\n\r\n#A server for nightly backup\r\nCPU: Intel(R) Core(TM) i7 CPU K 875  @ 2.93GHz (A gaming-grade CPU from 2010)\r\nMemory: 8GB\r\nZFS Pool Capacity: 43TB\r\nOS: CentOS 7\r\nKernel: 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU\/Linux\r\n\r\n\r\n#A server for analyzing genomic data, with a very high CPU usage\r\nCPU: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (A gaming-grade CPU from 2015)\r\nMemory: 64GB\r\nZFS Pool Capacity: 8.5TB\r\nOS: CentOS 7\r\nKernel: 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU\/Linux\r\n\r\n\r\n#A heavy weight network file server\r\nCPU: Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz (A mid-level server grade CPU from 2012)\r\nMemory: 96GB\r\nZFS Pool Capacity: 53TB\r\nOS: CentOS 7\r\nKernel: 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU\/Linux\r\n\r\n\r\n#A heavy weight web server\r\nCPU: Intel(R) Xeon(R) CPU E3-1225 v3 @ 3.20GHz (An entry-level server grade CPU from 2013)\r\nMemory: 16GB\r\nZFS Pool Capacity: 1.8TB\r\nOS: CentOS 7\r\nKernel: 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU\/Linux\r\n\r\n\r\n#A light weight web (Apache+MySQL+PHP), and file server (Samba)\r\nCPU: Intel(R) Core(TM) i7 CPU 920  @ 2.67GHz  (A gaming-grade CPU from 2008)\r\nMemory: 24GB\r\nZFS Pool Capacity: 25TB\r\nOS: FreeBSD 10.3\r\nKernel: FreeBSD 10.3-RELEASE-p11 FreeBSD 10.3-RELEASE-p11 #0: Mon Oct 24 18:49:24 UTC 2016     root@amd64-builder.daemonology.net:\/usr\/obj\/usr\/src\/sys\/GENERIC  amd64\r\n\r\n\r\n#A low-end backup server\r\nCPU: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz (An entry-level CPU from 2007)\r\nMemory: 8GB\r\nZFS Pool Capacity: 15TB\r\nOS: FreeBSD 10.3\r\nKernel: FreeBSD 10.3-RELEASE-p11 FreeBSD 10.3-RELEASE-p11 #0: Mon Oct 24 18:49:24 UTC 2016     root@amd64-builder.daemonology.net:\/usr\/obj\/usr\/src\/sys\/GENERIC  amd64\r\n<\/pre>\n<p>If you are interested in implementing network-based ZFS, please check <a href=\"\/wordpress\/a-zfs-cluster-using-nfs\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a> for details.<\/p>\n<p>Enjoy ZFS.<\/p>\n<p>&#8211;Derrick<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>First Edition: March 14, 2010 Last Edited: January 10, 2026 &nbsp; In this tutorial, I will show you how to improve the performance of your ZFS using the affordable consumer-grade <a class=\"more-link\" href=\"https:\/\/icesquare.com\/wordpress\/how-to-improve-zfs-performance\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":1260,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_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":false,"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,69,109],"tags":[171,19,177,131],"class_list":["post-1380","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computer-problems-computer-help-pc-support","category-everyday-computer-problem","category-freebsd","category-sever-problem","category-technology","category-troubleshooting-technology","category-zfs","tag-freebsd","tag-performance","tag-zfs","tag-zpool"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p1sqzr-mg","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":3914,"url":"https:\/\/icesquare.com\/wordpress\/zfs-linux-vs-freebsd\/","url_meta":{"origin":1380,"position":0},"title":"Running ZFS on Linux: Things you should know and be aware of","author":"Derrick","date":"February 29, 2016","format":false,"excerpt":"First Published: Feb 29, 2016 Last Revised: January 10, 2026 ZFS is a next-generation file system renowned for its reliability and advanced features. However, due to legal and licensing issues, it is not included by default in most Linux distributions. Fortunately, you can still install (ZFS on Linux) with just\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":1380,"position":1},"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":[]},{"id":3438,"url":"https:\/\/icesquare.com\/wordpress\/zfs-performance-boostimprovement-how-i-push-the-io-speed-to-126mbps\/","url_meta":{"origin":1380,"position":2},"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":3447,"url":"https:\/\/icesquare.com\/wordpress\/zfs-compression-lz4-vs-lzjb\/","url_meta":{"origin":1380,"position":3},"title":"ZFS Compression: lz4 VS lzjb","author":"Derrick","date":"January 26, 2014","format":false,"excerpt":"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\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":4286,"url":"https:\/\/icesquare.com\/wordpress\/how-to-install-zfs-on-rhel-centos-7\/","url_meta":{"origin":1380,"position":4},"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":4202,"url":"https:\/\/icesquare.com\/wordpress\/centosrhel-7-no-zfs-after-updating-the-kernel\/","url_meta":{"origin":1380,"position":5},"title":"CentOS\/RHEL 7 &#8211; No ZFS After Updating the Kernel","author":"Derrick","date":"December 12, 2016","format":false,"excerpt":"Let's all agree with this fact: ZFS is foreign to Linux. It is not native. You can't expect that ZFS on Linux will run smoothly as FreeBSD or Solaris. Having using ZFS on Linux since 2013 (and ZFS on FreeBSD since 2009), I've noticed that ZFS does not like Linux\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":[]}],"jetpack_featured_media_url":"https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2011\/01\/zfs_logo.jpg","_links":{"self":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/1380","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=1380"}],"version-history":[{"count":393,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/1380\/revisions"}],"predecessor-version":[{"id":5076,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/1380\/revisions\/5076"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/media\/1260"}],"wp:attachment":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}