$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 != 183 && RecommendedEntry_getEntryData( $eid_prev )) { RecommendedEntry_updateIndexFile( 183, $eid_prev, 0 /*incoming_from*/ ); RecommendedEntry_updateIndexFile( $eid_prev, 183, 1 /*outgoing_to*/ ); } } else { RecommendedEntry_updateIndexFile( 183, 183, 0 /*incoming_from*/ ); } } RecommendedEntry_incoming(); function RecommendedEntry_outgoing() { setcookie( 'mtrcmnd_eid', 183, 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( '183', -1 ). '/183.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( 183 == $_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; } } ?> [memo][apache]mod_mem_cacheしてみる - 寝不足にて候(仮)
Mar
27
2009

[memo][apache]mod_mem_cacheしてみる

どの程度に効果があるものか。localhostでのテストなので前後比較しか参考にはならない。


導入前:秒間331.45リクエスト。

$ ab -n 500 -c 50 http://blog.kenji00.com/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.kenji00.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 500 requests


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

Document Path:          /
Document Length:        47020 bytes

Concurrency Level:      50
Time taken for tests:   1.508537 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      23677463 bytes
HTML transferred:       23589613 bytes
Requests per second:    331.45 [#/sec] (mean)
Time per request:       150.854 [ms] (mean)
Time per request:       3.017 [ms] (mean, across all concurrent requests)
Transfer rate:          15327.43 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    9  24.0      2     159
Processing:    12  134  61.3    129     279
Waiting:       11  118  61.4    114     244
Total:         29  144  59.8    134     285

Percentage of the requests served within a certain time (ms)
  50%    134
  66%    185
  75%    197
  80%    203
  90%    213
  95%    239
  98%    247
  99%    249
 100%    285 (longest request)

モジュールを有効化

# vi /etc/httpd/conf/httpd.conf

LoadModule cache_module modules/mod_cache.so
#LoadModule suexec_module modules/mod_suexec.so
#LoadModule disk_cache_module modules/mod_disk_cache.so
#LoadModule file_cache_module modules/mod_file_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so


このサイトはバーチャルホストで運用しているので、マニュアル見ながら設定

# vi /etc/httpd/conf.d/バーチャルホストのconf


ServerName blog.kenji00.com
.
.


CacheEnable mem /
MCacheSize 12800
MCacheMaxObjectCount 1000
MCacheMinObjectSize 1
MCacheMaxObjectSize 128000
MCacheMaxStreamingBuffer 128000


.
.

で、再度ab(Apache bench)

導入後:秒間449.19リクエスト

$ ab -n 500 -c 50 http://blog.kenji00.com/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.kenji00.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 500 requests


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

Document Path: /
Document Length: 47020 bytes

Concurrency Level: 50
Time taken for tests: 1.113118 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 23691890 bytes
HTML transferred: 23604040 bytes
Requests per second: 449.19 [#/sec] (mean)
Time per request: 111.312 [ms] (mean)
Time per request: 2.226 [ms] (mean, across all concurrent requests)
Transfer rate: 20784.86 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 9.3 1 126
Processing: 9 104 53.1 95 286
Waiting: 7 96 51.9 87 278
Total: 9 106 52.8 101 287

Percentage of the requests served within a certain time (ms)
50% 101
66% 142
75% 164
80% 168
90% 175
95% 178
98% 181
99% 185
100% 287 (longest request)

ちょい早。当社比135.5%

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

トラックバック(0)

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

コメントする

過去のエントリ(一覧)

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