{"id":241849,"date":"2021-05-04T16:00:39","date_gmt":"2021-05-04T13:00:39","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/setup-a-completely-unlimited-limits-conf-configuration-for-testing-servers-cloudsavvy-it\/"},"modified":"2021-05-04T16:00:39","modified_gmt":"2021-05-04T13:00:39","slug":"setup-a-completely-unlimited-limits-conf-configuration-for-testing-servers-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/setup-a-completely-unlimited-limits-conf-configuration-for-testing-servers-cloudsavvy-it\/","title":{"rendered":"#Setup a Completely Unlimited limits.conf Configuration for Testing Servers \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6aef7a8993e7a\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6aef7a8993e7a\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/setup-a-completely-unlimited-limits-conf-configuration-for-testing-servers-cloudsavvy-it\/#What_Is_limitsconf\" >What Is limits.conf?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/setup-a-completely-unlimited-limits-conf-configuration-for-testing-servers-cloudsavvy-it\/#Going_Unlimited\" >Going Unlimited<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/setup-a-completely-unlimited-limits-conf-configuration-for-testing-servers-cloudsavvy-it\/#Wrapping_up\" >Wrapping up<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#Setup a Completely Unlimited limits.conf Configuration for Testing Servers \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage alignnone size-full wp-image-4038\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/add8ac45.png?width=1200&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Bash Shell\" width=\"1400\" height=\"600\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>No Limits! We may all like no limits, but is it really such a good idea? Usually, when there are no limits, \u2018there\u2019ll be dragons\u2019. It is the same with limits.conf, though for testing servers, a truly unlimited limits.conf helps!<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"What_Is_limitsconf\"><\/span>What Is <i>limits.conf<\/i>?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <code>limits.conf<\/code> file contains resource limit settings for the Linux operating system. When your Linux computer was installed, the file was created as part of the installation and contained values for resources like virtual memory size, the maximum number of files, and more.<\/p>\n<p>These values are set to pre-specified limits to ensure that your Linux system will not easily overload. Otherwise, a rogue program or process could easily bring an otherwise performant system to a halt. Picture, for example, a situation where you set the maximum number of open files to unlimited, and a rogue process (being a process with a fault in it, or even a malicious piece of software like a virus or malware) now starts opening file after file on the system.<\/p>\n<p>Soon the system will run out of a resource it needs to handle all these open files. Whether it be the processor in your system (the CPU), or memory or even disk in some cases, where for example, we may have configured the maximum core file size as unlimited, and we run large processes in a system with much memory and little free remaining space, or a small root drive.<\/p>\n<p>In summary, using the <code>limits.conf<\/code> configuration file, a user (or sysadmin) can specify limits on resources available to the user and to the system.<\/p>\n<p>The format of the <code>limits.conf<\/code> file (which resides in <code>\/etc\/security\/<\/code>) is well defined. <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">General<\/a>ly, we will specify an <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>licable domain (like a user, a group, and even wildcards like <code>*<\/code>), a type (soft or hard limit), an item that the rule relates to (like the <code>nofile<\/code> item which defines the maximum number of open files, the <code>locks<\/code> item which defines the maximum number of file locks a user can hold, etc.) and finally a value (the actual setting\/maximum).<\/p>\n<p>The header of the <code>limits.conf<\/code> file clearly defines this in a suitable amount of detail:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10160\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/03\/6846fd2c.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The limits.conf header information\" width=\"763\" height=\"879\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>If you would like to read more about each specific item and other configuration settings with the <code>limits.conf<\/code> file, simply execute:<\/p>\n<pre>man limits.conf&#13;\n<\/pre>\n<p>At your terminal prompt.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10161\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/03\/90b1c8a1.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The limits.conf man page provides ample of information on limits.conf syntax, idioms and formatting\" width=\"1155\" height=\"520\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Going_Unlimited\"><\/span>Going Unlimited<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In general, for all intents and purposes, one should never go unlimited with <code>limits.conf<\/code>. Then, you may ask, why this article? Well, whenever there is a rule, there is a valid exception. The exception, in this case, is for testing servers. When you do testing or Quality Assurance work of any kind, you will often run into the limits of a system.<\/p>\n<p>Setting things up as unlimited, with a proper test\/QA framework setup to take care of system resource management, is a valid exception to keeping reasonable and system-specific limits inside <code>limits.conf<\/code>. For all other servers, as indicated, a per-server configuration is preferred and recommended.<\/p>\n<p>Without further ado, let us introduce a script which sets all variables and options in <code>limits.conf<\/code> to unlimited. This script is based on the GPLv2 licensed <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/mariadb-corporation\/mariadb-qa\/blob\/master\/setup_server.sh\">setup_server.sh<\/a> script in the mariadb-qa repository on GitHub. You may also like to explore this script for other files you can adopt towards unlimited settings for a test server setup, for example <code>\/etc\/sysctl.conf<\/code> settings and <code>\/etc\/systemd\/logind.conf<\/code><\/p>\n<p>To configure a server towards unlimited, execute the following script at the terminal prompt of the (test) server you want to configure as unlimited.<\/p>\n<p>Warning: please note that doing this on a production machine is likely not a good idea unless you have a solid understanding of the change you are making, as explained in part in this article, and are making it for a specific and valid reason. Doing this change also has significant security implications, and it is recommended to do this only on a machine that is behind a firewall and VPN, i.e., not a public-facing server. TLDR; Proceeding to implement this is at your own risk.<\/p>\n<p>You should also know that using a high number (greater than ~20000) for soft and hard nproc may cause system instability and hangs on Centos 7, though not on Ubuntu 18, 19, and 20. I, and other engineers with me, have used this setup for quite some time for testing servers, and for that application, it is ideal. Note how all of the settings are unlimited except <code>nofile<\/code> for which 1048576 is the maximum.<\/p>\n<pre>sudo bash -c \"cat &lt;&lt; EOF &gt; \/etc\/security\/limits.conf&#13;\n* soft core unlimited&#13;\n* hard core unlimited&#13;\n* soft data unlimited&#13;\n* hard data unlimited&#13;\n* soft fsize unlimited&#13;\n* hard fsize unlimited&#13;\n* soft memlock unlimited&#13;\n* hard memlock unlimited&#13;\n* soft nofile 1048576&#13;\n* hard nofile 1048576&#13;\n* soft rss unlimited&#13;\n* hard rss unlimited&#13;\n* soft stack unlimited&#13;\n* hard stack unlimited&#13;\n* soft cpu unlimited&#13;\n* hard cpu unlimited&#13;\n* soft nproc unlimited&#13;\n* hard nproc unlimited&#13;\n* soft as unlimited&#13;\n* hard as unlimited&#13;\n* soft maxlogins unlimited&#13;\n* hard maxlogins unlimited&#13;\n* soft maxsyslogins unlimited&#13;\n* hard maxsyslogins unlimited&#13;\n* soft locks unlimited&#13;\n* hard locks unlimited&#13;\n* soft sigpending unlimited&#13;\n* hard sigpending unlimited&#13;\n* soft msgqueue unlimited&#13;\n* hard msgqueue unlimited&#13;\nEOF\"&#13;\n<\/pre>\n<p>Once you executed this, simply restart your server to load all of the new configuration settings. You will not notice any difference, except that your test runs, if they were very resource-intensive, will not halt on various limit configuration issues anymore.<\/p>\n<p>That said, as indicated above, you will need, as part of your testing framework, a solid watchdog and server resources monitoring process which ensures that your server does not become overused, which often results in hangs and reboot requirements. In a future article, I may provide the basics for such a script from where you can expand to cover your own setup.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Wrapping_up\"><\/span>Wrapping up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>There are valid use cases for setting <code>\/etc\/security\/limits.conf<\/code> to every possible maximum. They are generally rare (with testing servers being a notable exception).<\/p>\n<p>In this article, we learned more about <code>limits.conf<\/code>: why it exists, and how to change its configuration. We explored the\u00a0<code>limits.conf<\/code>\u00a0format, syntax, and idioms and listed a simple script that can set all of our settings to unlimited.<\/p>\n<p>Even if you want to configure your server to lesser limits, the script is easy to adapt and can be integrated (as GPLv2 code as described) into your own scripts: simply change <code>unlimited<\/code> to the desired values. This is also a straightforward way to quickly configure a server to the desired values and thus unify and code your server farm <code>limits.conf<\/code> setup.<\/p>\n<p><strong>Enjoy!<\/strong>\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/10159\/setup-a-completely-unlimited-limits-conf-configuration-for-testing-servers\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#Setup a Completely Unlimited limits.conf Configuration for Testing Servers \u2013 CloudSavvy IT&#8221; No Limits! We may all like no limits, but is it really such a good idea? Usually, when there are no limits, \u2018there\u2019ll be dragons\u2019. It is the same with limits.conf, though for testing servers, a truly unlimited limits.conf helps! What Is limits.conf?&#8230;<\/p>\n","protected":false},"author":1,"featured_media":241850,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/add8ac45.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-241849","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/241849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=241849"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/241849\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/241850"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=241849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=241849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=241849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}