Use google-perltools to optimize nginx

Source: Internet
Author: User
To learn about nginx performance optimization, I found & quot; using TCMalloc to optimize nginx performance & quot; and using google-perftool to optimize nginx performance on the Internet. I read these articles separately and found the same content. In fact, google-perftools contains four tools: TCMa... to learn about nginx performance optimization, I found articles on the Internet, "using TCMalloc to optimize nginx performance" and "using google-perftool to optimize nginx performance. I read these articles separately and found the same content.
In fact, google-perftools includes four tools: TCMalloc, heap-checker, heap-profiler, and cpu-profiler. TCMalloc is one of google-perftools tools, it is used to optimize the memory allocation efficiency and speed, and helps control the memory usage in high concurrency.
In mysql and nginx performance optimization solutions, most of the tutorials use The TCMalloc tool provided by google-perftools. the efficiency and speed of TCMalloc in memory allocation is much higher than that of malloc. However, nginx memory usage is actually very small, and a process occupies about 12 MB of memory. Therefore, google-perftools may not significantly optimize nginx.
However, since we have this technology, we will learn how to use it.
Install and configure google-perftools
Before installation, determine whether the OS is 64-bit or 32-bit. if the OS is 64-bit, install the libunwind library before installing google-perftools:
1. [root @ lvs ~] # Uname-
2. Linux lvs. master 2.6.18-164. el5 #1 SMP Tue Aug 18 15:51:54 EDT 2009 i686 i686 i386 GNU/Linux
3. [root @ lvs ~] #
This indicates that my environment is a 32-bit environment. So the libunwind installation method should be searched by the officers themselves. (^ O ^ )/
1. install google-perftools
1. [root @ lvs pkgs] # wget http://gperftools.googlecode.com/files/google-perftools-1.10.tar.gz
2. [root @ lvs google-perftools-1.10] #./configure
3. [root @ lvs google-perftools-1.10] # make & make install
4. [root @ lvs google-perftools-1.10] # echo "/usr/local/lib">/etc/ld. so. conf. d/usr_local_lib.conf
5. [root @ lvs google-perftools-1.10] # ldconfig
II. recompile nginx
1. [root @ lvs nginx-0.8.53] #./configure -- with-google_perftools_module -- with-http_stub_status_module
2. [root @ lvs nginx-0.8.53] # make & make install
3. add a thread directory for google-perftools
1. [root @ lvs nginx] # mkdir/tmp/tcmalloc
2. [root @ lvs nginx] # chmod 0777/tmp/tcmalloc/
4. modify the nginx configuration file
1. [root @ lvs nginx] # vim/usr/local/nginx/conf/nginx. conf
2. add the following line:
3. google_perftools_profiles/tmp/tcmalloc;
4.
5. restart nginx:
6. [root @ lvs nginx] # ps ax | grep nginx | grep-v grep | awk '{print $1}' | xargs kill-9
7. [root @ lvs nginx] #/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx. conf
Here I encountered an error: error prompt
1. [root @ lvs nginx] #/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx. conf
2./usr/local/nginx/sbin/nginx: error while loading shared libraries: libprofiler. so.0: cannot open shared object file: No such file or directory
3. [root @ lvs nginx] #
Later I found that it was/etc/ld. so. conf. the d/usr_local_lib.conf file contains a problem. in this step, "echo"/usr/local/lib ">/etc/ld. so. conf. d/usr_local_lib.conf"
I copied an online article and later found garbled characters in the/etc/ld. so. conf. d/usr_local_lib.conf file. After the change, it will be normal. If you find the same errors as me,
Check whether the file is normal.
1. [root @ lvs lib] #/usr/local/nginx/sbin/nginx-V
2. nginx version: nginx/0.8.53
3. built by gcc 4.1.2 20080704 (Red Hat 4.1.2-46)
4. configure arguments: -- with-google_perftools_module -- with-http_stub_status_module
5. verification:
1. [root @ lvs lib] #/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx. conf
2. [root @ lvs lib] # lsof-n | grep tcmalloc
3. nginx 22171 nobody 10 w REG 985587/tmp/tcmalloc.22171
4. [root @ lvs lib] # head/usr/local/nginx/conf/nginx. conf
5. user nobody;
6. worker_processes 1;
A thread has a record file. since I only open one thread, there is only one record file.
The configuration method optimized by google-perftools has been described.
This article is from the "YEELON ghost" blog
Related Article

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.