Note: This tutorial is only available for Linux.
Here is a description of Google-perftools installation, and configure Nginx and MySQL support Google-perftools.
First, describe how to optimize nginx:
1, first download and install Google-perftools:
Note that if the 64-bit system is:
Then you need to do:
1 Install Libunwind or 2 first, add--enable-frame-pointers at configure.
So first, let's talk about how to install Libunwind:
Copy Code code as follows:
wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99.tar.gz
Tar zxvf libunwind-0.99.tar.gz
CD libunwind-0.99/
Cflags=-fpic./configure--prefix=/usr
Make Cflags=-fpic
Make Cflags=-fpic Install
Install Libunwind here to complete.
If you are using the way to add--enable-frame-pointers, let's go down.
Download and install Google-perftools:
Copy Code code as follows:
wget http://google-perftools.googlecode.com/files/google-perftools-1.7.tar.gz
Tar xzvf google-perftools-1.7.tar.gz
CD google-perftools-1.7
Then start the configuration:
Copy Code code as follows:
./configure--PREFIX=/USR--enable-frame-pointers
Note This step here, if it is a 32-bit system, you can not add--enable-frame-pointers, if it is a 64-bit system, and you did not install Libunwind before, then you must add this:--enable-frame-pointers
Compile and install:
Copy Code code as follows:
The installation google-perftools is complete but not effective, and the next step is to make the Google-perftools effective:
Copy Code code as follows:
echo "/usr/local/lib" >/etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig
Note that the double quotes here are in English.
Install Google-perftools here to complete.
In order for Nginx to support google-perftools, you need to add--with-google_perftools_module recompile nginx, and if you don't know how to install Nginx, you can view the Nginx installation tutorials from here.
For example:
Copy Code code as follows:
./configure--user=www--group=www--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_ssl_module--with-openssl= \
--with-http_addition_module \
--with-zlib= \
--with-google_perftools_module
Make
Make install
Add Nginx Quick Restart script, download from wpadm.com.
Install Nginx here to complete.
Next, add the thread directory for Google-perftools:
Copy Code code as follows:
Mkdir/tmp/tcmalloc
chmod 0777/tmp/tcmalloc
Modify/usr/local/nginx/conf/ncing.conf
Add below the PID line
Copy Code code as follows:
#pid Logs/nginx.pid;
Google_perftools_profiles/tmp/tcmalloc;
Reboot Nginx:
Copy Code code as follows:
Verify that you are running:
Copy Code code as follows:
[Root@localhost ~]# Lsof-n | grep tcmalloc
Nginx 13101 www 45w REG 8,1 0 4014748/tmp/tcmalloc.13101
Nginx 13102 www 47w REG 8,1 0 4014742/tmp/tcmalloc.13102
Nginx 13103 www 49w REG 8,1 0 4014746/tmp/tcmalloc.13103
Nginx 13105 www 51w REG 8,1 0 4014745/tmp/tcmalloc.13105
Nginx 13106 www 53w REG 8,1 0 4014743/tmp/tcmalloc.13106
Nginx 13107 www 55w REG 8,1 0 4014749/tmp/tcmalloc.13107
Nginx 13108 www 57w REG 8,1 0 4014754/tmp/tcmalloc.13108
Nginx 13109 www 59w REG 8,1 0 4014750/tmp/tcmalloc.13109
Nginx 13110 www 61w REG 8,1 0 4014747/tmp/tcmalloc.13110
Nginx 13111 www 63w REG 8,1 0 4014755/tmp/tcmalloc.13111
Nginx 13112 www 65w REG 8,1 0 4014753/tmp/tcmalloc.13112
Nginx 13113 www 67w REG 8,1 0 4014756/tmp/tcmalloc.13113
Nginx 13114 www 69w REG 8,1 0 4014757/tmp/tcmalloc.13114
Nginx 13115 www 71w REG 8,1 0 4014751/tmp/tcmalloc.13115
Nginx 13116 www 73w REG 8,1 0 4014744/tmp/tcmalloc.13116
Nginx 13117 www 75w REG 8,1 0 4014752/tmp/tcmalloc.13117
My server has 8 cores, so 8 nginx threads are turned on, and each thread has a row of similar records.
To some, nginx under the Google-perftools optimization installation completed, for friends to learn reference.