clowwindy的杂草牧场

   :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理
  34 Posts :: 2 Stories :: 74 Comments :: 0 Trackbacks

公告

最近准备换VPS,看到有VPS支持FreeBSD,就打算试试。想了解一下它和linux性能上的差异,就在网上找了些文章看了看。很多文章都提到FreeBSD更适合做前端的文件服务器,它的数据库性能和SMP性能不如linux。不过这些文章要么比较老,要么就是纯粹的口水仗,缺乏翔实的数据支撑。于是还是决定自己多装几台虚拟机测试一下好了。

测试环境:
宿主:
Core i3 530 @ 2.93GHz 双核4线程
16G RAM
Windows 7 64bit

虚拟机软件:
Virtualbox 4.1.2

虚拟机配置:
FreeBSD 7.2 i386 / FreeBSD 8.2 amd64 / Debian 5.0 i386 / CentOS 5.6 i386
双核全速
256M RAM
8GB硬盘
启用硬件虚拟化和IO APIC

各系统用最小安装,然后安装了编译工具链+apache(为了方便使用ab)+php+mysql。之后关掉apache,安装nginx。
FreeBSD使用ports编译安装nginx,Debian分别使用了源自带的和编译的最新稳定版,CentOS使用编译的最新稳定版。FreeBSD的nginx应该默认使用了kqueue,linux默认使用了epoll。
nginx设置为1个worker,开启gzip。

测试使用ApacheBench,测试文件为一个57244 bytes的jquery.js。
除CentOS外,ApacheBench都是2.3版,CentOS是2.0版。

ab -c 10 -n 100000 http://localhost/jquery.js


不多废话了,以下是测试结果:

FreeBSD 7.2 i386 + nginx 0.6.36

Concurrency Level:      10
Time taken for tests: 26.156 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 5747200000 bytes
HTML transferred: 5724400000 bytes
Requests per second: 3823.15 [#/sec] (mean)
Time per request: 2.616 [ms] (mean)
Time per request: 0.262 [ms] (mean, across all concurrent requests)
Transfer rate: 214574.53 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 4
Processing: 0 2 0.8 2 18
Waiting: 0 1 0.6 1 16
Total: 0 3 0.7 2 18


FreeBSD 8.2 amd64 + nginx 0.8.54

Concurrency Level:      10
Time taken for tests: 24.675 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 5747257344 bytes
HTML transferred: 5724457116 bytes
Requests per second: 4052.62 [#/sec] (mean)
Time per request: 2.468 [ms] (mean)
Time per request: 0.247 [ms] (mean, across all concurrent requests)
Transfer rate: 227455.77 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 8
Processing: 1 2 0.6 2 19
Waiting: 0 1 0.5 1 9
Total: 1 2 0.6 2 20


Debian 5.0 i386 + nginx 0.6.32

Concurrency Level:      10
Time taken for tests: 9.808 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 5747257472 bytes
HTML transferred: 5724457244 bytes
Requests per second: 10195.98 [#/sec] (mean)
Time per request: 0.981 [ms] (mean)
Time per request: 0.098 [ms] (mean, across all concurrent requests)
Transfer rate: 572254.98 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 10
Processing: 0 1 1.0 1 94
Waiting: 0 0 0.9 0 94
Total: 0 1 1.0 1 95


Debian 5.0 i386 + nginx 1.0.6

Concurrency Level:      10
Time taken for tests: 9.321 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 5747157471 bytes
HTML transferred: 5724457244 bytes
Requests per second: 10728.92 [#/sec] (mean)
Time per request: 0.932 [ms] (mean)
Time per request: 0.093 [ms] (mean, across all concurrent requests)
Transfer rate: 602156.28 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 7
Processing: 0 1 0.4 1 32
Waiting: 0 0 0.4 0 31
Total: 0 1 0.5 1 32


CentOS 5.6 i386 + nginx 1.0.6

Concurrency Level:      10
Time taken for tests: 9.996502 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 1452132704 bytes
HTML transferred: 1429432704 bytes
Requests per second: 10003.50 [#/sec] (mean)
Time per request: 1.000 [ms] (mean)
Time per request: 0.100 [ms] (mean, across all concurrent requests)
Transfer rate: 141859.42 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 3
Processing: 0 0 0.7 0 9
Waiting: 0 0 0.2 0 6
Total: 0 0 0.7 0 9

整理:


和之前看到的很多文章的观点正相反,在nginx静态文件性能的测试中,FreeBSD表现出了巨大的劣势。

由于这一结果非常奇怪,我又将虚拟机改为单核,并测试了lighttpd,结果依然是linux领先了一倍左右。究竟是什么原因造成如此巨大的差异呢?

posted on 2011-09-19 20:21 clowwindy 阅读(...) 评论(...) 编辑 收藏