First, the compilation and installation process optimization
1. Reduce the file size after Nginx compilation
When compiling nginx, the default is in debug mode, and in the debug mode will be inserted a lot of tracking and assert such information, after compiling, an nginx to have several megabytes, and before compiling the debug mode, the compilation is completed only several hundred bytes, so, Before compiling, modify the relevant source code:
After extracting the Nginx source file, find the AUTO/CC/GCC file under the source directory. Open and then find the following lines in it:
#debug
Cflags= "$CFLAGS-G"
Comment or delete the two lines.
2. Specify CPU type compilation optimizations for specific CPUs
When compiling nginx, the default gcc compilation parameter is "-O", to optimize GCC compilation, you can use the following two parameters:
--with-cc-opt= '-o3 '
--WITH-CPU-OPT=CPU #为特定的CPU编译, valid values include: Pentium, Pentiumpro, PENTIUM3,
#pentium4, Athlon, Opteron, AMD64, Sparc32, SPARC64, PPC64
to determine the CPU type, you can do this with the following command:
# cat/proc/cpuinfo |grep "model name"
Second, using Tcmalloc to optimize the performance of Nginx
Three, nginx kernel parameter optimization
The optimization of Nginx kernel parameters is mainly based on the optimization of kernel parameters for Nginx application in Linux system.
An example of optimization is given below for reference:
Net.ipv4.tcp_max_tw_buckets = 6000
Net.ipv4.ip_local_port_range = 1024 65000
Net.ipv4.tcp_tw_recyle = 1
Net.ipv4.tcp_tw_reuse = 1
Net.ipv4.tcp_syncookies = 1
Net.core.somaxconn = 262144
Net.core.netdev_max_backlog = 262144
This article is from the "Stones" blog, make sure to keep this source http://wangzan18.blog.51cto.com/8021085/1627292
Nginx Performance Optimization Tips