High performance Linux Server kernel tuning

Source: Internet
Author: User
Tags set time nginx server redis server dmesg

High performance Linux Server kernel tuning

First, let's introduce two commands
1, DMESG printing System information.
There are many students server problems, read the program log, found no useful information, or no solution, at this time, you need to see the system kernel thrown exception information, using the DMESG command, you can view the system information, dmesg-c clear already read the information.
2. Sysctl-p Effective Kernel configuration
After we have modified the kernel parameter file/etc/sysctl.conf, we need to perform the following sysctl-p to make the parameters effective.

Nginx Server Core Tuning

User requests, the first to enter is the Nginx server, then we must first of its kernel tuning.

First of all, of course the file description Fu Yi ~

#增大文件描述符
Ulimit-n 65536
Echo-ne "
* Soft Nofile 65536
* Hard Nofile 65536
">>/etc/security/limits.conf

#修改系统线程限制
Echo-ne "
* Soft Nproc 2048
* Hard Nproc 4096
">>/etc/security/limits.conf

Link Tracking Table Issues

Nginx server is most likely to encounter the following when opening a firewall
Execute the DMESG command to view the system printing information
Nf_conntrack:table full, dropping packet
(Link Tracking table is full)
This is a fairly common problem, and very serious, causing the server to randomly discard requests, your concurrency will not exceed thousands of.

Tuning method:
Add or modify kernel parameters
Vim/etc/sysctl.conf
Net.nf_conntrack_max = 655360 (maximum number of rows in the Status tracking table, 16G server)
net.netfilter.nf_conntrack_tcp_timeout_established = 1200 (set time-out)
After the modification is completed, execute the sysctl-p effective command.

Time_wait

Next, we will face too much time_wait situation.
Time_wait too much, will cause the system to reduce the number of ports available, it is well known that the availability of Linux random port range is 32768-65535, the user through 80 port requests come in, the server needs to open a random port to return data to the user, The reduction of the available ports will inevitably affect the user's access, and then we can reduce the number of time_wait by adjusting the two kernel parameters.
Decrease Time_wait Maximum, this operation causes the kernel alarm tcp:time wait bucket table overflow. However, you can increase concurrency and save ports.
Net.ipv4.tcp_max_tw_buckets = 8000
Increase the range of available ports, as the effect implies
Net.ipv4.ip_local_port_range = 1024 65000

Last two parameters I forgot what it meant, but also add it:)
Net.ipv4.tcp_keepalive_time = 1200
Net.ipv4.tcp_max_syn_backlog = 81920

At this point, your Nginx server can be happy to run up!

Redis Server kernel Tuning

Just one.
Vm.overcommit_memory = 1
To avoid the system running out of memory, the system kills the most memory-intensive programs (often Redis qaq).
Don't forget to take the order.

Elastic Server Kernel Tuning

Increase the number of VMA (virtual memory regions) that a process can have
Vm.max_map_count = 262144
Reduce the priority of using the Swap partition (you also configure the Disable swap partition in the elastic program)
vm.swappiness = 1

Other temporarily, the Nginx server kernel tuning parameters can be added to the initialization script.

Not to be continued ~

High performance Linux Server kernel tuning

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.