$value ) if( $value['eid'] == $eid ) return $value; return null; } function RecommendedEntry_updateIndexFile( $eid_updated, $eid, $direction ) { $filename = '/var/www/VirtualDomain/kenji00.com/blog/recommend_data'; is_dir( $filename ) || mkdir( $filename ); $filename .= '/'. substr( $eid_updated, -1 ); is_dir( $filename ) || mkdir( $filename ); $filename .= sprintf( '/%d.txt', $eid_updated); file_exists( $filename ) || touch( $filename ); $fp = @fopen( $filename, 'r+' ); if( $fp ) { if( flock( $fp, LOCK_EX | LOCK_NB )) { $ret = ''; $not_found = 1; while( !feof( $fp ) && ( $buf = fgets( $fp ))) { list( $_eid, $_n0, $_n1 ) = split( "[\t\r\n]", $buf ); if( $eid == $_eid ) { $not_found = 0; $direction ? $_n1++ : $_n0++; } $ret .= sprintf( "%d\t%d\t%d\n", $_eid, $_n0, $_n1 ); } if( $not_found ) $ret .= sprintf( "%d\t%d\t%d\n", $eid, 1 - $direction, $direction); rewind( $fp ); fwrite( $fp, $ret, strlen( $ret )); } fclose( $fp ); } } function RecommendedEntry_incoming() { $eid_prev = $_COOKIE['mtrcmnd_eid']; if( isset( $eid_prev )) { if( $eid_prev != 135 && RecommendedEntry_getEntryData( $eid_prev )) { RecommendedEntry_updateIndexFile( 135, $eid_prev, 0 /*incoming_from*/ ); RecommendedEntry_updateIndexFile( $eid_prev, 135, 1 /*outgoing_to*/ ); } } else { RecommendedEntry_updateIndexFile( 135, 135, 0 /*incoming_from*/ ); } } RecommendedEntry_incoming(); function RecommendedEntry_outgoing() { setcookie( 'mtrcmnd_eid', 135, time() + 2592000, '/' ); } RecommendedEntry_outgoing(); function RecommendedEntry_initialize( $mode = 0 ) { global $RecommendedEntry_table; $RecommendedEntry_table = array(); $filename = '/var/www/VirtualDomain/kenji00.com/blog/recommend_data/'. substr( '135', -1 ). '/135.txt'; $fp = @fopen( $filename, 'r' ); if( $fp ) { if( flock( $fp, LOCK_SH | LOCK_NB )) { while( !feof( $fp ) && ( $buf = fgets( $fp ))) { list( $_eid, $_n0, $_n1 ) = split( "[\t\r\n]", $buf ); if( 135 == $_eid ) continue; else if( $mode == 1 ) $RecommendedEntry_table{$_eid} = $_n0; else if( $mode == 2 ) $RecommendedEntry_table{$_eid} = $_n1; else $RecommendedEntry_table{$_eid} = $_n0 + $_n1; } arsort( $RecommendedEntry_table, SORT_NUMERIC ); } fclose( $fp ); } } function RecommendedEntry_GetEntry( $_index ) { global $RecommendedEntry_table; foreach( $RecommendedEntry_table as $eid => $count ) { if( --$_index ) continue; $entry = RecommendedEntry_getEntryData( $eid ); if( $entry ) $entry['count'] = $count; return $entry; } } ?> CentOS3にPHP5+eAccelerator その3 - 寝不足にて候(仮)
Jan
21
2008

CentOS3にPHP5+eAccelerator その3

15分前に、Zend optimizer未導入であることに気付く。

明日はどんな風が吹くか分からないので、今やることにする。

というわけで、Zend Technologiesから持ってきましたよ、ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz。

$ gunzip -dc ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz | tar xvf -
$ cd ZendOptimizer-3.3.0a-linux-glibc21-i386
# ./install.sh

はい。終了。
先ほどのポストから20分経過。

......errorでつ。

PHP Fatal error: [Zend Optimizer] Zend Optimizer 3.3.0 is incompatible with eAccelerator 0.9.5.2 in Unknown on line 0

あぁ、eAccelerator設定の後ろにZend Optimizerを書けばいいのね。

# vi /etc/php.d/eaccelerator.ini

Ctrl+G,oして


[Zend]
zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.0
zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.0
zend_optimizer.version=3.3.0a
zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so
zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so

を追記

OK。

早速ApacheBenchを。

$ ab -n 100 -c 10 http://***.kenji00.com/index.php
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.121.2.1 $> apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking cat.kenji00.com (be patient).....done


Server Software: Apache
Server Hostname: ***.kenji00.com
Server Port: 80

Document Path: /index.php
Document Length: 14343 bytes

Concurrency Level: 10
Time taken for tests: 47.88499 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1477900 bytes
HTML transferred: 1434300 bytes
Requests per second: 2.12 [#/sec] (mean)
Time per request: 4708.850 [ms] (mean)
Time per request: 470.885 [ms] (mean, across all concurrent requests)
Transfer rate: 30.64 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.6 0 6
Processing: 1602 4602 2817.0 3938 17307
Waiting: 1517 4430 2793.6 3701 17225
Total: 1602 4602 2817.0 3938 17307

Percentage of the requests served within a certain time (ms)
50% 3938
66% 4926
75% 5685
80% 6570
90% 8583
95% 10652
98% 13889
99% 17307
100% 17307 (longest request)

遅くなってるやん。orz

あ!未だCacheされてないからだ!

もう一度。

$ ab -n 100 -c 10 http://***.kenji00.com/index.php
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.121.2.1 $> apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking cat.kenji00.com (be patient).....done


Server Software: Apache
Server Hostname: ***.kenji00.com
Server Port: 80

Document Path: /index.php
Document Length: 14343 bytes

Concurrency Level: 10
Time taken for tests: 46.674345 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1477900 bytes
HTML transferred: 1434300 bytes
Requests per second: 2.14 [#/sec] (mean)
Time per request: 4667.434 [ms] (mean)
Time per request: 466.743 [ms] (mean, across all concurrent requests)
Transfer rate: 30.92 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.8 0 7
Processing: 1703 4588 2518.1 4090 10632
Waiting: 1627 4323 2396.7 3716 9809
Total: 1703 4588 2518.3 4090 10632

Percentage of the requests served within a certain time (ms)
50% 4090
66% 5160
75% 6654
80% 6945
90% 8670
95% 9532
98% 10449
99% 10632
100% 10632 (longest request)

微妙。

このエントリを読んだ人はこんなんも読んでいます

トラックバック(1)

トラックバックURL: http://blog.kenji00.com/MT/mt-tb.cgi/134

ベンチマークに使っていたXOOPSアプリのcache機能を使っていなかったので、... 続きを読む

コメントする

過去のエントリ(一覧)

Powered by Movable Type 4.261
Creative Commons License
このブログはクリエイティブ・コモンズでライセンスされています。