LAMP服务器优化---Nginx

来源:互联网 发布:机构投资者持股数据 编辑:程序博客网 时间:2024/05/01 20:26

本文将服务器Apache换成Nginx
在Nginx下优化对比Apache的性能。
下载Nginx源码包

wget http://nginx.org/download/nginx-1.10.3.tar.gz

下载 zlib

wget http://www.zlib.net/zlib-1.2.11.tar.gz

下载OpenSSL

wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz

将zlib openssl解压到 Nginx/src 目录下
编译安装

./configure --prefix=/usr/local/nginx --with-zlib=src/zlib --with-openssl=src/openssl

nginx启动/停止/重载
To start nginx, run the executable file. Once nginx is started, it can be controlled by invoking the executable with the -s parameter. Use the following syntax:
nginx -s signal
Where signal may be one of the following:
stop — fast shutdown
quit — graceful shutdown
reload — reloading the configuration file
reopen — reopening the log files
配置nginx fcgi代理
这里写图片描述
重启Nginx
通过 ab 模拟1000个客户端发起200000个并发请求
这里写图片描述
nginx能够接受的请求太小了。
更改worker进程的最大打开文件数限制。
这里写图片描述
再次测试
这里写图片描述
cpu及/io
这里写图片描述
内存
这里写图片描述
开始优化
修改如下配置
这里写图片描述
再次测试
这里写图片描述
cpu/io
这里写图片描述
内存
这里写图片描述

经过调节后,每秒并发达到了10K多。内存的使用也相对较少了。

0 0
原创粉丝点击