« 2007年12月 | メイン | 2008年2月 »

2008年1月 アーカイブ

2008年1月 7日

猫入院

新年明けましておめでとう御座います。m(_ _)m
喪中につき年賀欠礼。金欠につき寝正月。半分以上が税金で出来ている宝くじという名の紙切れの番号を照合していたら2等の組違いでがっかり......な2008年のSTART。

新年初の外出は嫁の病院で、2回目の外出は猫の病院。

どうも朝から元気が無いけど、病院に連れて行くほどじゃなさそうだから少し様子を見ようと思っていたウチの猫2号。
夜になったら、ソファーから殆ど動かず食事もせず。嫁と二人で徹夜で見守り、翌日朝一で動物病院へ駆け込んだところ、熱と黄疸で入院することになりました。

junior.jpg

幸い、今日の病院からの連絡では、黄疸は治まりつつある傾向ですし、血液検査でも大きな異常は無いということで、少し安心しましたが、猫の黄疸について調べてみると、場合によっては大変みたいです。
昨年14万overに達した500円玉貯金を再開し、猫貯金増額に努めることにします。

chokinbako.JPG

2008年1月 8日

画像リンクが多いページを

表示してから、URL入力欄に下のコードを入力。

javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI= document.images; DIL=DI.length; function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval('A()',5 ); void(0)
狙ったリンクがクリックできず、もどかしい。

ココとかでやってみるが吉。

javascript:document.body.style.filter="flipH()";eval();
手元に鏡があるなら、こっちでも良い。

猫退院

昨日投与したインターフェロンが功を奏し、熱が引いて黄疸も治まってきました。
病院のケージだと緊張でコチコチになっているという話だったので、本日退院。
1人だったらパークハイアットにギリギリ泊まれるかも.....くらいの治療費。:-)

帰宅後は食欲もあり、先ずは一安心。どうも、猫風邪で炎症を起こして黄疸が出ていた模様。

病院で何か匂いを付けてきたらしく、ただ一人去勢していない猫3号が病み上がりの2号にマウンティングを繰り返すので、ただいまPC部屋に3号を拉致ってBlog中。

wink.jpg
3号テレビ出演中の図。

2008年1月19日

CentOS3卒業(メモ)

ハイ。このサイトを動かしているOSは、CentOS3。
Full Updates期間は終了し現在はMaintenance Updates中。(2010 年10月31日まで)
当然、新しいソフトウェアは提供されません。

クララオンラインのVPSを契約しており、初期費用はかからないのでCentOS5に移行する予定ですが、その前に月額6,980円のVPSでちょっとだけ設定ファイルを弄った状態でのパフォーマンスをメモ。(既にApacheもMysqlもPHPも設定含め吊るしのモノではありませんが.....)

sysstatもsnmpもインストールしていないので、わかりやすいところでWebサーバのレスポンスチェックを。

[XOOPSなVirtualhostに100リクエスト/10同時リクエストでApacheBenchの結果]

$ ab -n 100 -c 10 http://***.kenji00.com/
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 ***.kenji00.com (be patient)...

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

Document Path: /
Document Length: 14469 bytes

Concurrency Level: 10
Time taken for tests: 43.721657 seconds
Complete requests: 100
Failed requests: 1
(Connect: 0, Length: 1, Exceptions: 0)
Write errors: 0
Total transferred: 1473793 bytes
HTML transferred: 1432744 bytes
Requests per second: 2.29 [#/sec] (mean)
Time per request: 4372.166 [ms] (mean)
Time per request: 437.217 [ms] (mean, across all concurrent requests)
Transfer rate: 32.91 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.9 0 6
Processing: 1564 4286 2560.6 3744 16586
Waiting: 1492 4058 2517.3 3520 16531
Total: 1564 4286 2560.5 3744 16586

Percentage of the requests served within a certain time (ms)
50% 3744
66% 4473
75% 4726
80% 5043
90% 7174
95% 10288
98% 13518
99% 16586
100% 16586 (longest request)


この状態で、マシンの負荷が

$ uptime ; free
00:30:52 up 11 days, 2:42, 2 users, load average: 7.36, 1.92, 0.97

total used free shared buffers cached
Mem: 6220504 6182828 37676 0 248224 2705860
-/+ buffers/cache: 3228744 2991760
Swap: 10241428 73684 10167744


こんな感じ。

なお、CentOS3卒業→CentOS5入学式の日には「漢なら、一度はやろう # rm -rf / 」というタイトルで記事を投稿します。:-)

2008年1月20日

CentOS3にPHP5+eAccelerator

現在入ってるのは、PHP5.1.6
5.2系へのUpdateは、適当なSRPMを探すのが面倒なので、とりあえず見送り。

結論から言うと、eAcceleratorの導入で、応答速度は1/3近くまで短縮される模様。

本当は、Apacheも2.0から2,2にしようと思いましたが、SRPMからのrebuildだとApache Portable Runtimeのインストール時に、稼動中ソフト/ライブラリとの兼ね合いで弄りが必要となり、心が折れました。
ソースからmakeすればいいじゃん。という説もありますが、一介の金融系サラリーマンでnerdでもgeekでも無いワタクシは、PKG管理派に宗旨替えをしていますので。

前回のeAcceleratorインストール時は、未だPHP4.4.4でした。その時の手順を思い出しながら、こちらはソースからbuild。

[eAcceleratorのインストール]

$ wget http://jaist.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.5.2.tar.bz2
$ bunzip2 -dc eaccelerator-0.9.5.2.tar.bz2 | tar xvf -
$ cd eaccelerator-0.9.5.2
$ /usr/bin/phpize
$ ./configure --enable-eaccelerator=shared --with-php-config=/usr/bin/php-config --with-eaccelerator-info
$ make
$ su
# make install
Installing shared extensions: /usr/lib/php/modules/

[設定]

$ cp control.php /var/www/VirtualHosts/kenji00/***.kenji00.com/htdocs/
$ vi /var/www/VirtualHosts/kenji00/***.kenji00.com/htdocs/control.php

$user = "*******";
$pw = "********";

$ mkdir /tmp/eaccelerator
# chown apache:apache /tmp/eaccelerator/
# cp eaccelerator.ini /etc/php.d/eaccelerator.ini
# vi /etc/php.d/eaccelerator.ini

zend_extension = "/usr/lib/php/modules/eaccelerator.so"
eaccelerator.allowed_admin_path = "/var/www/VirtualHosts/kenji00/***.kenji00.com/htdocs/control.php"

[TEST]

# /etc/init.d/httpd restart

test_php.png

では、テストしてみましょう。

先ずは1回目。インストール済みのcontrol.phpで、Cachingを無効にしています。

$ 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: 14311 bytes

Concurrency Level: 10
Time taken for tests: 87.545530 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1472400 bytes
HTML transferred: 1431100 bytes
Requests per second: 1.14 [#/sec] (mean)
Time per request: 8754.553 [ms] (mean)
Time per request: 875.455 [ms] (mean, across all concurrent requests)
Transfer rate: 16.41 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.7 0 7
Processing: 3032 8546 7254.4 6660 43925
Waiting: 2864 7979 6574.6 6347 43761
Total: 3032 8546 7254.3 6660 43925

Percentage of the requests served within a certain time (ms)
50% 6660
66% 8256
75% 9568
80% 10456
90% 15477
95% 19389
98% 43640
99% 43925
100% 43925 (longest request)

次は、Caching有効時。テストしているURLのcacheがあることをcontrol.phpで確認して.....

$ 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: 14311 bytes

Concurrency Level: 10
Time taken for tests: 38.965838 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1472400 bytes
HTML transferred: 1431100 bytes
Requests per second: 2.57 [#/sec] (mean)
Time per request: 3896.584 [ms] (mean)
Time per request: 389.658 [ms] (mean, across all concurrent requests)
Transfer rate: 36.88 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.7 0 5
Processing: 1436 3836 2701.9 3168 15025
Waiting: 1369 3589 2436.0 3039 14516
Total: 1441 3836 2701.9 3168 15025

Percentage of the requests served within a certain time (ms)
50% 3168
66% 4204
75% 5329
80% 5745
90% 7480
95% 9817
98% 13015
99% 15025
100% 15025 (longest request)

先ほどのポストが、投稿から僅か1~2時間でGoogleの検索結果に反映されている件

google_result.PNG

いくらなんでも早すぎないか?
ちなみに、検索クエリはコレ。19位あたりで表示。

クローラのアクセスログは、

66.249.70.20 - - [20/Jan/2008:19:30:56 +0900] "GET /2008/01/centos3php5eaccelerator.html HTTP/1.1" 200 17037 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

なので、2時間以内であることは確実。

ふ~ん。
ま、タイミングがなんか合ったのかなぁ。インデックスされている本文テキストは草稿段階のものなので、現在UPされているものとは多少違いますが....
こういうの、他サイトも含めて調べると面白いのだろうが、面倒なので、誰かやってください。

地味なApacheチューニング

httpd.confを弄ってみた。

FileETag None
ExpiresActive On
ExpiresDefault "access plus 4 weeks"
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
DeflateCompressionLevel 9
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/rdf+xml application/xml application/x-javascript

mod_deflateとmod_expiresとHTTPヘッダへのETag付与。
CPUもそれほど喰わず、いい感じ。

ちなみに、mod_deflateによる圧縮状況は、ログとかHTTPヘッダでも確認できますが、こんな感じで確認できるサイトが分かりやすくて宜しいかと。

圧縮転送に対応していないURLを入力すると、"もしgzip転送したら...."なデータを表示してくれます。

2008年1月21日

CentOS3にPHP5+eAccelerator その2

memory_usage_100.PNG


Cache容量を食い潰していたので。増量。


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

; The amount of shared memory (in megabytes) that eAccelerator will use.
; "0" means OS default. Default value is "0".
;eaccelerator.shm_size = "0"
eaccelerator.shm_size = "64"

# /etc/init.d/httpd restart

今、phpinfo()を眺めてて気づいたんだけど、Zend Optimizer入ってないでやんの。orz
もう眠いので、コレは明日のお楽しみで。

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)

微妙。


2008年1月26日

CentOS3にPHP5+eAccelerator まとめ

ベンチマークに使っていたXOOPSアプリのcache機能を使っていなかったので、こちらも設定したところで、以下、備忘録。

Requests per second基準で。


  • eAccelerato0.9.5.2導入での効果は225%
  • mod_deflateの圧縮コストも計測しなきゃだわ。
  • XOOPS cache設定効果で250%

環境:CentOS release 3.9 (Final) + Apache2.0.40(※) + PHP 5.1.6

[初期]
Requests per second: 1.14 [#/sec] (mean)
Transfer rate: 16.41 [Kbytes/sec] received

[+eAccelerato0.9.5.2]
Requests per second: 2.57 [#/sec] (mean)
Transfer rate: 36.88 [Kbytes/sec] received

[+mod_deflate+mod_expires+ZendOptimizer-3.3.0a]
Requests per second: 2.12 [#/sec] (mean)
Transfer rate: 30.64 [Kbytes/sec] received

[+XOOPS cache設定]
Requests per second: 5.34 [#/sec] (mean)
Transfer rate: 76.95 [Kbytes/sec] received

結論


  • XOOPSに関しては、最初からCache機能に気付け、俺。
  • まぁ、非XOOPSなサイトに関してもパフォーマンスが出るようになったので、良しとする。
  • 仕事でサーバ触らなくなったので、自宅で作業するのが楽しい。


※:このApacheは脆弱性アリversionですな。先ほどupdateしました。:-)

2008年8月

          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Powered by Movable Type 4.2-ja

About 2008年1月

2008年1月にブログ「寝不足にて候(仮):」に投稿されたすべてのエントリーです。過去のものから新しいものへ順番に並んでいます。

前のアーカイブは2007年12月です。

次のアーカイブは2008年2月です。

他にも多くのエントリーがあります。メインページアーカイブページも見てください。

Creative Commons License
このブログは、次のライセンスで保護されています。 クリエイティブ・コモンズ・ライセンス.