[Linux] Tips-linux Kernel parameter adjustment method "Brother Lian Technology sharing"

Source: Internet
Author: User
Tags message queue

Ulimit settings

Ulimit-n to be adjusted to 100000 or larger. The command line executes ulimit-n 100000 to be modified. If you cannot modify it, you need to set/etc/security/limits.conf, join

* Soft Nofile 262140

* Hard Nofile 262140

Root Soft Nofile 262140

Root Hard Nofile 262140

* Soft Core Unlimited

* Hard Core Unlimited

Root Soft Core Unlimited

Root Hard Core Unlimited

Kernel settings

Net.unix.max_dgram_qlen = 100

Swoole uses the UNIX socket dgram for interprocess communication, which needs to be adjusted if the request volume is large. The system defaults to 10 and can be set to 100 or greater.

or increase the number of worker processes, reducing the amount of requests allocated by individual worker processes.

Net.core.wmem_max

Modify this parameter to increase the memory size of the socket buffer

Net.ipv4.tcp_mem = 379008 505344 758016

Net.ipv4.tcp_wmem = 4096 16384 4194304

Net.ipv4.tcp_rmem = 4096 87380 4194304

Net.core.wmem_default = 8388608

Net.core.rmem_default = 8388608

Net.core.rmem_max = 16777216

Net.core.wmem_max = 16777216

Net.ipv4.tcp_tw_reuse

whether the socket is reuse, the function is to quickly re-use the listening port when the server restarts. Failure to set this parameter causes the port not to be released in time when the server restarts and fails to start

Net.ipv4.tcp_tw_recycle

Short connection server needs to turn on this parameter by using the Socket quick Recycle

Message Queuing settings

This kernel parameter needs to be adjusted when Message Queuing is used as an inter-process communication method

KERNEL.MSGMNB = 4203520, maximum number of bytes for Message Queuing

Kernel.msgmni = 64, maximum number of message queues to be created

Kernel.msgmax = 8192, maximum length of message queue single data

Freebsd/macos

Sysctl-w net.local.dgram.maxdgram=8192

Sysctl-w net.local.dgram.recvspace=200000 Modifying the buffer area size of a UNIX socket

Open Coredump

Kernel parameter settings

Kernel.core_pattern =/data/core_files/core-%e-%p-%t

To view the limitations of the current Coredump file by using the ULIMIT-C command

Ulimit-c

if 0, the/etc/security/limits.conf needs to be modified for the limit setting.

When Core-dump is turned on, the process is exported to a file once the program has an exception. It's a great help for the investigative procedure.

For other important configurations, here are the method demos:

Net.ipv4.tcp_syncookies=1

net.ipv4.tcp_max_syn_backlog=81920

Net.ipv4.tcp_synack_retries=3

Net.ipv4.tcp_syn_retries=3

Net.ipv4.tcp_fin_timeout = 30

Net.ipv4.tcp_keepalive_time = 300

Net.ipv4.tcp_tw_reuse = 1

Net.ipv4.tcp_tw_recycle = 1

Net.ipv4.ip_local_port_range = 20000 65000

Net.ipv4.tcp_max_tw_buckets = 200000

Net.ipv4.route.max_size = 5242880

To see if the configuration takes effect

example: After modifying Net.unix.max_dgram_qlen = 100, pass

Cat/proc/sys/net/unix/max_dgram_qlen

Tip: If the modification succeeds, this is the value of the new setting.

[Linux] Tips-linux Kernel parameter adjustment method "Brother Lian Technology sharing"

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.