今天看到killkill作者关于Linux环境Nginx与Apache HTTP性能对比测试,很受启发,特别转载过来与大家一起分享,虽然在Linux系统下Nginx与Apache各有所长,但在大压力,大访问量,大数据的情况下的确要比Apache的表现要好!详情请看文中的详细性能对比测试结果!
下载并编译安装,我的编译过程有点特别:
1。去除调试信息,修改$nginx_setup_path/auto/cc/gcc这个文件,将 CFLAGS="$CFLAGS -g" 这一行注释掉。
2。由于仅测试WEB的性能,所以不安装FastCGI。
view sourceprint?
./configure \
--prefix=/opt/nginx \
--user=www \
--group=www \
--with-http_stub_status_module \
--with-http_ssl_module \
--without-http_fastcgi_module
安装完成之后,将一堆生产环境中静态化了的HTML页面copy 到 nginx 的上,我的 nginx.conf 的配置如下:
view sourceprint?
worker_processes 8;
worker_rlimit_nofile 102400;
events
{
use epoll;
worker_connections 204800;
}
http
{
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
charset GBK ;
keepalive_timeout 60;
server_names_hash_bucket_size 128;
client_header_buffer_size 2k;
large_client_header_buffers 4 4k;
client_max_body_size 8m;
open_file_cache max=102400 inactive=20s;
server
{
listen 80;
location /
{
root /tmp/webapps/;
index index.html index.htm;
}
location = /NginxStatus
{
stub_status on;
access_log off;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html
{
root html;
}
}
}