纯静态文件环境下的Nginx优化思路

发表于:2011-11-14 09:45

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:崔晓辉    来源:51Testing软件测试网采编

分享:

  2)安装google-perftools

wget http://google-perftools.googlecode.com/files/google-perftools-1.7.tar.gz
tar xzvf google-perftools-1.7.tar.gz
cd google-perftools-1.7

  然后开始配置:

./configure --prefix=/usr --enable-frame-pointers (32位可以不添加--enable-frame-pointers)
make --j4 && make install

  nginx configure 参数加上--with-google-perftools 重新编译nginx

./configure --prefix=/usr/local/nginx --user=www --group=www  --with-http_stub_status_module --without-http_fastcgi_module --without-http_proxy_module --without-http_upstream_ip_hash_module --without-http_autoindex_module --without-http_ssi_module   --without-http_proxy_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_uwsgi_module --without-http_scgi_module  --without-http_memcached_module –with-google_perftools_module
make && make install

  3)在nginx.conf 的pid部分下,增加

google_perftools_profiles /data0/google_cache;

  重启

service nginx restart

  即可生效。

  三、nginx 工作进程优化

  通常的做法是在nginx.conf 的

worker_processes 8;

  下面增加

worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;

  但是在纯静态文件环境下,我们可以增加nginx 工作进程,来提升nginx的工作效率。

  工作进程 为24个,worker_cpu_affinity 可以这样来调整

worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;

  重启nginx后生效,可以充分利用nginx的对多核心cpu的良好的特性,大幅提升网站的访问速度。

22/2<12
价值129的会员专享直播免费赠送,添加微信领取听课名额哦~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计

法律顾问:上海漕溪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2023
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号