把 apache2-mpm-prefork 換成 apache2-mpm-worker 遇到的問題

edited 十月 2013 in 伺服器環境
我先是在自己的機器上試,大致上確認 OK 後,就把同樣的步驟搬到伺服器上;兩台主機主要的差異是,一台為 Ubuntu Desktop 8.04 32位元版本,一台是 Ubuntu Server 8.04 64 位元版本。在伺服器上一直沒辦法順利執行 CakePHP ,但是 phpMyAdmin 活的很好,可是自己主機上都沒事...

原有主機的效能測試:
ab -c 100 -n 1000 http://somewhere/~kiang/test.php

Server Software: Apache/2.2.8
Server Hostname: somewhere
Server Port: 80

Document Path: /~kiang/test.php
Document Length: 50379 bytes

Concurrency Level: 100
Time taken for tests: 85.360736 seconds
Complete requests: 1000
Failed requests: 57
(Connect: 0, Length: 57, Exceptions: 0)
Write errors: 0
Total transferred: 51213306 bytes
HTML transferred: 51002787 bytes
Requests per second: 11.71 [#/sec] (mean)
Time per request: 8536.073 [ms] (mean)
Time per request: 85.361 [ms] (mean, across all concurrent requests)
Transfer rate: 585.89 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 54 1185 5045.3 349 45350
Processing: 512 3232 2036.4 2466 12515
Waiting: 55 476 723.8 337 8673
Total: 711 4418 5896.1 2817 56207

Percentage of the requests served within a certain time (ms)
50% 2817
66% 3980
75% 5290
80% 5898
90% 7292
95% 8785
98% 24189
99% 51146
100% 56207 (longest request)

安裝步驟:
1. sudo apt-get install apache2-mpm-worker libapache2-mod-fcgid php5-cgi
*提示訊息:
The following packages will be REMOVED:
apache2-mpm-prefork libapache2-mod-php5
The following NEW packages will be installed:
apache2-mpm-worker libapache2-mod-fcgid php5-cgi
2. sudo pico /etc/apache2/sites-available/default
sudo pico /etc/apache2/mods-available/userdir.conf

在資料夾設定加入 ExecCGI

3. sudo pico /etc/mods-available/fcgid.conf
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi .php
FCGIWrapper /usr/lib/cgi-bin/php5 .php
IPCConnectTimeout 20
</IfModule>

4. sudo /etc/init.d/apache2 restart

新的效能測試:
Server Software: Apache/2.2.8
Server Hostname: somewhere
Server Port: 80

Document Path: /~kiang/test.php
Document Length: 46858 bytes

Concurrency Level: 100
Time taken for tests: 71.930751 seconds
Complete requests: 1000
Failed requests: 4
(Connect: 0, Length: 4, Exceptions: 0)
Write errors: 0
Non-2xx responses: 1
Total transferred: 47201756 bytes
HTML transferred: 47033563 bytes
Requests per second: 13.90 [#/sec] (mean)
Time per request: 7193.075 [ms] (mean)
Time per request: 71.931 [ms] (mean, across all concurrent requests)
Transfer rate: 640.82 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 43 1105 4967.7 331 45583
Processing: 306 2211 1287.2 1943 14754
Waiting: 54 380 359.6 313 3479
Total: 457 3317 5488.9 2353 58681

Percentage of the requests served within a certain time (ms)
50% 2353
66% 2633
75% 2844
80% 3218
90% 4296
95% 5956
98% 11008
99% 47931
100% 58681 (longest request)


雖然效能有提升了,但是不知為何,就是無法順利執行 CakePHP 應用...^^||

另外,在這之前有不小心裝成 libapache2-mod-fastcgi ,不知道兩個的差異是啥,也不知道是不是過程出了什麼差錯。

原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=3449

評論

  • edited 六月 2008
    fastcgi跟fastcgid可能是在multi-thread處理上有差異,因為在multi-thread enabled的伺服器上fork行程時還需要複製所有的thread,代價比較高,所以用fastcgid特別處理這個過程,其他跟fastcgi應該沒有不同。(從mod_cgi跟mod_cgid的說明上推測的...)
Sign In or Register to comment.