Notes about CONNTRACK_MAX and HASHSIZE in linux

Source: Internet
Author: User
Note the CONNTRACK_MAX and HASHSIZE in linux. if the concurrency increases during stress testing but the test cannot be completed, you can try to adjust the parameter vi/etc/sysctl. conf added before kernel2.6: net. ipv4.netfilter. ip_conntrack_max... note the CONNTRACK_MAX and HASHSIZE in linux. if the concurrency increases during stress testing but the test cannot be completed, you can try to adjust the parameter vi/etc/sysctl. conf added before kernel2.6: net. ipv4.netfilter. ip_conntrack_max = 655360. net. ipv4.netfilter. ip_conntrack_tcp_timeout_established = 180 add after kernel2.6: net. nf_conntrack_ma X = 655360 # net. nf_conntrack_max = 655360 can also be net. netfilter. nf_conntrack_tcp_timeout_established = 1200 sysctl-p/etc/sysctl. conf: error: "net. nf_conntrack_max "is an unknown key, you need to use modprobe to load the ip_conntrack module. lsmod check that the module has been loaded. Modprobe ip_conntrack -- the maximum number of trace connection entries allowed by CONNTRACK_MAX is the "task" that netfilter can simultaneously process in the kernel memory (connection trace entries) -- HASHSIZE: the default values of the size CONNTRACK_MAX and HASHSIZE of the Hasse table in the list of trace connection entries. generally, both CONNTRACK_MAX and HASHSIZE are set to "reasonable" values, calculate the value based on the available RAM size. The default value of CONNTRACK_MAX is in the i386 Architecture. CONNTRACK_MAX = RAMSIZE (in bytes)/16384 = RAMSIZE (in MegaBytes) * 64. therefore, A 32-bit PC with 512 MB memory can handle 1024*2/16384 ^ 512 = 32768*64 = concurrent netfilter connections by default. But the real formula is: CONNTRACK_MAX = RAMSIZE (in bytes)/16384/(x/32). Here, x is the number of bits of pointers (for example, 32 or 64bit). Note the following: -the default value of CONNTRACK_MAX is not lower than 128-for systems with more than 1 GB of memory, the default value of CONNTRACK_MAX is limited to 65536 (but can be set to a larger value manually). The default value of HASHSIZE is usually, CONNTRACK_MAX = HASHSIZE * 8. This means that the list of each link contains an average of 8 conntrack entries (when the optimization condition and CONNTRACK_MAX reach). the list of each link is a Hasse table entry (one bucket ). In the i386 architecture, HASHSIZE = CONNTRACK_MAX/8 = RAMSIZE (in bytes)/131072 = RAMSIZE (in MegaBytes) x 8. For example, a 32-bit PC with 512 MB memory can store 1024*2/128 ^ 1024/512 = 4096*8 = buckets (chain tables), but the actual formula is: HASHSIZE = CONNTRACK_MAX/8 = RAMSIZE (in bytes)/131072/(x/32) Here x is the number of bits of pointers (for example, 32 or 64bit). Please note: -the default HASHSIZE value is no less than 16.-for systems with more than 1 GB of memory, the default HASHSIZE value is limited to 8192 (but can be set to a larger value manually)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.