linux + nginx configuration optimization

linux on TCP / IP optimization configuration commands modify the configuration file /etc/sysctl.conf finished document in force / sbin / sysctl -p 

The following is a summary of the contents and configuration instructions

= net.ipv4.conf.all.rp_filter 0  
net.ipv4.conf. default .rp_filter = 0     
net.ipv4.conf. default .arp_announce = 2     in claim arp_announce parameters DR # direct routing mode is configured to claim 2 
net.ipv4. conf.lo.arp_announce = 2     
net.ipv4.conf.all.arp_announce = 2     
fs.file -max = 1000000     # number of open file handles 
net.ipv4.tcp_tw_reuse = . 1     # indicates turning allows reuse TIME - the WAIT for re Sockets the new TCP connection 
net.ipv4.tcp_keepalive_time = 600     # enable keepalive, tcp keepalive messages transmitted frequency 
net.ipv4.tcp_fin_timeout = 30    Socket-WAIT-# indicates the FIN 2 timeout time 
net.ipv4.tcp_tw_recycle = . 1 # represents the open TCP connections TIME- rapid recovery of the WAIT sockets 
net.ipv4.tcp_max_tw_buckets = 5000     # TIME_WAIT socket system while maintaining maximum for setting the number of nginx 5,000 to 30000  
net.ipv4.ip_local_port_range = 1024  61000     # set the system to open a range of ports, i.e. port range for outgoing connections 
net.ipv4.tcp_rmem = 4096  32768  262142     # TCP memory usage 
net. ipv4.tcp_wmem = 4096  32768  262142     
net.core.rmem_default = 262144     
net.core.wmem_default = 262144    
net.core.rmem_max = 2097152     
net.core.wmem_max = 2097152     
net.core.netdev_max_backlog = 8096     # network when the fast rate of each received packet rate interface than the core processing of the packets, transmitted to the packet queue allows maximum number 
net.ipv4.tcp_syncookies = . 1     # SYN Cookies indicates turning function 
net.ipv4.tcp_max_syn_backlog = 8192 # SYN bit set queue length 
net.ipv4.tcp_synack_retries = . 1     # decides to abandon the transmission of the SYN + kernel before the connection number of ACK packets 
net.ipv4 .tcp_syn_retries = . 1     # to establish the number of cores to abandon the SYN packet sent before a connection
View Code

nginx optimization configuration instructions

Global worker_proceses 8 ; cpu cpu count the number of optimal system has been "grep ^ Processor / proc / cpuinfo | WC - L" to run the command in linux to view the number of system cpu 
        worker_cpu_affinity 00000001  00000010  00000100  00001000  00010000  00100000  01000000  10000000 ; directly to the nginx worker process bound to a fixed cpu nginx processes running on one core of a CPU or a CPU, resulting in uneven nginx process using hardware resources can be fully effective use of hardware resources efficiently after binding 
events use epoll ; using the epoll (high-performance mode of linux2.6)     
        worker_connections 1024 ; the number of processes per worker connection     
        multi_accept on; as many connections in a new request is received     
http proxy_buffer_size 4k; instruction set the buffer size, from the agent back-end server response content acquired, will first be placed to read here.    
        sendfile on; sendfile () data can be copied (or any two file descriptors) each between the disk and the TCP socket, that copy is done in the kernel, sendfile () than the combination of read () and write (), and discarding more effective opening and closing the buffer     
        tcp_nopush on; tcp_nopush tells nginx transmitting a data package in all the header files, one by one without transmitting     
        tcp_nodelay on; send a request without any delay, oN nagle disable caching algorithm nagle caching algorithm, some applications It will be sent when the network communications of a few bytes, such as a byte, plus TCP protocol itself, in fact, made to 41 bytes, so the efficiency is very low. This time nagle algorithm is adopted, it will be sent the data stored in the cache, when accumulated to a certain amount or a certain time, and then sent them. 
        keepalive_timeout  30 ; nginx set the timeout     
        the allow    47.103 . 36.8 ; (LOCATION module) designated ip access     
        deny all; (location module) to disable access to all except permit ip ip of    
View Code

 

Guess you like

Origin www.cnblogs.com/Weibull/p/10955913.html