{"id":95783,"date":"2020-10-03T13:42:02","date_gmt":"2020-10-03T11:42:02","guid":{"rendered":"https:\/\/prohoster.info\/blog\/administrirovanie\/nastrojka-yadra-linux-dlya-glusterfs"},"modified":"2020-10-03T13:42:02","modified_gmt":"2020-10-03T11:42:02","slug":"nastrojka-yadra-linux-dlya-glusterfs","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/nastrojka-yadra-linux-dlya-glusterfs","title":{"rendered":"Configuring the Linux kernel for GlusterFS","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><b><i>This article's translation was prepared in anticipation of the course launch <noindex><a rel=\"nofollow\" href=\"https:\/\/otus.pw\/ODzb\/\">\u00abLinux Administrator. Professional\u00bb<\/a><\/noindex>.<\/i><\/b><\/p>\n<p><img decoding=\"async\" alt=\"Configuring the Linux kernel for GlusterFS\" src=\"\/wp-content\/uploads\/2020\/10\/d44c40c5e21142bff6fc56f2478f5e3b.png\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p>From time to time, questions arise regarding Gluster's recommendations for kernel configuration and whether it is necessary.<\/p>\n<p>Such necessity rarely arises. In most workloads, the kernel performs very well. However, there is a downside. Historically, the Linux kernel tends to consume a lot of memory if given the opportunity, including for caching as a primary means of boosting performance.<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<p>In most cases, this works excellently, but under heavy load, it can lead to issues. <\/p>\n<p>We have extensive experience with memory-intensive systems, such as CAD, EDA, and similar applications, which began to slow down under high loads. Occasionally, we encountered issues with Gluster. After careful observation of memory usage and disk wait times over several days, we experienced overloads, substantial iowait, kernel oops errors, and freezes, among others. <\/p>\n<p>This article is the result of many experiments with configuration parameters performed in various situations. Thanks to these parameters, not only has responsiveness improved overall, but cluster stability has significantly increased.<\/p>\n<p>When it comes to memory configuration, the first area to examine is the virtual memory (VM) subsystem, which has a multitude of options that can be quite confusing.<\/p>\n<h4>vm.swappiness<\/h4>\n<p>\nParameter <code>vm.swappiness<\/code> determines how much the kernel uses swapping in comparison to RAM. In the source code, it is also defined as \"tendency to steal mapped memory.\" A high swappiness value means that the kernel will be more inclined to unload mapped pages. A low swappiness value means the opposite: the kernel will unload pages from memory less frequently. In other words, the higher the value <code>vm.swappiness<\/code>, the more the system will utilize swap.<\/p>\n<p>Excessive swapping is undesirable, as large blocks of data are loaded into and out of RAM. Many argue that the swappiness value should be high, but in my experience, setting it to \"0\" leads to better performance.<\/p>\n<p>You can read more about it here \u2014 <noindex><a rel=\"nofollow\" href=\"http:\/\/lwn.net\/Articles\/100978\/\">lwn.net\/Articles\/100978<\/a><\/noindex> <\/p>\n<p>However, these settings should be applied cautiously and only after testing the specific application. For high-load streaming applications, this parameter should be set to '0'. Changing it to '0' improves the system's responsiveness.<\/p>\n<h4>vm.vfs_cache_pressure<\/h4>\n<p>\nThis parameter controls the memory consumed by the kernel for caching directory objects and index descriptors (dentry and inode).<\/p>\n<p>With a default value of 100, the kernel will attempt to free dentry and inode caches 'fairly' relative to the pagecache and swapcache. Reducing vfs_cache_pressure causes the kernel to retain dentry and inode caches. When the value is '0', the kernel will never clear the dentry and inode cache due to memory pressure, which can easily lead to an out-of-memory error. Increasing vfs_cache_pressure above 100 prioritizes the kernel to unload dentry and inode.<\/p>\n<p>When using GlusterFS, multiple users with large data volumes and many small files can easily consume significant amounts of RAM on the server due to inode\/dentry caching, which may lead to performance degradation as the kernel processes data structures in a system with 40 GB of memory. Setting this parameter above 100 has helped many users achieve fairer caching and improve the kernel's responsiveness.<\/p>\n<h4>vm.dirty_background_ratio and vm.dirty_ratio<\/h4>\n<p>\nThe first parameter (<code>vm.dirty_background_ratio<\/code>) defines the percentage of memory with dirty pages that should be reached before starting a background flush of dirty pages to disk. Until this percentage is reached, pages are not flushed to the disk. And when the flush begins, it is done in the background without interrupting running processes. <\/p>\n<p>The second parameter (<code>vm.dirty_ratio<\/code>) determines the percentage of memory that can be occupied by dirty pages before a forced flush begins. When this threshold is reached, all processes become synchronous (blocked), and they are not allowed to continue until the I\/O operation they requested is actually completed and the data is on disk. Under high I\/O loads, this causes issues since data caching is absent, and all processes performing I\/O are blocked waiting for I\/O. This leads to a large number of stuck processes, high load, unstable system operation, and poor performance.<\/p>\n<p>Reducing these parameter values causes data to be flushed to disk more frequently, instead of being held in RAM. This can help systems with a large amount of memory, where it is normal to flush a page cache of 45-90 GB to disk, resulting in huge wait times for frontend applications, decreasing overall responsiveness and interactivity.<\/p>\n<h4>\"1\" &gt; \/proc\/sys\/vm\/pagecache<\/h4>\n<p>\nThe page cache is a cache that stores the data of files and executable programs, meaning these are pages containing the actual content of files or block devices. This cache is used to reduce the number of reads from disk. A value of \"1\" means that 1% of RAM is used for caching, resulting in more read operations from disk than from RAM. It is not necessary to modify this parameter, but if you are paranoid about controlling page cache, you can utilize it.<\/p>\n<h4>\"deadline\" &gt; \/sys\/block\/sdc\/queue\/scheduler<\/h4>\n<p>\nThe I\/O scheduler is a component of the Linux kernel that handles read and write queues. Theoretically, for an intelligent RAID controller, it is better to use \"noop\" because Linux knows nothing about the physical geometry of the disk, so it is more efficient to let the controller, which knows the disk's geometry well, process requests as quickly as possible. However, it seems that \"deadline\" improves performance. More about schedulers can be read in the Linux kernel source documentation:<code> linux\/Documentation\/block\/*osched.txt<\/code>. And I also observed an increase in read throughput during mixed operations (many write operations).<\/p>\n<h4>\"256\" &gt; \/sys\/block\/sdc\/queue\/nr_requests<\/h4>\n<p>\nThe number of I\/O requests in the buffer before they are sent to the scheduler. The internal queue size of some controllers (queue_depth) is larger than the nr_requests of the I\/O scheduler, making it difficult for the I\/O scheduler to properly prioritize and merge requests. For deadline and CFQ schedulers, it is better when nr_requests is twice the internal queue size of the controller. Merging and reordering requests helps the scheduler to be more responsive under high load.<\/p>\n<h4>echo \"16\" &gt; \/proc\/sys\/vm\/page-cluster<\/h4>\n<p>\nThe page-cluster parameter controls the number of pages that are swapped at one time. In the example above, the value is set to \"16\" according to the stripe size of the RAID at 64 KB. This setting does not make sense with swappiness = 0, but if you set swappiness to 10 or 20, using this value will help when your RAID stripe size is 64 KB.<\/p>\n<h4>blockdev --setra 4096 \/dev\/<code>&lt;<\/code>devname<code>&gt;<\/code> (-sdb, hdc, or dev_mapper)<\/h4>\n<p>\nThe default block device settings for many RAID controllers often lead to terrible performance. Adding the above option configures read-ahead for 4096 * 512-byte sectors. At least for streaming operations, the speed is increased by filling the disk's built-in cache through read-ahead during the period used by the kernel to prepare I\/O. Data that will be requested in the next read can be cached. Excessive read-ahead can severely impact random I\/O for large files if it occupies potentially useful disk time or loads data beyond the cache.<\/p>\n<p>Here are a few more recommendations at the file system level. However, they have not yet been tested. Ensure that your file system is aware of the stripe size and the number of disks in the array. For example, this could be a RAID5 array with a stripe size of 64K across six disks (actually five, as one disk is used for parity). These recommendations are based on theoretical assumptions and compiled from various blogs\/articles by RAID experts.<\/p>\n<pre><code class=\"bash\">-&gt; ext4 fs, 5 disks, 64K stripe, units in 4K blocks\nmkfs -text4 -E stride=$((64\/4))\n-&gt; xfs, 5 disks, 64K stripe, units in 512-byte sectors\nmkfs -txfs -d sunit=$((64*2)) -d swidth=$((5*64*2))<\/code><\/pre>\n<p>\nFor large files, consider increasing the stripe sizes mentioned above.<\/p>\n<p><b>WARNING!<\/b> Everything described above is highly subjective for certain types of applications. This article does not guarantee any improvements without prior testing of the relevant applications by the user. It should only be applied if there is a need to improve overall system responsiveness or if it addresses current issues.<\/p>\n<h4>Additional materials:<\/h4>\n<p><\/p>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"http:\/\/dom.as\/2008\/02\/05\/linux-io-schedulers\/\">dom.as\/2008\/02\/05\/linux-io-schedulers<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"http:\/\/www.nextre.it\/oracledocs\/oraclemyths.html\">www.nextre.it\/oracledocs\/oraclemyths.html<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/lkml.org\/lkml\/2006\/11\/15\/40\">lkml.org\/lkml\/2006\/11\/15\/40<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"http:\/\/misterd77.blogspot.com\/2007\/11\/3ware-hardware-raid-vs-linux-software.html\">misterd77.blogspot.com\/2007\/11\/3ware-hardware-raid-vs-linux-software.html<\/a><\/noindex> <\/li>\n<\/ul>\n<p>\n<noindex><a rel=\"nofollow\" href=\"https:\/\/otus.pw\/ODzb\/\"><img decoding=\"async\" alt=\"Configuring the Linux kernel for GlusterFS\" src=\"\/wp-content\/uploads\/2020\/10\/1dc8da8d6b7c70ca909365e26ccb9a48.png\" style=\"display:block;margin: 0 auto;\" \/><\/a><\/noindex><\/p>\n<blockquote>\n<h3>Read more<\/h3>\n<p><\/p>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/511122\/\">Using nftables in Red Hat Enterprise Linux 8<\/a><\/noindex><\/li>\n<\/ul>\n<\/blockquote>\n<p>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/521480\/\">habr.com<\/a> <\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u0443\u0440\u0441\u0430 \u00abAdministrator Linux. Professional\u00bb. \u041f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u043e \u0442\u0443\u0442, \u0442\u043e \u0442\u0430\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f\u0445 Gluster \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u044f\u0434\u0440\u0430 \u0438 \u0435\u0441\u0442\u044c \u043b\u0438 \u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c. \u0422\u0430\u043a\u0430\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0440\u0435\u0434\u043a\u043e. \u041d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u043d\u0430\u0433\u0440\u0443\u0437\u043e\u043a \u044f\u0434\u0440\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e. \u0425\u043e\u0442\u044f \u0435\u0441\u0442\u044c \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430. \u0418\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u044f\u0434\u0440\u043e Linux \u043e\u0445\u043e\u0442\u043d\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u0438, \u0435\u0441\u043b\u0438 \u0435\u043c\u0443 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":95784,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-95783","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u0443\u0440\u0441\u0430 \u00abAdministrator Linux.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/nastrojka-yadra-linux-dlya-glusterfs\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u044f\u0434\u0440\u0430 Linux \u0434\u043b\u044f GlusterFS | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u0443\u0440\u0441\u0430 \u00abAdministrator Linux.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/nastrojka-yadra-linux-dlya-glusterfs\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-10-03T11:42:02+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-10-03T11:42:02+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Configuring the Linux Kernel for GlusterFS | ProHoster","description":"The translation of this article is prepared in anticipation of the launch of the 'Linux Administrator' course.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/nastrojka-yadra-linux-dlya-glusterfs","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u044f\u0434\u0440\u0430 Linux \u0434\u043b\u044f GlusterFS | ProHoster","og:description":"\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u0443\u0440\u0441\u0430 \u00abAdministrator Linux.","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/nastrojka-yadra-linux-dlya-glusterfs","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2020-10-03T11:42:02+00:00","article:modified_time":"2020-10-03T11:42:02+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"95783","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 10:57:48","updated":"2022-09-29 13:03:02","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/95783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=95783"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/95783\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media\/95784"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=95783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=95783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=95783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}