使用TCMalloc优化OpenResty,tcmallocopenresty


1、安装依赖包

yum -y install wget gcc gcc-c++ -y

2、安装libunwind库
可以从http://ftp.twaren.net/Unix/NonGNU//libunwind/下载

wget http://ftp.twaren.net/Unix/NonGNU//libunwind/libunwind-1.1.tar.gz
tar zxvf libunwind-1.1.tar.gz
cd libunwind-1.1
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install

3、安装google-perftools
下载http://pan.baidu.com/s/1bnfDFbD

tar zxvf gperftools-2.1.tar.gz
cd gperftools-2.1
./configure
make
make install
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig

为google-perftools创建一个线程目录

mkdir /tmp/tcmalloc
chmod 777 /tmp/tcmalloc

4、安装OpenResty

请参看我另一篇博客http://www.cnblogs.com/kgdxpr/p/3550633.html

编译时增加--with-google_perftools_module

./configure --prefix=/usr/local/openresty --with-google_perftools_module --with-http_stub_status_module --with-http_gzip_static_module --with-luajit

 查看nginx安装的模块

/usr/local/openresty/nginx/sbin/nginx -V

修改nginx主配置文件,在pid这行的下面添加如下代码

验证google-perftools是否已经正常加载,可通过如下命令查看

lsof -n | grep tcmalloc

相关内容