Linux项目_Lnmp_4_nginx的压测及优化
Linux项目_Lnmp_4_nginx的压测及优化
一.什么是压测
压测,即压力测试,是确立系统稳定性的一种测试方法,通常在系统正常运作范围之外进行,以考察其功能极限和隐患。一般针对网络游戏压力测试从传统的意义来讲是对网络游戏的服务器不断施加“压力”的测试,是通过确定一个系统的瓶颈或者不能接收的性能点,来获得系统能提供的最大服务级别的测试。 主要检测游戏服务器的承受能力,包括用户承受能力(多少用户同时玩基本不影响质量)、流量承受等。
二.实验部署
1.环境
操作系统:RHEL6.5
VM1 172.25.0.8 - - - - - server8
2.安装ab压力测试命令
ab压力测试工具,http提供
压侧:评估服务器的性能
ab -c 10 -n 5000 http://172.25.0.8/index.php
3.测试
(示例:)
真机压测虚拟机:(用物理机去测试)
ab -c 10 -n 5000 http://172.25.36.6/index.php 1400错误不少(529) php服务
ab -c 10 -n 5000 http://172.25.36.6/example.php 3519 memcache高速缓存
ab -c 10 -n 5000 http://172.25.36.6/index.html 14814 本地缓存
Complete requests: 5000 成功5000个
Failed requests: 529 失败461个
Requests per second: 1399.61 [#/sec] (mean) 速度1399.61/s
三种比较:
php服务:index.php
memcache高速缓存:example.php
本地静态页面:index.html
nginx的memc和sr_caceb模块
参考文章:https://blog.****.net/jiao_fuyou/article/details/36014543
nginx -s stop 关闭nginx
openresty官方网站:http://openresty.org/cn/
4.解压源码安装openresty加速模块
(1)源码安装
cd /mnt
tar zxf openresty-1.13.6.1.tar.gz
cd openresty-1.13.6.1
./configure
gmake
gmake install
(2)修改nginx配置信息
cd /usr/local/openresty/nginx/conf
vim nginx.conf
(3)开启openresty环境下的nginx
cd /usr/local/openresty/nginx/sbin
./nginx -t
./nginx
(4)创建检测页面
cd /usr/local/openresty/nginx/html
cp /usr/local/lnmp/nginx/html/index.php .
cp /usr/local/lnmp/nginx/html/example.php .
浏览器访问http://172.25.36.6/index.php查看nginx是否启动
(5)修改配置信息
cd /usr/local/openresty/nginx/conf
vim nginx.conf
(6)配置信息可参考
使用memc-nginx和srcache-nginx模块构建高效透明的缓存机制:
https://blog.****.net/jiao_fuyou/article/details/36014543
重新启动
cd /usr/local/openresty/nginx/sbin
./nginx -t
./nginx -s reload
(7)[真机]检测
ab -c 10 -n 5000 http://172.25.36.6/index.php 2489.56 php服务
ab -c 10 -n 5000 http://172.25.36.6/example.php 5899.45 memcache高速缓存
ab -c 10 -n 5000 http://172.25.36.6/index.html 7800 本地缓存
三种比较:
php服务:index.php
memcache高速缓存:example.php
本地静态页面:index.html
(8)参考:
nginx的memc和sr_caceb模块
https://blog.****.net/jiao_fuyou/article/details/36014543
openresty官方网站:
http://openresty.org/cn/
使用memc-nginx和srcache-nginx模块构建高效透明的缓存机制:
https://blog.****.net/jiao_fuyou/article/details/36014543