闲的没事,拿一台淘汰的2950做了做nginx和lighttpd的性能对比,可以在选择webserver上做个参考。

测试环境如下
Dell2950 4G内存,FreeBSD 8.2 release
#sysctl -a | grep CPU
hw.model: Intel(R) Xeon(R) CPU                        5130    @ 2.00GHz

2x2颗

内存4G

#uname -a
FreeBSD localhost.localdomain 8.2-RELEASE

php5.2.17,fastcgi方式,默认5进程测试,失败请求太多,改用20进程,无请求失败。
Nginx主要配置
events {
use kqueue;
worker_connections  102400;
}

写了个phpinfo用ab测试,内网IP,不考虑带宽因素。
# ab -n 100000 -c 1000 http://192.168.100.28/info.php
This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.100.28 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Finished 100000 requests
Server Software:                nginx/1.0.0                                                                                
Server Hostname:                192.168.100.28
Server Port:                        80

Document Path:                    /info.php
Document Length:                49457 bytes

Concurrency Level:            1000
Time taken for tests:     86.578 seconds
Complete requests:            100000
Failed requests:                0
Broken pipe errors:         0
Total transferred:            4977355920 bytes
HTML transferred:             4961202790 bytes
Requests per second:        1155.03 [#/sec] (mean)
Time per request:             865.78 [ms] (mean)
Time per request:             0.87 [ms] (mean, across all concurrent requests)
Transfer rate:                    57489.84 [Kbytes/sec] received

Connnection Times (ms)
                            min    mean[+/-sd] median     max
Connect:                0     297    888.8         11    6414
Processing:        20     555    649.9        421    9989
Waiting:             18     555    649.9        421    9988
Total:                 20     852 1065.3        473 10222

Percentage of the requests served within a certain time (ms)
    50%        473
    66%        584
    75%        699
    80%        776
    90%     3308
    95%     3473
    98%     3688
    99%     3817
100%    10222 (last request)

iostat -w 1
       tty           mfid0              da0              cd0             cpu
 tin  tout  KB/t tps  MB/s   KB/t tps  MB/s   KB/t tps  MB/s  us ni sy in id
   0    23 19.12   1  0.01   0.01   0  0.00   0.00   0  0.00   0  0  0  0 100
   0   235  0.00   0  0.00   0.00   0  0.00   0.00   0  0.00   0  0  0  0 100
   0    79  2.00   3  0.01   0.00   0  0.00   0.00   0  0.00   0  0  0  0 100
   4   393  2.00   2  0.00   0.00   0  0.00   0.00   0  0.00  10  0  4  2 85
   0    78 123.85  54  6.52   0.00   0  0.00   0.00   0  0.00  76  0 17  7  0
   0    76 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  72  0 16  8  5
   0    79 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  81  0 12  5  2
   0    79 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  74  0 15  7  3
   0    79 16.95  19  0.31   0.00   0  0.00   0.00   0  0.00  71  0 19  8  2
   0    78 21.60  10  0.21   0.00   0  0.00   0.00   0  0.00  74  0 17  7  2
   0    78  0.00   0  0.00   0.00   0  0.00   0.00   0  0.00  74  0 17  8  1
   0    78 53.33   3  0.16   0.00   0  0.00   0.00   0  0.00  68  0 21 10  1
   0   104 20.20  20  0.39   0.00   0  0.00   0.00   0  0.00  68  0 18 10  5

磁盘压力只在测试开始时大,并且因为所有东西都放在一台服务器,瞬间最高把CPU空闲率干到了0.3%,但实际上占用CPU最多的是ab,占了40%多,nginx占用不到40%

------------------------------------------------换lighttpd
server.max-fds = 8192
## 
## Stat() call caching.
##
## lighttpd can utilize FAM/Gamin to cache stat call.
##
## possible values are:
## disable, simple or fam.
##
server.stat-cache-engine = "simple"
##
## Fine tuning for the request handling
##
## max-connections == max-fds/2 (maybe /3)
## means the other file handles are used for fastcgi/files
##
Server.max-connections = 4096

也是使用kqueue队列
# ab -n 100000 -c 1000 http://192.168.100.28/info.php
This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.100.28 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Finished 100000 requests
Server Software:                lighttpd/1.4.28                                                                        
Server Hostname:                192.168.100.28
Server Port:                        80

Document Path:                    /info.php
Document Length:                49127 bytes

Concurrency Level:            1000
Time taken for tests:     83.107 seconds
Complete requests:            100000
Failed requests:                0
Broken pipe errors:         0
Total transferred:            4932575365 bytes
HTML transferred:             4915304142 bytes
Requests per second:        1203.27 [#/sec] (mean)
Time per request:             831.07 [ms] (mean)
Time per request:             0.83 [ms] (mean, across all concurrent requests)
Transfer rate:                    59352.10 [Kbytes/sec] received

Connnection Times (ms)
                            min    mean[+/-sd] median     max
Connect:                0        19    206.2            1    3113
Processing:        79     807    155.8        823    3891
Waiting:             66     807    155.8        823    3890
Total:                 79     826    251.0        826    4248

Percentage of the requests served within a certain time (ms)
    50%        826
    66%        843
    75%        854
    80%        862
    90%        894
    95%        939
    98%     1006
    99%     1094
100%     4248 (last request)

# iostat -w 1
       tty           mfid0              da0              cd0             cpu
 tin  tout  KB/t tps  MB/s   KB/t tps  MB/s   KB/t tps  MB/s  us ni sy in id
   0    23 19.25   1  0.01   0.01   0  0.00   0.00   0  0.00   0  0  0  0 100
   0   387  0.00   0  0.00   0.00   0  0.00   0.00   0  0.00   0  0  0  0 99
   0    78  0.00   0  0.00   0.00   0  0.00   0.00   0  0.00   0  0  0  0 100
   4  2185  0.00   0  0.00   0.00   0  0.00   0.00   0  0.00  47  0 14  7 33
   0    78 120.00   2  0.23   0.00   0  0.00   0.00   0  0.00  68  0 23  9  1
   0  2405 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  77  0 14  6  2
   0    79 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  71  0 17 10  2
   0  1852 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  72  0 18  8  2
   0    79 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  62  0 22  7 10
   0  1143 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  68  0 20  9  3
   0    79 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  65  0 25  8  2
   0  2074 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  69  0 22  8  2
   0    79 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  65  0 23 10  3
   0  1917 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  62  0 26 10  3
   0    79 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  63  0 25  8  5
   0  2247 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  66  0 23  8  3
   0    79 128.00   1  0.12   0.00   0  0.00   0.00   0  0.00  66  0 25  7  2
   0  1373 48.00   7  0.33   0.00   0  0.00   0.00   0  0.00  66  0 22  8  4

看起来,lighttpd在磁盘上并没有nginx那样的瞬间压力。
总结:
一开始的失败请求主要来自php-cgi,在此服务器上,默认进程数无法处理大并发访问量。改为20以上就不存在失败了,再高收益不大。从高负载动态页面吞吐率上说,lighttpd可能要稍稍高于nginx。
附ab静态页面吞吐率
lighttpd Requests per second:    9045.68 [#/sec] (mean)
nginx  Requests per second:    11622.50 [#/sec] (mean)
处理静态页面上,nginx要比lighttpd快不少。如果去掉ab对cpu的压力,两款软件加php对cpu的压力应该不超过70%。
在处理诸如php,ror等应用方面的极端压榨,可以考虑使用lighttpd。处理静态页面可以考虑使用nginx。篇幅有限,vmstat和truss跟踪的结果就不贴了。

转载于:https://blog.51cto.com/slaytanic/554880

nginx与lighttpd性能简单对比相关推荐

  1. java.io和java.nio性能简单对比

    我从java1.3开始学习java,后来主要用1.4,再后来1.5和1.6中的很多新特性,都停留在"知道"的状态,比如nio,虽然据说可以提升性能,但并没有真正深入使用和测试过,工 ...

  2. 飞腾PC机器与奔腾G645的PC机器以及E5-2630V4虚拟机内存性能简单对比

    1. 对比工具 sysbench 2. 对比命令 sysbench --test=memory --memory-total-size=12G --num-threads=8 run 3 安装方式 # ...

  3. apache,ngnix,lighttpd性能对比

    1. web服务器简介 1. lighttpd Lighttpd是一个德国人领导的开源软件,其根本的目的是提供一个专门针对高性能网站,安全.快速.兼容性好并且灵活的Web server环境 Light ...

  4. 不同CPU的MATLAB性能表现的简单对比方法

    MATLAB性能表现 小结:程序不同,无法一概而论.可以分为两部分:1.多线程,2.浮点数.[好像说了一堆众所周知的废话] 参考网址 https://www.mathworks.com/support ...

  5. 不同cpu matlab,不同CPU的MATLAB性能表现的简单对比方法

    MATLAB性能表现 小结:程序不同,无法一概而论.可以分为两部分:1.多线程,2.浮点数.[好像说了一堆众所周知的废话] 参考网址 https://www.mathworks.com/support ...

  6. nginx哪个版本性能好_R7 3700X和i7 9700KF哪个好?i79700KF和R73700X性能对比评测

    R7-3700X是AMD在2019年7月7日带来的第三代全新Zen2架构的7纳米高端处理器,受到广大装机用户性价比认可,用来抗衡intel酷睿i7-9700KF,而往往装机用户会在这两者不知道如何选择 ...

  7. 基于 Nginx 的 HTTPS 性能优化实践

    前言 分享一个卓见云的较多客户遇到HTTPS优化案例. 随着相关浏览器对HTTP协议的"不安全".红色页面警告等严格措施的出台,以及向 iOS 应用的 ATS 要求和微信.支付宝小 ...

  8. 基于 Nginx 的 HTTPS 性能优化

    前言 分享一个卓见云的较多客户遇到HTTPS优化案例. 随着相关浏览器对HTTP协议的"不安全".红色页面警告等严格措施的出台,以及向 iOS 应用的 ATS 要求和微信.支付宝小 ...

  9. 负载均衡器技术Nginx和F5的优缺点对比

    负载均衡器技术Nginx和F5的优缺点对比 博客分类: 应用服务 F5nginx  对于数据流量过大的网络中,往往单一设备无法承担,需要多台设备进行数据分流,而负载均衡器就是用来将数据分流到多台设备的 ...

最新文章

  1. Spark1.4启动spark-shell时initializing失败
  2. 什么是 Web 应用性能评测领域的 RAIL 模型
  3. 3997: [TJOI2015]组合数学
  4. hyper-v虚拟服务器内存满了,在Hyper-V Dynamic Memory里设置虚拟内存
  5. python 第一行 报错_初学Python-只需4步,爬取网站图片
  6. 医用应用计算机,计算机在医疗方面应用.doc
  7. CENTOS7.8忘记ROOT密码,重置密码步骤
  8. 解决ubuntu下arduino IDE的Serial Port无法选择问题
  9. 为什么CPU的使用率总是100%
  10. 一个核函数把低维空间映射到高维空间的例子
  11. 超高频RFID R200系列远距离一体化读写器开发测试
  12. hbuilderx制作简单网页_普通网站如何制作一个网站?
  13. 13.1.X:ByteScout PDF Extractor SDK
  14. 045孙悟空和独角大王对话
  15. bzoj1618 购买干草
  16. 日语输入法时的部分实用快捷键
  17. Codeforces Round #686 (Div. 3) A-F题解
  18. 深度学习在计算机视觉领域图像应用总结
  19. 夹缝中的垂直母婴电商贝莱优品们:生存之道怎么挖?
  20. 【单片机毕业设计】基于单片机的空气质量(烟雾、天然气或煤气、CO、有害混合气体)检测系统的设计

热门文章

  1. mycat集群执行带有join的sql语句时报错_can‘t find table define in schema_分片join---Linux运维工作笔记052
  2. 数据库零碎要点002---认识时序数据库
  3. 微服务升级_SpringCloud Alibaba工作笔记0018---Nacos之服务注册中心对比提升
  4. Netty工作笔记0029---NIO 网络编程应用--群聊系统4--客户端编写2
  5. Struts2 + Hibernate + Spring 以及javaweb模块问题解决(1)
  6. 那些年,我们一起追过的足球
  7. c 匹配mysql密码,MySQL设置密码的三种方法
  8. kis显示用户登录服务器失败,金蝶KIS专业版提示用户KISAdmin登陆失败。原因:未与信任SQL Server连接相关联...
  9. AD原理图编译WARNING:Net XXX has no driving source
  10. 10天智能锁项目实战第1天(了解单片机STM32F401RET6和C语言基础)