Home Backend Development PHP Tutorial NGINX kernel parameter optimization

NGINX kernel parameter optimization

Jul 29, 2016 am 09:15 AM
ipv net tcp

The optimization of kernel parameters is mainly the optimization of system kernel parameters for Nginx applications in Linux systems.
An optimization example is given below for reference.
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_syncookies = 1
net.core.somaxconn = 262144
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 1
net. ipv4.tcp_keepalive_time = 30
Add the above kernel parameter values ​​​​to the /etc/sysctl.conf file, and then execute the following command to make it effective
/sbin/sysctl -p
The above parameters are introduced below:
net .ipv4.tcp_max_tw_buckets is used to set the number of timewait. The default is 180000, here it is changed to 6000.
net.ipv4.ip_local_port_range is used to set the minimum port range allowed to be opened by the system 1024.
net.ipv4.tcp_tw_recycle is used to set the startup timewait speed. Recycle.
net.ipv4.tcp_tw_reuse is used to set up reuse, allowing time-wait sockets to be reused for new tcp connections.
net.ipv4.tcp_syncookies is used to enable syn cookies. When a syn waiting queue appears, cookie processing is enabled
The default value of net.core.somaxconn is 128. The parameter is used to adjust the number of TCP connections initiated by the system at the same time. In highly concurrent requests, the default value may cause connection timeout or retransmission. Therefore, this parameter needs to be adjusted in conjunction with the number of concurrent requests. value.
net.core.netdev_max_backlog represents the maximum number of packets allowed to be sent to the queue when each network interface accepts packets faster than the kernel can process them.
net.ipv4.tcp_max_orphans is used to set the maximum number of tcp sockets in the system that are not associated with any user file handle. If this number is exceeded, the orphaned connection will be reset immediately and a warning message printed. This limit is to prevent simple DOS attacks. You cannot rely too much on this limit or even artificially reduce this value. In more cases, you should increase this value.
net.ipv4.tcp_max_syn_backlog is used to record the maximum value of connection requests that have not yet received client confirmation information. For systems with 128MB of memory, the default value of the secondary parameter is 1024, and for systems with small memory it is 128. net.ipv4.tcp_synack_retries The value of the parameter determines the number of SYN+ACK packets sent before the kernel gives up the connection. net.ipv4 .tcp_syn_retries represents the number of SYN packets sent before the kernel gives up the connection. Net.ipv4.tcp_fin_timeout determines how long the socket remains in the FIN-WAIT-2 state. The default value is 60 seconds. It is very important to set this value correctly. Sometimes even a web server with a small load will have a large number of dead sockets and risk memory overflow.
net.ipv4.tcp_keepalive_time indicates the frequency of tcp sending keepalive messages when keepalive is started. The default value is 2 (units are hours).

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above has introduced NGINX kernel parameter optimization, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solving IPv6 network access permission issues Solving IPv6 network access permission issues Feb 18, 2024 am 11:09 AM

How to solve the problem of IPv6 without network access rights. With the development of the Internet and the popularity of smart devices, our lives are inseparable from the Internet. As an upgraded version of IPv4, IPv6 has become an important part of the future Internet. However, when using IPv6, you sometimes encounter the problem of no network access. So, if we encounter this situation, how should we solve it? First, we need to clarify the reason why IPv6 has no network access rights. There are many possible reasons, such as incorrect gateway configuration, too strict firewall settings, network

How to reset tcp/ip protocol in win10? How to reset the tcp/ip protocol stack in windows 10 How to reset tcp/ip protocol in win10? How to reset the tcp/ip protocol stack in windows 10 Mar 16, 2024 am 11:07 AM

How to reset tcp/ip protocol in win10? In fact, the method is very simple. Users can directly enter the command prompt, and then press the ctrl shift enter key combination to perform the operation, or directly execute the reset command to set it up. Let this site do the following. Let us carefully introduce to users how to reset the TCP/IP protocol stack in Windows 10. Method 1 to reset the tcp/ip protocol stack in Windows 10. Administrator permissions 1. We use the shortcut key win R to directly open the run window, then enter cmd and hold down the ctrl shift enter key combination. 2. Or we can directly search for command prompt in the start menu and right-click

How to verify that the input string is in the correct IPv6 address format using PHP regular expressions How to verify that the input string is in the correct IPv6 address format using PHP regular expressions Jun 24, 2023 am 09:44 AM

With the development of the Internet and the continuous reduction of IPv4 addresses, IPv6 addresses have become an indispensable part of network communications. When developing network applications, IPv6 addresses are often used. In order to ensure that the entered IPv6 address is in the correct format, we can verify it with the help of PHP regular expressions. This article will use examples to explain how to use PHP regular expressions to verify whether the input string is in the correct IPv6 address format. Comparison of IPv4 and IPv6 address formats introduces how to use PHP regular tables

How to use TCP to implement conversation between client and server in python How to use TCP to implement conversation between client and server in python May 17, 2023 pm 03:40 PM

TCP client A client sample code that uses the TCP protocol to achieve continuous dialogue: importsocket#Client configuration HOST='localhost'PORT=12345#Create a TCP socket and connect to the server client_socket=socket.socket(socket.AF_INET,socket .SOCK_STREAM)client_socket.connect((HOST,PORT))whileTrue:#Get user input message=input("Please enter the message to be sent:&

How to solve the problem of computer IPv6 being unable to connect to the network How to solve the problem of computer IPv6 being unable to connect to the network Feb 24, 2024 pm 08:03 PM

What should I do if my computer does not have IPv6 access rights to the network? In recent years, with the development of the Internet, IPv6 has gradually replaced IPv4 as the new Internet protocol. However, for some users, they may encounter the problem of computer IPv6 without network access permissions, resulting in the inability to use the network normally. So, how to solve this problem? Let’s take a look at some solutions below. First of all, we need to clarify why the problem of computer IPv6 without network access rights occurs. Generally speaking, this problem may be due to

See you soon! TCP waves twice, have you seen it? What about the four handshakes? See you soon! TCP waves twice, have you seen it? What about the four handshakes? Jul 24, 2023 pm 05:18 PM

The "connection-oriented" mentioned here means that you need to establish a connection, use the connection, and release the connection. Establishing a connection refers to the well-known TCP three-way handshake. When using a connection, data is transmitted in the form of one send and one confirmation. There is also the release of the connection, which is our common TCP four wave waves.

How to set win10ipv4 address How to set win10ipv4 address Jan 02, 2024 pm 12:17 PM

Many users don’t know how to set the IPV4 address under win10 system. We can enter the computer’s network settings to modify and configure it. The specific operation is also very simple. You can refer to the following methods and steps. How to set the IPv4 address in win10 1. Open "Network and Internet Settings" 2. Click "Change Adapter Options" 3. Select the network you are connected to open, and then click "Properties" 4. Find ipv45, open it and you can set it.

Using Netty4 for TCP communication in Java API development Using Netty4 for TCP communication in Java API development Jun 17, 2023 pm 11:18 PM

TCP is a type of computer network communication protocol and a connection-oriented transmission protocol. In Java application development, TCP communication is widely used in various scenarios, such as data transmission between client and server, real-time transmission of audio and video, etc. Netty4 is a high-performance, highly scalable, and high-performance network programming framework that can optimize the data exchange process between the server and the client to make it more efficient and reliable. The specific implementation steps of using Netty4 for TCP communication are as follows: Introduction

See all articles