Archive

Posts Tagged ‘lamp’

Google Apache modpagespeed 测试

November 9th, 2010 西坪 No comments

昨日尝新测试Google Pagespeed Mod。今天重新测试了一下,服务器为OpenVZ vps/amd64bit/512M。Web服务器为 Apache 2.2.11。机器的性能是比较差的,所有数据仅供参考。

从客户端看速度有不错提升

未启用之前在Google Chrome中打开 本页,页面各部分内容的大小如下图:

a2b

请求速度如下图:

a1b

开启mod_pagespeed以后,页面各部分内容的大小如下图:
a2

css减少约1K,js减少1.5K,图片没有太大变化。总体减少约2K。

请求速度如下图:

a1

页面加载时间变化明显,document加载减少了480ms,css减少了6ms(提升比为25%),图片减少了24ms(提升比为18%),js脚本减少了6ms(提升比为25%),整体加载时间减少了460ms(提升比为21%)。

从服务端看

用ab在本机测试服务器的性能,可能是因为机器资源有限,ab本身要消耗一些资源,而本机测试时传输阶段的性能提升可以不计,故整体提升作用不明显。另外,ab不会去获取外部连接的文件也会错过mod_pagespeed在css/js/jpg方面的许多优化工作。尽管如此,处理速度还是有一些提升。开启前,50%的请求需要609ms,开启后降到599ms;66%的请求需要641ms,开启后降到621ms。所有请求的处理时间的中位数从609ms降到599ms。

启用前数据如下:

blog@feihoo:~$ ab -n 1000 -c 3 blog.feihoo.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Document Path:          /
Document Length:        114025 bytes
 
Concurrency Level:      3
Time taken for tests:   209.315 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      114394000 bytes
HTML transferred:       114025000 bytes
Requests per second:    4.78 [#/sec] (mean)
Time per request:       627.946 [ms] (mean)
Time per request:       209.315 [ms] (mean, across all concurrent requests)
Transfer rate:          533.71 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   484  628 108.2    609    1763
Waiting:      224  288  57.5    284    1035
Total:        485  628 108.2    609    1763
 
Percentage of the requests served within a certain time (ms)
  50%    609
  66%    641
  75%    657
  80%    670
  90%    735
  95%    825
  98%    895
  99%    988
 100%   1763 (longest request)

启用后测试结果如下:

blog@feihoo:~$ ab -n 1000 -c 3 blog.feihoo.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
 
Server Software:        Apache/2.2.11
Document Path:          /
Document Length:        114356 bytes
 
Concurrency Level:      3
Time taken for tests:   209.686 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      114755000 bytes
HTML transferred:       114356000 bytes
Requests per second:    4.77 [#/sec] (mean)
Time per request:       629.057 [ms] (mean)
Time per request:       209.686 [ms] (mean, across all concurrent requests)
Transfer rate:          534.44 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       6
Processing:   511  628 216.0    599    3660
Waiting:      233  294 157.4    277    2984
Total:        511  628 216.0    599    3660
 
Percentage of the requests served within a certain time (ms)
  50%    599
  66%    621
  75%    635
  80%    643
  90%    664
  95%    694
  98%   1075
  99%   1641
 100%   3660 (longest request)
Categories: server & system Tags: ,

Ubuntu 上安装buildix,PHP5, Apache2

October 12th, 2008 西坪 No comments

一开始,我在计算机上安装了buildix,发现 Buildix的各项功能也能正确运行。但是,一旦我安装并启用了 php5和mod-php5,就会导致buildix被卸载。如下:

liuzhr@suowan-master:/etc/apache2/sites-enabled$ sudo apt-get install php5 libapache2-mod-php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
php5 is already the newest version.
The following packages were automatically installed and are no longer required:
python-libxslt1 libapache2-svn libapache2-mod-python sun-java5-jdk python-libxml2 python-svn libapache2-mod-fastcgi cruisecontrol sun-java5-demo
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
apache2-mpm-prefork
The following packages will be REMOVED:
apache2-mpm-worker buildix
The following NEW packages will be installed:
apache2-mpm-prefork libapache2-mod-php5
0 upgraded, 2 newly installed, 2 to remove and 60 not upgraded.
Need to get 0B/2978kB of archives.
After unpacking 5747kB of additional disk space will be used.
Do you want to continue [Y/n]?

如果选择继续,安装了php5和libapache2-mod-php5,则会导致buildix卸载,如果重新安装 buildix,安装过程中会出现下面的错误,原因大概是libapache-mod-php5被buildix自动卸载了。

liuzhr@suowan-master:/etc/apache2/sites-enabled$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2
* We failed to correctly shutdown apache, so we're now killing all running apache processes. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!
apache2: Syntax error on line 183 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: cannot open shared object file: No such file or directory。

原因应该是 buildix 依赖于  apache2-mpm-worker, 而目前的 php5只能运行单线程的apache2,这样就必须使用  apache2-mpm-prefork。
使用  apt-cache show buildix 一看,果然buildix依赖于 apache2-mpm-worker。看来必须放弃将 buildix与目前的 php5(Module方式) 在一起安装的方法。

于是只能选择使用 cgi 的方式来安装。参考这篇文章:Installing Apache2 and PHP5 using mod_fcgid 。配置的过程中发生了一些错误(you don’t have permission to access ‘/index.php’),似乎是因为下面的配置中,AllowOverride ,FCGIWrapper ,AddHandler 或者 Options +ExecCGI 的顺序导致的。没有时间仔细研究这个问题,高手看到请指教。

<directory>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
FCGIWrapper /usr/lib/cgi-bin/php5 .php
AddHandler fcgid-script .php
Options +ExecCGI
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#RedirectMatch ^/$ /apache2-default/
</directory>

php5 目前不能使用 apache2-mpm-worker 模块是因为不支持多线程的apache2。 PHP如此说:Why shouldn’t I use Apache2 with a threaded MPM in a production environment? 

有关 apt-get 的命令,参考这里:https://help.ubuntu.com/community/AptGet/Howto

有关 Ubuntu上的LAMP,参考:ApacheMySQLPHP

Categories: server & system Tags: , ,