Tcmalloc optimizes Nginx Memory Management

Source: Internet
Author: User

Lab environment:

OS: Redhat 5.3 64bit

Mysql: mysql 5.5.29


The last time I wrote a blog about the installation configuration of Tcmallo-optimized Mysql memory management, this time I wrote down the installation configuration of Tcmalloc-optimized Nginx memory management.

First, like mysql, We need to install Tcmalloc first. Please refer to the previous blog "Tcmalloc optimizing Mysql memory management", which is not described here.

Then Nginx is installed. The details are as follows:

# ./configure --prefix=/app/soft/nginx-download --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_random_index_module --with-http_perl_module --with-http_addition_module --with-pcre=../pcre-8.31 --with-zlib=../zlib-1.2.8 --add-module=../ngx_cache_purge-1.6 --add-module=../echo-nginx-module-0.44 --add-module=../ngx_devel_kit-0.2.18 --add-module=../lua-nginx-module-0.7.18 --add-module=../nginx_upstream_check_module-master --with-google_perftools_module# make# make install

To support Tcmalloc in Nginx, you need to add -- with-google_perftools_module during installation, the same for everything else. After the installation is complete, you need to configure the configuration document. Otherwise, Tcmalloc is not enabled for Nginx by default. The specific configuration is as follows:

# mkdir /tmp/tcmalloc# chown -R www.www /tmp/tcmalloc# vim nginx.conf···pid        logs/nginx.pid;google_perftools_profiles /tmp/tcmalloc/;···

As shown above, the installation configuration for Nginx to use Tcmalloc for memory management optimization has been completed. You can use the following command to check whether Nginx uses Tcmalloc:

[root@szmlvm29-79 tmp]# lsof |grep tcmallocnginx     14578    nobody   25w      REG              253,0        0    5925239 /tmp/tcmalloc/.14578nginx     14579    nobody   27w      REG              253,0        0    5925240 /tmp/tcmalloc/.14579nginx     14580    nobody   29w      REG              253,0        0    5925241 /tmp/tcmalloc/.14580nginx     14581    nobody   31w      REG              253,0        0    5925242 /tmp/tcmalloc/.14581nginx     14582    nobody   33w      REG              253,0        0    5925243 /tmp/tcmalloc/.14582nginx     14583    nobody   35w      REG              253,0        0    5925244 /tmp/tcmalloc/.14583nginx     14584    nobody   37w      REG              253,0        0    5925245 /tmp/tcmalloc/.14584nginx     14585    nobody   39w      REG              253,0        0    5925246 /tmp/tcmalloc/.14585

As shown above, we have seen eight records, because the value of work_processes in each thread) There will be a line of records, and the numerical value behind each thread file is the pid value of the nginx started.


The above is the installation configuration of the entire Tcmalloc to optimize Nginx memory management.

This article is from the "kavin Study Notes" blog, please be sure to keep this source http://yjh625.blog.51cto.com/225746/1298198

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.