17. Establishment of Single-host running environment -- using tcmalloc to optimize nginx in CentOS-6.4

Source: Internet
Author: User
I. Introduction

Tcmalloc, short for thread-caching malloc, is an open-source tool developed by Google. Compared with the standard glibc library's malloc. Tcmalloc has higher memory allocation efficiency and speed than malloc. For more information, see. The URL below.

http://www.mysqlops.com/2011/06/14/google-tcmalloc-malloc.html#more-737 
2. Install the libunwind library.
CD/usr/local
Wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz
Tar xf libunwind-1.1.tar.gz CD libunwind-1.1
Cflags =-FPIC./configure # Add the compilation parameter make cflags =-FPIC install
3. Install gpperftools:
CD/usr/local

Download https://gperftools.googlecode.com/files/gperftools-2.0.tar.gz with thunder
Then upload the file to/usr/local, because it seems that wget cannot download the HTTPS stuff, or it is very troublesome.
Tar-zxvf gperftools-2.0.tar.gz CD gperftools-2.0

./Configure
make && make install 

echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf

/sbin/ldconfig

If you have optimized MySQL before, you do not need to install gperftools.

Install nginx here. Refer to another blog to complete the operation.

# Cd/usr/local/src

#wget http://tengine.taobao.org/download/tengine-1.4.4.tar.gz#tar zxvf tengine-1.4.4.tar.gz#cd tengine-1.4.4

./configure --add-module=/usr/local/src/ngx_cache_purge-2.1 --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre=/usr/local/src/pcre-8.32 --with-google_perftools_modulemake make install
 
Iv. configuration process

Create a thread directory for gperftools

mkdir /tmp/tcmalloc chmod 0777 /tmp/tcmalloc 

 

Modify the nginx configuration file

VI/usr/local/nginx/CONF/nginx. conf # PID logs/nginx. PID;Google_perftools_profiles/Tmp/Tcmalloc;Add this line

 

Start nginx and verify that tcmalloc is loaded properly

# Service nginx restart

Install the lsof command:

Yum install lsof-y

# Lsof-N | grep tcmalloc

So far, it has been replaced successfully.

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.