首页 > 代码库 > tcMalloc 配置和优化 nginx 高性能
tcMalloc 配置和优化 nginx 高性能
tcMalloc优化nginx
记住:nginx一定要先启动
1>下载安装libunwind:
#wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99.tar.gz
wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-alpha.tar.gz
tar -zxvf libunwind-0.99-alpha.tar.gz
cd libunwind-0.99-alpha
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install
2>下载安装Google-perftools
wget http://soft.7dot.com/soft/google-perftools-1.8.tar.gz
tar -zxvf google-perftools-1.8.tar.gz
cd google-perftools-1.8
./configure
make && make install
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig
3>重新编译nginx(使nginx支持Google-perftools)
cd nginx-1.2.8
./configure --with-google_perftools_module --with-http_stub_status_module
#./configure \
#> --with-google_perftools_module --with-http_stub_status_module #--prefix=/usr/local/nginx
make
make install
4> 为google-perftools 添加线程目录
mkdir /tmp/tcmalloc
chmod 0777 /temp/tcmalloc
5> 修改nginx主配置文件
cd /usr/local/nginx/conf
修改nginx.conf 在pid这行添加下面代码
#pid logs/nginx.pid
#google_perftools_profiles /tmp/tcmalloc/
google_perftools_profiles /tmp/tcmalloc
检查nginx.conf配置是否正确
/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
#/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/sbin/conf/nginx.conf
重启nginx
/usr/local/nginx/sbin/nginx -s reload
#kill -HUP cat /usr/local/nginx/logs/nginx.pid
ps ax | grep nginx | grep -v grep | awk ‘{print $1}‘ | xargs kill -9
6> 验证
lsof -n | grep tcmalloc
记住:nginx一定要先启动
1>下载安装libunwind:
#wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99.tar.gz
wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-alpha.tar.gz
tar -zxvf libunwind-0.99-alpha.tar.gz
cd libunwind-0.99-alpha
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install
2>下载安装Google-perftools
wget http://soft.7dot.com/soft/google-perftools-1.8.tar.gz
tar -zxvf google-perftools-1.8.tar.gz
cd google-perftools-1.8
./configure
make && make install
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig
3>重新编译nginx(使nginx支持Google-perftools)
cd nginx-1.2.8
./configure --with-google_perftools_module --with-http_stub_status_module
#./configure \
#> --with-google_perftools_module --with-http_stub_status_module #--prefix=/usr/local/nginx
make
make install
4> 为google-perftools 添加线程目录
mkdir /tmp/tcmalloc
chmod 0777 /temp/tcmalloc
5> 修改nginx主配置文件
cd /usr/local/nginx/conf
修改nginx.conf 在pid这行添加下面代码
#pid logs/nginx.pid
#google_perftools_profiles /tmp/tcmalloc/
google_perftools_profiles /tmp/tcmalloc
检查nginx.conf配置是否正确
/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
#/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/sbin/conf/nginx.conf
重启nginx
/usr/local/nginx/sbin/nginx -s reload
#kill -HUP cat /usr/local/nginx/logs/nginx.pid
ps ax | grep nginx | grep -v grep | awk ‘{print $1}‘ | xargs kill -9
6> 验证
lsof -n | grep tcmalloc
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。