Google Perf Tools for Nginx

Source: Internet
Author: User

Note: This tutorial is only available for Linux.

The following is an introduction to the installation of Google-perftools and the configuration of Nginx and MySQL support Google-perftools.

First, we describe how to optimize nginx:

1, first download and install Google-perftools:

Note that if it is a 64-bit system:

Then you need to do:
1) First install Libunwind or 2) to add--enable-frame-pointers at configure.

So, first of all, how to install Libunwind:

Copy CodeThe code is 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 Add--enable-frame-pointers, let's go down.

Download and install Google-perftools:

Copy CodeThe code is 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 CodeThe code is as follows:
./configure--PREFIX=/USR--enable-frame-pointers

Note This step here, if it is a 32-bit system, 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 CodeThe code is as follows:
Make
Make install

The installation google-perftools is complete but not effective, and the next step is to make google-perftools effective:

Copy CodeThe code is as follows:
echo "/usr/local/lib" >/etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig

Note that the double quotation marks here are in English.

Install Google-perftools here to complete.

In order to make nginx support google-perftools, need to add--with-google_perftools_module recompile nginx, if you do not know how to install Nginx, you can view the Nginx installation tutorial here.

For example:

Copy CodeThe code is 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

To add the Nginx quick restart script, please download it from wpadm.com.
Install Nginx here to complete.

Next add the thread directory for Google-perftools:

Copy CodeThe code is as follows:
Mkdir/tmp/tcmalloc
chmod 0777/tmp/tcmalloc

Modify/usr/local/nginx/conf/ncing.conf
Add the following in the PID line

Copy CodeThe code is as follows:
#pid Logs/nginx.pid;
Google_perftools_profiles/tmp/tcmalloc;

Restart Nginx:

Copy CodeThe code is as follows: Service Nginx restart

Verify that you are running:

Copy CodeThe code is as follows:
[Email protected] ~]# 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 will have a similar record.
To some, nginx under the Google-perftools optimization installation is completed, for friends to learn the reference.

Google Perf Tools for Nginx

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.