VPSで遊ぶ -その9 仮想コンソール無しのVPSでssh-serverがコケて外からssh接続出来ない\(^o^)/オワタ鯖にならないように、任意のタイミングでtelnet鯖のポートを別鯖に飛ばす事のできるスクリプトを仕込む。その1(問題提起編)
皆様お久しぶりです。
OpenVZ系VPS(以後VPS鯖A)って、ssh-serverの設定にミスってssh-serverが起動しない完全に繋がらない状態になった場合、仮想コンソールがないのでどうしようもないですよね。外側から永遠に接続できない糞箱が出来てしまいます。
iptablesやパスワードを初期化したところで、VPS鯖Aのssh-serverがコケテたらもうお手上げ ジ・エンドにゃん。OS再インスコか、サポートに泣きつくしかありません。
AirDisplay(AjaxTerm)がある?んなもんssh鯖が落ちたら使えないし、なるべくインスコするプログラムやサービスを太らせたくない&ポートも開けたくない。速攻粛清(手動削除)の対象にしました。
私も前回のエントリー
VPSで遊ぶ -その8 ServersMan等のOpenVZ系VPSでは /etc/init/ssh.conf内の oom never は絶対に無効にしておくこと - http://d.hatena.ne.jp/dix3/20110126/1295998428
みたいにOpenVZのVPSでssh-serverがコケて詰んで、OS再インスコ&バックアップからデータ戻しという時間浪費をしてしまったことがあります。(aptitude upgradeで設定ファイルを駄目ファイルに入れ替えて繋がらなくなる罠に嵌った)
そんなリカバリー手段の少ないOpenVZ系VPSを工夫して使いたい・別系統のログイン方法が欲しい。
今日はそんなお話(の前半)。使い方は後半で。
1:対象となるユーザー
a)鯖初心者( ゚∀゚)アヒャ以外:sshとはなんぞやとか、トンネリングって?とか、秘密鍵がーとかiptablesがーとかhosts.allowがーとかその辺りの事の説明は省略。偉大なるGoogle先生に聞きましょう。きっと導いてくれることでしょう。
b)固定のグローバルIPアドレスを持つ信頼できる別鯖(以後鯖B)を持っていて、鯖Bのssh-serverに鯖Aのsshクライアントで接続できる人:
最悪な状況でも仮想シリアルコンソールが使える別事業者のVPSや、固定IPアドレスの自宅鯖を持っている人。
同じ会社のVPSでもやってやれなくはないけれど、そっちも設定ミスで繋がらなくなると完全に詰むのでおすすめしない。(aptitude upgrade時の糞設定ファイル書き換えとかで同タイミングで2台とも繋がらなくなる事が起きうる)
鯖が1台しかない場合はここでアキラメロン
c)telnetなんか使うな糞が(゚Д゚)と速攻思い浮かべられる人
普通にtelnet鯖を立ててインターネット上に公開したらいいんでないかい?って思ってしまう人はggrks
d)プロ鯖管以外
すんません、俺が怖くなって動悸息切れしてしまうのでお断りします。
ミッション・インポッシブルな仕事には使わないでください。
上記a-dを満たす者。
iptablesや、hosts.allow,hosts.denyを自らの環境向けに適切に設定出来ない人は穴が広がる可能性が増えるだけなので決して使わないでください。
2:先に結論
じゃあVPS鯖A内にtelnet鯖を立ち上げて外部から接続できるようにポートの穴を開けるか…が出来ればいいですが(実際出来てしまいますが)インターネット上に平文垂れ流しのtelnetサーバーは流石に設置できない。そこでssh の逆向きのポートフォワーディング(ssh -R)を使い、
緊急時に限ってVPS鯖A側のtelnet鯖を127.0.0.1縛り(localhost限定)で立ち上げて、鯖Aのtelnetのポート23をsshトンネリングで、別鯖Bに転送して使ってしまおうと。
主旨を簡潔に書くと
糞箱鯖Aのcrontabで
ssh -f -N -R 鯖Bの適当な空きポート番号:localhost:23 鯖Bユーザ@鯖BのIPアドレス
を何かのきっかけ(トリガー)で起動し、
鯖B側で
telnet localhost 鯖Bの適当な空きポート番号
すると鯖A接続キタ━━━(゚∀゚)━( ゚∀)━( ゚)━( )━( )━(゚ )━(∀゚ )━(゚∀゚)━━━!!! 急いでssh-serverが起動するように修復するんだ!
…てな具合でssh-serverのコケた鯖Aの内側から、外側鯖Bのssh-serverにssh(クライアント)でトンネルを掘って、糞箱鯖Aの内側にアクセスしてしまおうというわけです。
telnet over ssh を外部から任意のタイミングで実行出来るようにします。それ以上でもそれ以下でもないです。
環境
必要となる環境はこんな感じ。後半のエントリーでもう少し丁寧に手順を書きます。- 鯖A,鯖B共に Ubuntu 10.04.2 LTS i686、他の環境?シラネ
- telnetd autossh を鯖Aに追加インストール(autosshじゃなくてもいいが、コネクション切れ時に自動再接続させたいので)、鯖Aのtelnetdには、鯖A内からのみ接続できるようにiptables,hosts.allow,hosts.deny,xinetdを調整しておく。
- 実行ユーザー(ここではhogeusr)が鯖A→鯖B(のここではsfconsoleユーザー)にsshでノーパスワードで接続可能。(ssh-keygen時にノーパスワードでつながるようにしておく。無理ならexpectでも使って自動入力頑張ってください。)
- 鯖Aのcrontabが動いている、sshクライアントも動いている。(ssh-serverやsshを削除しちゃったらこれでも復旧できない)
3:トリガーチェック&自動トンネル掘りスクリプト
説明は次のエントリーで。このスクリプト(鯖Aで実行)では
鯖B側作業ディレクトリ(例: sfconsole@59.xxx.xxx.xxx:/home/sfconsole/exec_autossh/)に
鯖A(183.xxx.xxx.xxx)のipアドレスの空ファイル (例:sfconsole@59.xxx.xxx.xxx:/home/sfconsole/exec_autossh/183.xxx.xxx.xxx)
が存在する場合にはtelnet over sshの 自動穴掘り指令が下った緊急事態とみなし、
ssh -f -N -R 鯖Bの適当な空きポート番号:localhost:23 鯖Bユーザ@鯖BのIPアドレス
を実行します。(+多重起動防止チェック、pidファイル除去、鯖Bの作業ディレクトリ側へのログ書き込み付き。& autossh使用)
あとはこいつをcrontabで鯖A側で1時間に1回くらい回せばおk、ssh-serverが起動しなくなっても、
鯖Bで空ファイルをtouchすると、遅くても1時間後にはトンネル掘ったtelnetで、鯖B側から鯖Aにログインしてリカバリー作業が出来る様になります。
ソース1:鯖A(OpenVZ-VPS鯖)側設置用、閉じられた内側から自動トンネル掘りを試すスクリプト
/home/hogeusr/bin/check_sfconsole.sh
#!/bin/sh #鯖A側の一般ユーザ(hogeusr)のcrontab -e に仕込んで定期実行する。 # m h dom mon dow command #*/60 * * * * /home/hogeusr/bin/check_sfconsole.sh > /dev/null LANG=C #鯖B(Xen,KVM,または実機)側IPアドレス REMOTE_IP="59.xxx.xxx.xxx" #鯖B側ssh接続ポート番号(通常22) REMOTE_PORT="10122" #鯖B側ssh接続ユーザ名(緊急作業時専用ユーザ、ノーパスワードで接続出来るようにssh-keygen -t rsa の時に空パスで接続可能にしておくこと) REMOTE_USR="sfconsole" #鯖A(OpenVZ)側IPアドレス LOCAL_IP="183.xxx.xxx.xxx" #鯖B側の作業ディレクトリ名 DIRNAME="exec_autossh" #鯖Aのtelnet用port 23を、鯖B側の下記のポートで接続可能とする。 (鯖Bで telnet localhost 10124 ) TMP_PORT="10124" #トンネル堀り開始指令用ファイルチェック check_pid(){ if ssh -p ${REMOTE_PORT} ${REMOTE_USR}@${REMOTE_IP} "ls ${DIRNAME}/${LOCAL_IP} && rm ${DIRNAME}/${LOCAL_IP}" > /dev/null 2>&1 ; then echo "pid file ( ${DIRNAME}/${LOCAL_IP} ) exists" return 0 ; else echo "pid file ( ${DIRNAME}/${LOCAL_IP} ) NOT exists" return 1 ; fi } #autossh多重起動防止チェック check_ps(){ if ps axu |grep [a]utossh.*${REMOTE_USR}@${REMOTE_IP} > /dev/null 2>&1 ; then echo "autossh already running " return 1 ; else echo "autossh not running , now start up" return 0 ; fi } #autossh起動、トンネル掘り開始 鯖Aの23番ポートを鯖Bの${TMP_PORT}に飛ばす exec_autossh(){ if autossh -M 0 -p ${REMOTE_PORT} -f -N -R ${TMP_PORT}:localhost:23 ${REMOTE_USR}@${REMOTE_IP} ; then echo "autossh start up OK" return 0 ; else echo "autossh start up FAIL" return 1 ; fi } #ログファイルを鯖B側にssh経由で書き込み write_log(){ MSG="`date`: autossh -M 0 -p ${REMOTE_PORT} -f -N -R ${TMP_PORT}:localhost:23 ${REMOTE_USR}@${REMOTE_IP} START" if ssh -p ${REMOTE_PORT} ${REMOTE_USR}@${REMOTE_IP} "echo ${MSG} >> ${DIRNAME}/${LOCAL_IP}.log" > /dev/null 2>&1 ; then echo ${MSG} return 0 ; else return 1 ; fi } #関数呼び出し実行 main if check_pid && check_ps && exec_autossh ; then write_log fi
ソース2:鯖A(OpenVZ-VPS鯖)側設置用、ソース1の定期実行 sfclientユーザー(一般ユーザー)の crontab -e
# m h dom mon dow command */60 * * * * /home/sfclient/bin/check_sfconsole.sh > /dev/null
ソース3:鯖A(OpenVZ-VPS鯖)側設置用、/etc/hosts.allow (一例)
# /etc/hosts.allow: list of hosts that are allowed to access the system. # See the manual pages hosts_access(5) and hosts_options(5). # # Example: ALL: LOCAL @some_netgroup # ALL: .foobar.edu EXCEPT terminalserver.foobar.edu # # If you're going to protect the portmapper use the name "portmap" for the # daemon name. Remember that you can only use the keyword "ALL" and IP # addresses (NOT host or domain names) for the portmapper, as well as for # rpc.mountd (the NFS mount daemon). See portmap(8) and rpc.mountd(8) # for further information. # ALL:127.0.0.1 sshd:ALL
ソース4:鯖A(OpenVZ-VPS鯖)側設置用、/etc/hosts.deny (一例)
# /etc/hosts.deny: list of hosts that are _not_ allowed to access the system. # See the manual pages hosts_access(5) and hosts_options(5). # # Example: ALL: some.host.name, .some.domain # ALL EXCEPT in.fingerd: other.host.name, .other.domain # # If you're going to protect the portmapper use the name "portmap" for the # daemon name. Remember that you can only use the keyword "ALL" and IP # addresses (NOT host or domain names) for the portmapper, as well as for # rpc.mountd (the NFS mount daemon). See portmap(8) and rpc.mountd(8) # for further information. # # The PARANOID wildcard matches any host whose name does not match its # address. # # You may wish to enable this to ensure any programs that don't # validate looked up hostnames still leave understandable logs. In past # versions of Debian this has been the default. # ALL: PARANOID ALL:ALL
ソース5:鯖A(OpenVZ-VPS鯖)側設置用、/etc/xinetd.d/telnet (一例)
# default: off # description: Telnet server # securlevel: 30 service telnet { disable = no socket_type = stream protocol = tcp wait = no user = root server = /usr/sbin/in.telnetd server_args = -h only_from = localhost.localdomain }
今日はここまで。
インスコ方法や使い方、使用例などは後半に続く。
皆まで書かずに終わりにしたくなってきたけど続けます。
ではでは!
VPSで遊ぶ -その8 ServersMan等のOpenVZ系VPSでは /etc/init/ssh.conf内の oom never は絶対に無効にしておくこと!!(有効にしたり、コメントアウトを外したりするとオワタ\(^o^)/状態になる。)
皆様お久しぶりです。本日は注意喚起の小ネタ。
先日ServersMan VPS のUbuntu君をaptitude upgrade した時にハマってしまった小ネタです。
ServersMan等のOpenVZ系VPSのUbuntu(確認したのは10.04)では
/etc/init/ssh.conf内の oom neverを有効にすると、upstartでssh-serverが開始出来ず外からsshで繋がらないオワタ\(^o^)/鯖ができあがります。
決してaptitude upgradeで /etc/init/ssh.confを入れ替えないように。
入れ替えるともれなく oom never 行が有効の/etc/init/ssh.confが設置され、ssh端末を閉じた瞬間から二度と繋がらなくなります。(aptitude 途中でserviceの自動再起動が走り地雷設定ファイルが読み込まれるため)
ssh(openssh-server)のaptitude upgrade途中に設定ファイル入れ替えるがよろしいか[y/N] みたいな質問が出ます。
ここのデフォルト選択肢はNなのですが y にするともれなく地雷が仕込まれます。お気をつけください。
NG オワタ\(^o^)/鯖の例
/etc/init/ssh.confoom neverが有効で、この状態で端末を閉じるともれなくsshで繋がらなくなります。
ssh接続NGの例:
# ssh - OpenBSD Secure Shell server # # The OpenSSH server provides secure shell access to the system. description "OpenSSH server" start on filesystem stop on runlevel S respawn respawn limit 10 5 umask 022 # replaces SSHD_OOM_ADJUST in /etc/default/ssh oom never #<<<<<-----コレが生きてると終了のお知らせ pre-start script test -x /usr/sbin/sshd || { stop; exit 0; } test -e /etc/ssh/sshd_not_to_be_run && { stop; exit 0; } test -c /dev/null || { stop; exit 0; } mkdir -p -m0755 /var/run/sshd end script # if you used to set SSHD_OPTS in /etc/default/ssh, you can change the # 'exec' line here instead exec /usr/sbin/sshd -D
OK インスコ直後の/etc/init/ssh.conf
/etc/init/ssh.confさりげなく oom never はコメントアウトされてます。
ssh接続OKの例:
# ssh - OpenBSD Secure Shell server # # The OpenSSH server provides secure shell access to the system. description "OpenSSH server" start on filesystem stop on runlevel S expect fork respawn respawn limit 10 5 umask 022 # replaces SSHD_OOM_ADJUST in /etc/default/ssh #oom never pre-start script test -x /usr/sbin/sshd || { stop; exit 0; } test -e /etc/ssh/sshd_not_to_be_run && { stop; exit 0; } test -c /dev/null || { stop; exit 0; } mkdir -p -m0755 /var/run/sshd end script # if you used to set SSHD_OPTS in /etc/default/ssh, you can change the # 'exec' line here instead exec /usr/sbin/sshd
参考:
"oom never" makes ssh upstart job fail to start in OpenVZ container
https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/634900
参考2: Upstart issues
http://linux-vserver.org/Upstart_issues
Init procedure doesn't complete
SSHIf you've completed all above steps and some init scripts doesn't get invoked at all (most notably old SYSV init scripts) you might have encountered same error that I did. In Lucid guest I had to comment out following line in /etc/init/ssh.conf:
# replaces SSHD_OOM_ADJUST in /etc/default/ssh
oom neverto
# replaces SSHD_OOM_ADJUST in /etc/default/ssh
#oom neverAfter commenting out this line initialization completed successfully.
えー私はやらかしてしまいました。惰性で更新後に鯖三台程バックアップから再インスコしました。ご注意あれ。
ではでは!
VPSで遊ぶ -その7 LinodeとServersMan VPSとさくらのVPSの転送速度の簡易テスト結果
皆様こんにちは!
最近同じ漫画の巻を重複して買ってしまうミスを連発しているdix3です。
「この漫画はこの巻まで読んだ!」のつぶやきを記録&携帯端末で検索できる系のサービスが提供されたら多分使います。誰か作ってちょ。
さて今日はVPS鯖君達の転送速度の簡易テストをしてみます。
先週
というわけで今日は以上。来週は大きいisoイメージファイルのダウンうpロード実験と、小さい画像ファイル複数をダウンうp実験してみるヨ。
http://twitter.com/mataga/status/23073401139
と言った以上は退くに退けないのだ。
今回はテスト対象を絞り、前回の出場選手から
優勝 | 選手1:自宅鯖SSD君 | 2CPU | 1830.0 |
---|---|---|---|
二位 | 選手8:さくらのVPS 980たん | 2CPU | 1201.1 |
五位 | 選手5:Linode 512 fremont 長男 | 4CPU | 1046.7 |
八位 | 選手4:ServersMan VPS Entry君 | 1CPU | 235.7 |
関連エントリー:
VPSで遊ぶ -その1 LinodeでVPS借りた。
VPSで遊ぶ -その2 もう一台Linodeで借りた。
VPSで遊ぶ -その3 Linodeのアトランタ(内陸部)とフレモント(西海岸)のping速度比較 - やっぱり西海岸は快適
VPSで遊ぶ -その4 Zend ServerをLinodeのVPS上に入れてCodeIgniterを動かしてみた。
VPSで遊ぶ -その5 Linode制御用のiphoneアプリを入れてみる。何処でもサーバ状況確認+再起動おk+鯖作成・DNS管理まで可能
VPSで遊ぶ -その6 LinodeとServersMan VPSとさくらのVPSとさくら専用鯖と自宅鯖との比較(秋のVPS&自宅鯖unixbench一人祭り結果 詳細)
1.先に結論だけ
わたくしとてもせっかちなもので、後ろに引っ張るのは好きじゃないので先に感想だけ。
- 上記の国内VPSは大体80-100Mbpsの速度が出ているみたいです。(時間帯・利用者数によってはもっと落ちるハズ)
- 海外VPSのLinodeは帯域制限が掛かっていてどうやら50Mbps?の様です。(参考: http://twitter.com/linode/status/1585102489 , http://www.linode.com/forums/viewtopic.php?t=4162 、チケット切れば上げてくれるみたいな事がここでは書かれている。)
- 転送量上限無し、100Mbps位共有、ネットワーク距離が短いでやっぱ国内は魅力的。 (+管理画面がもっとスーパーハカー向けっぽくてカッコよければ完璧ダネ)
- 10Mbps共有・RAID1無しのエントリー鯖君達の面子が危ない。
以上…
余談だけどネットワーク系のモニタリングツールは、ここら辺 :http://www.ubuntugeek.com/bandwidth-monitoring-tools-for-ubuntu-users.htmlに沢山あるので一度見ておけばいいヨ。Ubuntuならaptitude一発でインスコ出来ます。仕事をしているフリのツールとしても最適カモ。
2.テスト方法の紹介と結果
今回は下記(A-E)の5つの時間計測テストを、日曜深夜〜月曜朝にかけて実行してみました。(2010/9/13月曜早朝)(自宅は100Mbps共有の光回線、VPS鯖は本契約済)なおeth?はOSインストールの初期状態です。MTUなどは弄ってません。(/sbin/ifconfig eth0 mtu 1466 等)
テストA:外部http鯖→VPSへ686MBのisoファイル(CD1枚分データ)のダウンロード
テスト方法:
jaist.ac.jpにあるubuntu-10.04.1-desktop-i386.iso のダウンロード時間を計測します。
目的:
外部→各VPSへ、大きな1ファイルをダウンロードする時の目安を知りたい。
実行方法:(各VPS鯖上で)
time wget http://(自粛により中略)/10.04/ubuntu-10.04.1-desktop-i386.iso
テストAの結果(小数点第二位以下四捨五入):
経路 | 所要時間 | MB/秒 |
---|---|---|
外部http鯖→自宅鯖 | 5分17秒 | 2.2 MB/秒 |
外部http鯖→さくらのVPS | 1分10秒 | 9.9 MB/秒 |
外部http鯖→Linode Fremont | 2分37秒 | 4.4 MB/秒 |
外部http鯖→ServersMan VPS | 1分04秒 | 10.7 MB/秒 |
国内外部http鯖→国外VPSはその約半分。(35Mbps制限 or 50Mbps制限に引っかかってる?)
(自宅鯖が遅いですが後日計測し直した時は3分12秒,3.57MB/秒でした。その時々の状況によってだいぶ変わります。)
テストB:テストAで取得した686MBのisoファイル(CD1枚分のデータ)を各鯖→自宅鯖にscpでダウンロード
テスト方法:
各VPS鯖上にあるubuntu-10.04.1-desktop-i386.iso のダウンロード時間を計測します。
目的:
各VPS→光回線の自宅へ、大きな1ファイルをダウンロードする時の目安を知りたい。
実行方法:(自宅鯖上で)
time scp -P ポート番号 ユーザ名@VPS鯖側IPアドレス:/tmp/ubuntu-10.04.1-desktop-i386.iso ./
テストBの結果:
経路 | 所要時間 | MB/秒 |
---|---|---|
さくらのVPS→自宅鯖 | 2分14秒 | 5.2 MB/秒 |
Linode Fremont→自宅鯖 | 6分03秒 | 1.9 MB/秒 |
ServersMan VPS→自宅鯖 | 2分02秒 | 5.7 MB/秒 |
国外VPSから自宅へは、2MB/秒程度。
テストC:自宅鯖→各VPSへ大量画像(ファイル数3156個、702MB(約CD1枚分))をrsyncで転送
テスト方法:
写真素材集系の大量の画像(imgsディレクトリ以下全部)をrsyncで自宅→各VPSに転送します。(エロ画像では断じてない!)
目的:
自宅→各VPSへ大量ファイルをアップロードする時の目安を知りたい。
実行方法:(自宅鯖上で)
time rsync -av -e "ssh -p ポート番号" ./imgs ユーザ名@VPS鯖側IPアドレス:/tmp/
テストCの結果:
経路 | 所要時間 | MB/秒 |
---|---|---|
自宅鯖→さくらのVPS | 1分20秒 | 8.5 MB/秒 |
自宅鯖→Linode Fremont | 2分24秒 | 4.8 MB/秒 |
自宅鯖→ServersMan VPS | 1分39秒 | 6.9 MB/秒 |
テストD:さくらのVPS←→ServersMan & さくらのVPS←→Linode間での686MBisoファイルのSCP送受信
テスト方法:
VPS間で702MBのisoファイルをSCPで送受信します。
目的:
異なる会社間のVPSを跨がった、大きいダンプファイル等のバックアップは使用に耐えうるか知りたい。(バックアップは距離的・物理的に離しておく。東京大阪米国の複数のデータセンターor会社が同時にあぼーんならアキラメロン)
実行方法:(さくらのVPS鯖上で)
#送信1 time scp -P ポート番号 ./ubuntu-10.04.1-desktop-i386.iso ユーザ名@ServersMan側IPアドレス:/tmp/ #受信1 time scp -P ポート番号 ユーザ名@ServersMan側IPアドレス:/tmp/ubuntu-10.04.1-desktop-i386.iso ./ #送信2 time scp -P ポート番号 ./ubuntu-10.04.1-desktop-i386.iso ユーザ名@Linode側IPアドレス:/tmp/ #受信2 time scp -P ポート番号 ユーザ名@Linode側IPアドレス:/tmp/ubuntu-10.04.1-desktop-i386.iso ./(コマンド実行はさくら側で、時間の都合上逆からの送受信は省略しています。)
テストDの結果:
経路 | 所要時間 | MB/秒 |
---|---|---|
さくらのVPS→ServersMan VPS | 1分15秒 | 9.1 MB/秒 |
さくらのVPS←ServersMan VPS | 1分09秒 | 9.9 MB/秒 |
さくらのVPS→Linode Fremont | 2分15秒 | 5.1 MB/秒 |
さくらのVPS←Linode Fremont | 5分34秒 | 2.1 MB/秒 |
テストE:さくらのVPS←→ServersMan & さくらのVPS←→Linode間での大量画像
(ファイル数3156個、702MB(約CD1枚分))rsync送受信
テスト方法:
テストDと同様の事をファイル数3156個、トータル702MBの大量画像でrsyncにて実行します。
目的:
異なる会社間のVPSを跨がったファイルの日次差分バックアップを想定。どのくらいの時間が掛かるか目安を知りたい。
実行方法:(さくらのVPS鯖上で)
#送信1 time rsync -av -e "ssh -p ポート番号" ./imgs ユーザ名@ServersMan側IPアドレス:/tmp/ #受信1 time rsync -av -e "ssh -p ポート番号" ユーザ名@ServersMan側IPアドレス:/tmp/imgs ./ #送信2 time rsync -av -e "ssh -p ポート番号" ./imgs ユーザ名@Linode側IPアドレス:/tmp/ #受信2 time rsync -av -e "ssh -p ポート番号" ユーザ名@Linode側IPアドレス:/tmp/imgs ./(コマンド実行はさくら側で、時間の都合上逆からの送受信は省略しています。)
テストEの結果:
経路 | 所要時間 | MB/秒 |
---|---|---|
さくらのVPS→ServersMan VPS | 1分26秒 | 7.9 MB/秒 |
さくらのVPS←ServersMan VPS | 1分13秒 | 9.3 MB/秒 |
さくらのVPS→Linode Fremont | 2分28秒 | 4.7 MB/秒 |
さくらのVPS←Linode Fremont | 4分30秒 | 2.5 MB/秒 |
という感じで国内VPS君達の成績が良いですね。
また画面ショットも撮っていますが、画像数が多いので掲載は省略します。(一応こんな感じで証拠は押さえてあるぜキリッ)
ヘビーユーザーが増加した時の速度低下具合や、障害の発生・リカバリーの具合がまだ未知数なので私は1年位気長に寝かしておきます。
今日はここまで。ではでは!
VPSで遊ぶ -その6 LinodeとServersMan VPSとさくらのVPSとさくら専用鯖と自宅鯖との比較(秋のVPS&自宅鯖unixbench一人祭り結果 詳細)
皆様こんにちは!
イカ娘かわいいよイカ娘(http://www.ika-musume.com/)。ゲソゲソうるさくてすみません。すっかり洗脳されてしまいました。
今日は、きのうツイッカーでつぶやいていたネタをうpしておきます。
関連エントリー:
VPSで遊ぶ -その1 LinodeでVPS借りた。
VPSで遊ぶ -その2 もう一台Linodeで借りた。
VPSで遊ぶ -その3 Linodeのアトランタ(内陸部)とフレモント(西海岸)のping速度比較 - やっぱり西海岸は快適
VPSで遊ぶ -その4 Zend ServerをLinodeのVPS上に入れてCodeIgniterを動かしてみた。
VPSで遊ぶ -その5 Linode制御用のiphoneアプリを入れてみる。何処でもサーバ状況確認+再起動おk+鯖作成・DNS管理まで可能
VPSで遊ぶ -その7 LinodeとServersMan VPSとさくらのVPSの転送速度の簡易テスト結果
1.前説
突然すぎて何の事だかわからない方の為に一応少しだけ抜粋。
( http://twitter.com/mataga の 2010/9/5夜〜9/6早朝にかけてのログ。)
祭りといっても一人神輿です。ベンチを黙々ととる作業だと退屈なので擬人化しています。言わせんな恥ずか(ry
発端:他の方のレポートを見てLinodeほかVPS達と自宅マシン達をちょっと比較したくなったので
VPS界隈が活況づいているので、幾つかの環境でunixbenchちゅう。とりあえず Linode 512 x 3台 と、ServersMan エントリープランと、さくらの専用鯖と自宅鯖と自宅atomネットブックで動かしてみる。
いいわけ:一応比較的すいていそうな日曜夜に行いました。
VPS鯖でベンチ動かすなって? 普段ものすごくおとなしくしている鯖だから1回だけ許してちょ、先っぽだけ。
2.結果だけ先に書いておく
忙しい人の為に先に結論だけ。(選手番号と結果数値はアンカーになっています。選手番号は選手紹介へ、結果数値は詳細データに飛びます。)(unixbenchは http://byte-unixbench.googlecode.com からソースを取得。インスコ方法は入力可能文字数の関係上割愛)
BYTE UNIX Benchmarks (Version 5.1.2) 1コアでの比較(1 parallel process):System Benchmarks Index Score:
優勝 | 選手1:自宅鯖SSD君 | 899.4 |
---|---|---|
二位 | 選手8:さくらのVPS 980たん | 632.6 |
三位 | 選手3:さくら専鯖せんぷたん | 469.8 |
四位 | 選手6:Linode 512 atlanta 次男 | 460.6 |
五位 | 選手7:Linode 512 fremont 三男 | 432.5 |
六位 | 選手5:Linode 512 fremont 長男 | 430.6 |
七位 | 選手2:自宅SSDアトムネットブック君 | 244.8 |
八位 | 選手4:ServersMan VPS Entry君 | 235.7 |
優勝 | 選手1:自宅鯖SSD君 | 2CPU | 1830.0 |
---|---|---|---|
二位 | 選手8:さくらのVPS 980たん | 2CPU | 1201.1 |
三位 | 選手6:Linode 512 atlanta 次男 | 4CPU | 1106.2 |
四位 | 選手7:Linode 512 fremont 三男 | 4CPU | 1076.9 |
五位 | 選手5:Linode 512 fremont 長男 | 4CPU | 1046.7 |
六位 | 選手3:さくら専鯖せんぷたん | 1CPU | 469.8 |
七位 | 選手2:自宅SSDアトムネットブック君 | 疑似2CPU | 341.6 |
八位 | 選手4:ServersMan VPS Entry君 | 1CPU | 235.7 |
詳細データはこのページの下側に貼っておきます。
(2010/09/15補足追記)
使っているプラン・価格帯・付随機能共に横並びではない運動会の参考記録って事でご了承ください。
(自宅マシンはSSD化してゲタを履かせてます。手持ちの空いている鯖で遊んだだけです。)
案件の条件によって最善の選択肢(専鯖・VPS鯖・共有鯖・価格帯・必要な付随機能等)は自ずと変わってきます。
(2010/09/15補足追記おわり)
3.出場選手紹介
筋肉ムキムキの人は居ません。皆エントリーレベル。イタイ人は居ます。OS: | 32bit Ubuntu 10.04 デスクトップ |
---|---|
CPU(2コア): | Pentium(R) Dual-Core CPU E6500 @ 2.93GHz (5867.2 bogomips) |
MEM: | 4GB DDR2 |
マザボ: | Intel DG45FC |
HDD: | 40GB SSD (intel X25-V 40GB) + 日立のHDP725050GLA360 500GB x 2 ソフトウェアRAID1 |
hdparm -Tt: | SSDが Timing cached reads: 1525.20 MB/sec ,Timing buffered disk reads:142.53 MB/sec … trim要るかなぁ…遅くなってる気もしなくはない。 HDDが 1561.96 MB/sec , 90.84 MB/sec |
特徴: | Core2Quad 9550sを外された悲しいmini-itx自作マシン。自作は最近小さ目なのを攻めています。 |
OS: | 32bit Ubuntu 10.04 Netbook Remix |
---|---|
CPU(疑似2コア): | Intel(R) Atom(TM) CPU N270 @ 1.60GHz (3192.0 bogomips) |
MEM: | 1GB DDR2 |
HDD: | 40GB SSD (intel X25-V 40GBに交換済み) |
hdparm -Tt: | 624.92 MB/sec ,105.46 MB/sec |
特徴: | 元はAspire One AOA150ダヨ(http://www2.acer.co.jp/aspireone/a150/spec.html) HDDをSSDに載せ替えて足回りキビキビ。 |
選手3:さくら専鯖せんぷたん 三歳半くらい上に戻る
OS: | 32bit Fedora バージョンは事情により内緒、近々リプレース予定 |
---|---|
CPU(1コア): | AMD Sempron(tm) Processor 2800+ (3208.9 bogomips) |
MEM: | 1GB DDR2 |
マザボ: | ASUS M2NPV-VM /usr/sbin/dmidecodeで確認 |
HDD: | 250GB |
hdparm -Tt: | 831.26 MB/sec , 60.88 MB/sec |
特徴: | 昔の10Mスタンダードプラン。今はもっと性能がいいのがあるヨ。 |
ping: | ServersMan東京から17.837ms位 (所在地大阪) |
月額: | 10,290円 |
URL: | http://server.sakura.ad.jp/dedicated/basic/ |
選手4:ServersMan VPS Entry君 一ヶ月くらい上に戻る
OS: | 32bit CentOS release 5.5 |
---|---|
CPU(1コア使用可): | Intel(R) Xeon(R) CPU L5520 @ 2.27GHz (4522.1 bogomips) |
MEM: | 512MB(保証は256MB) |
HDD: | 10GB |
hdparm -Tt: | Permission deniedとなって禁則事項です。 |
特徴: | 体感は普通にサクサクしてる。(数年前のVPS達の遅さとはレベルが違う。そこのところ誤解無きよう。富豪プログラム動かすのなら知らん。富豪なんだから富豪鯖使えばいいじゃん。) |
ping: | さくら専用鯖大阪から16.783ms位 (所在地東京) |
月額: | 490円 |
URL: | http://dream.jp/vps/ |
選手5:Linode 512 fremont 長男 一歳半くらい上に戻る
OS: | 32bit Ubuntu 9.10(8.04LTSからアップグレード、Ubuntuはアップグレード時にハマリが少なくて楽) |
---|---|
CPU(4コア使用可): | Intel(R) Xeon(R) CPU L5420 @ 2.50GHz (5000.2 bogomips) |
MEM: | 512MB |
HDD: | 16GB |
hdparm -Tt: | 4159.26 MB/sec ,59.20 MB/sec |
特徴: | コンパネが充実なんだかスゲー、あとiphoneでAPI経由で操作出来るっす。→(VPSで遊ぶ -その5 Linode制御用のiphoneアプリを入れてみる。何処でもサーバ状況確認+再起動おk+鯖作成・DNS管理まで可能 http://d.hatena.ne.jp/dix3/20100522/1274468533) |
ping: | さくら専用鯖大阪から115.040ms位(所在地 米国西海岸) |
月額: | 19.95ドル |
URL: | http://www.linode.com/ |
選手6:Linode 512 atlanta 次男 一歳半くらい上に戻る
OS: | 32bit Ubuntu 9.10(8.04LTSからアップグレード) |
---|---|
CPU(4コア使用可): | Intel(R) Xeon(R) CPU L5420 @ 2.50GHz (5000.2 bogomips) |
MEM: | 512MB |
HDD: | 16GB |
hdparm -Tt: | 4981.69 MB/sec ,79.69 MB/sec 長男と差があるように見えるがそれはhdparm計測時の誤差の範囲の幻。また、同居人の挙動によって異なる。 |
特徴: | 米国外利用者は海側に借りるのでFremontよりデータセンター丸ごと攻撃を受けることが少ない?Fremontが不安定でもこっちは無風状態、つかDDoS攻撃▼ |
ping: | さくら専用鯖大阪から167.502ms位(所在地 米国南東部フロリダ半島より上側) |
月額: | 19.95ドル + 1IPアドレス追加で 20.95ドル |
選手7:Linode 512 fremont 三男 一ヶ月くらい上に戻る
OS: | 32bit Ubuntu 10.04 LTS |
---|---|
CPU(4コア使用可): | Intel(R) Xeon(R) CPU L5520 @ 2.27GHz (4533.5 bogomips) |
MEM: | 512MB |
HDD: | 16GB |
hdparm -Tt: | 5593.44 MB/sec ,125.77 MB/sec 長男次男と差があるように見えるがそれは上記に同じ。 |
特徴: | CPUがNehalemに世代交代。上記ServersManとCPUは一緒、使用可能コア数は4倍 |
ping: | さくら専用鯖大阪から117.289ms位(所在地 米国西海岸) |
月額: | 19.95ドル + 1IPアドレス追加で 20.95ドル |
OS: | 64bit CentOS release 5.5 |
---|---|
CPU(2コア使用可): | Intel(R) Core(TM)2 Duo CPU T7700 @ 2.40GHz (5320.2 bogomips) /proc/cpuinfo読みのコピペ |
MEM: | 512MB |
HDD: | 20GB |
hdparm -Tt: | 4130.50 MB/sec ,87.50 MB/sec |
特徴: | リクエストにお答えして計測飛び入り参加のニューフェイス。手つかずの状態でお試し期限が切れてたので個人で申し込んでリベンジ。 |
ping: | さくら専用鯖大阪から12.029ms位(所在地 |
月額: | 980円 |
URL: | http://vps.sakura.ad.jp/ |
4.BYTE UNIX Benchmarks (Version 5.1.2)の詳細結果
一部都合によりマスクしています。(数字は改変していないです。)
Benchmark of 選手1:自宅鯖SSD君 / GNU/Linux on 日 9月 05 2010上に戻る
Test System Information
System: | 選手1:自宅鯖SSD君 : GNU/Linux | |
OS: | GNU/Linux -- 2.6.32-24-generic-pae -- #42-Ubuntu SMP Fri Aug 20 15:37:22 UTC 2010 | |
Machine: | i686: unknown | |
Language: | en_US.utf8 (charmap="UTF-8", collate="UTF-8") | |
CPUs: | 0: | Pentium(R) Dual-Core CPU E6500 @ 2.93GHz (5867.2 bogomips) Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, Intel virtualization |
1: | Pentium(R) Dual-Core CPU E6500 @ 2.93GHz (5867.2 bogomips) Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, Intel virtualization |
|
Uptime: | xxxxxxxxx |
Benchmark Run: 2 CPUs; 1 parallel process
Time: 20:53:12 - 21:21:42; 28m 30s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 16575117.1 | lps | 10.0 s | 7 | 116700.0 | 1420.3 |
Double-Precision Whetstone | 2928.3 | MWIPS | 10.0 s | 7 | 55.0 | 532.4 |
Execl Throughput | 2065.2 | lps | 29.8 s | 2 | 43.0 | 480.3 |
File Copy 1024 bufsize 2000 maxblocks | 543816.4 | KBps | 30.0 s | 2 | 3960.0 | 1373.3 |
File Copy 256 bufsize 500 maxblocks | 184812.5 | KBps | 30.0 s | 2 | 1655.0 | 1116.7 |
File Copy 4096 bufsize 8000 maxblocks | 1081918.6 | KBps | 30.0 s | 2 | 5800.0 | 1865.4 |
Pipe Throughput | 904490.9 | lps | 10.0 s | 7 | 12440.0 | 727.1 |
Pipe-based Context Switching | 55268.6 | lps | 10.0 s | 7 | 4000.0 | 138.2 |
Process Creation | 9533.9 | lps | 30.0 s | 2 | 126.0 | 756.7 |
Shell Scripts (1 concurrent) | 5946.9 | lpm | 60.0 s | 2 | 42.4 | 1402.6 |
Shell Scripts (8 concurrent) | 1129.5 | lpm | 60.0 s | 2 | 6.0 | 1882.6 |
System Call Overhead | 2016094.8 | lps | 10.0 s | 7 | 15000.0 | 1344.1 |
System Benchmarks Index Score: | 899.4 |
Benchmark Run: 2 CPUs; 2 parallel processes
Time: 21:21:42 - 21:50:23; 28m 41s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 30515512.1 | lps | 10.0 s | 7 | 116700.0 | 2614.9 |
Double-Precision Whetstone | 5589.7 | MWIPS | 10.1 s | 7 | 55.0 | 1016.3 |
Execl Throughput | 7386.7 | lps | 29.9 s | 2 | 43.0 | 1717.8 |
File Copy 1024 bufsize 2000 maxblocks | 865482.9 | KBps | 30.0 s | 2 | 3960.0 | 2185.6 |
File Copy 256 bufsize 500 maxblocks | 327286.3 | KBps | 30.0 s | 2 | 1655.0 | 1977.6 |
File Copy 4096 bufsize 8000 maxblocks | 1465084.8 | KBps | 30.0 s | 2 | 5800.0 | 2526.0 |
Pipe Throughput | 1710572.1 | lps | 10.0 s | 7 | 12440.0 | 1375.1 |
Pipe-based Context Switching | 487948.5 | lps | 10.0 s | 7 | 4000.0 | 1219.9 |
Process Creation | 22001.3 | lps | 30.0 s | 2 | 126.0 | 1746.1 |
Shell Scripts (1 concurrent) | 9002.3 | lpm | 60.0 s | 2 | 42.4 | 2123.2 |
Shell Scripts (8 concurrent) | 1137.8 | lpm | 60.1 s | 2 | 6.0 | 1896.3 |
System Call Overhead | 3600219.4 | lps | 10.0 s | 7 | 15000.0 | 2400.1 |
System Benchmarks Index Score: | 1830.0 |
Benchmark of 選手2:自宅SSDアトムネットブック君 / GNU/Linux on 日 9月 05 2010戻る
Test System Information
System: | 選手2:自宅SSDアトムネットブック君: GNU/Linux | |
OS: | GNU/Linux -- 2.6.32-24-generic -- #42-Ubuntu SMP Fri Aug 20 14:24:04 UTC 2010 | |
Machine: | i686: unknown | |
Language: | en_US.utf8 (charmap="UTF-8", collate="UTF-8") | |
CPUs: | 0: | Intel(R) Atom(TM) CPU N270 @ 1.60GHz (3192.0 bogomips) Hyper-Threading, MMX, Physical Address Ext |
1: | Intel(R) Atom(TM) CPU N270 @ 1.60GHz (3191.9 bogomips) Hyper-Threading, MMX, Physical Address Ext |
|
Uptime: | xxxxxxxxx |
Benchmark Run: 2 CPUs; 1 parallel process
Time: 21:16:40 - 21:45:01; 28m 21s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 4868043.3 | lps | 10.0 s | 7 | 116700.0 | 417.1 |
Double-Precision Whetstone | 576.0 | MWIPS | 10.1 s | 7 | 55.0 | 104.7 |
Execl Throughput | 636.2 | lps | 29.9 s | 2 | 43.0 | 148.0 |
File Copy 1024 bufsize 2000 maxblocks | 122455.5 | KBps | 30.0 s | 2 | 3960.0 | 309.2 |
File Copy 256 bufsize 500 maxblocks | 35042.9 | KBps | 30.0 s | 2 | 1655.0 | 211.7 |
File Copy 4096 bufsize 8000 maxblocks | 330329.8 | KBps | 30.0 s | 2 | 5800.0 | 569.5 |
Pipe Throughput | 291455.9 | lps | 10.0 s | 7 | 12440.0 | 234.3 |
Pipe-based Context Switching | 60394.2 | lps | 10.0 s | 7 | 4000.0 | 151.0 |
Process Creation | 2145.5 | lps | 30.0 s | 2 | 126.0 | 170.3 |
Shell Scripts (1 concurrent) | 1400.2 | lpm | 60.0 s | 2 | 42.4 | 330.2 |
Shell Scripts (8 concurrent) | 220.9 | lpm | 60.2 s | 2 | 6.0 | 368.2 |
System Call Overhead | 392715.8 | lps | 10.0 s | 7 | 15000.0 | 261.8 |
System Benchmarks Index Score: | 244.8 |
Benchmark Run: 2 CPUs; 2 parallel processes
Time: 21:45:01 - 22:13:07; 28m 06s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 6069540.3 | lps | 10.0 s | 7 | 116700.0 | 520.1 |
Double-Precision Whetstone | 923.3 | MWIPS | 10.1 s | 7 | 55.0 | 167.9 |
Execl Throughput | 1633.4 | lps | 29.9 s | 2 | 43.0 | 379.9 |
File Copy 1024 bufsize 2000 maxblocks | 142723.8 | KBps | 30.0 s | 2 | 3960.0 | 360.4 |
File Copy 256 bufsize 500 maxblocks | 42061.0 | KBps | 30.0 s | 2 | 1655.0 | 254.1 |
File Copy 4096 bufsize 8000 maxblocks | 356087.5 | KBps | 30.0 s | 2 | 5800.0 | 613.9 |
Pipe Throughput | 313934.1 | lps | 10.0 s | 7 | 12440.0 | 252.4 |
Pipe-based Context Switching | 85824.0 | lps | 10.0 s | 7 | 4000.0 | 214.6 |
Process Creation | 5434.7 | lps | 30.0 s | 2 | 126.0 | 431.3 |
Shell Scripts (1 concurrent) | 1717.7 | lpm | 60.0 s | 2 | 42.4 | 405.1 |
Shell Scripts (8 concurrent) | 219.9 | lpm | 60.3 s | 2 | 6.0 | 366.5 |
System Call Overhead | 585077.1 | lps | 10.0 s | 7 | 15000.0 | 390.1 |
System Benchmarks Index Score: | 341.6 |
Benchmark of 選手3:さくら専鯖せんぷたん / GNU/Linux on 日 9月 05 2010上に戻る
Test System Information
System: | 選手3:さくら専鯖せんぷたん: GNU/Linux | |
OS: | GNU/Linux --xxxxxxxxx | |
Machine: | i686: i386 | |
Language: | en_US.utf8 (charmap="UTF-8", collate="UTF-8") | |
CPUs: | 0: | AMD Sempron(tm) Processor 2800+ (3208.9 bogomips) x86-64, MMX, AMD MMX, Physical Address Ext, SYSCALL/SYSRET |
Uptime: | xxxxxxxxx |
Benchmark Run: 1 CPU; 1 parallel process
Time: 20:56:08 - 21:24:31; 28m 23s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 5111786.4 | lps | 10.0 s | 7 | 116700.0 | 438.0 |
Double-Precision Whetstone | 1329.4 | MWIPS | 9.9 s | 7 | 55.0 | 241.7 |
Execl Throughput | 1827.7 | lps | 29.9 s | 2 | 43.0 | 425.1 |
File Copy 1024 bufsize 2000 maxblocks | 239318.5 | KBps | 30.0 s | 2 | 3960.0 | 604.3 |
File Copy 256 bufsize 500 maxblocks | 68012.5 | KBps | 30.0 s | 2 | 1655.0 | 411.0 |
File Copy 4096 bufsize 8000 maxblocks | 562454.0 | KBps | 30.0 s | 2 | 5800.0 | 969.7 |
Pipe Throughput | 445054.3 | lps | 10.0 s | 7 | 12440.0 | 357.8 |
Pipe-based Context Switching | 88469.6 | lps | 10.0 s | 7 | 4000.0 | 221.2 |
Process Creation | 6804.6 | lps | 30.0 s | 2 | 126.0 | 540.0 |
Shell Scripts (1 concurrent) | 2690.9 | lpm | 60.0 s | 2 | 42.4 | 634.6 |
Shell Scripts (8 concurrent) | 378.8 | lpm | 60.1 s | 2 | 6.0 | 631.4 |
System Call Overhead | 935254.3 | lps | 10.0 s | 7 | 15000.0 | 623.5 |
System Benchmarks Index Score: | 469.8 |
Benchmark of 選手4:ServersMan VPS Entry君 / GNU/Linux on 日 9月 05 2010上に戻る
Test System Information
System: | 選手4:ServersMan VPS Entry君: GNU/Linux | |
OS: | GNU/Linux -- 2.6.18-164.15.1.el5.028stab068.9 -- #1 SMP Tue Mar 30 18:07:38 MSD 2010 | |
Machine: | i686: i386 | |
Language: | en_US.utf8 (charmap="UTF-8", collate="UTF-8") | |
CPUs: | 0: | Intel(R) Xeon(R) CPU L5520 @ 2.27GHz (4522.1 bogomips) Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization |
Uptime: | xxxxxxxxx |
Benchmark Run: 1 CPU; 1 parallel process
Time: 20:45:24 - 21:16:44; 31m 20s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 2850172.7 | lps | 10.0 s | 7 | 116700.0 | 244.2 |
Double-Precision Whetstone | 1392.9 | MWIPS | 10.2 s | 7 | 55.0 | 253.3 |
Execl Throughput | 988.4 | lps | 29.5 s | 2 | 43.0 | 229.8 |
File Copy 1024 bufsize 2000 maxblocks | 109360.6 | KBps | 30.0 s | 2 | 3960.0 | 276.2 |
File Copy 256 bufsize 500 maxblocks | 32538.3 | KBps | 30.0 s | 2 | 1655.0 | 196.6 |
File Copy 4096 bufsize 8000 maxblocks | 299816.1 | KBps | 30.0 s | 2 | 5800.0 | 516.9 |
Pipe Throughput | 235400.4 | lps | 10.0 s | 7 | 12440.0 | 189.2 |
Pipe-based Context Switching | 71152.9 | lps | 10.0 s | 7 | 4000.0 | 177.9 |
Process Creation | 3459.6 | lps | 30.0 s | 2 | 126.0 | 274.6 |
Shell Scripts (1 concurrent) | 1141.0 | lpm | 60.0 s | 2 | 42.4 | 269.1 |
Shell Scripts (8 concurrent) | 146.6 | lpm | 60.4 s | 2 | 6.0 | 244.3 |
System Call Overhead | 181603.3 | lps | 10.0 s | 7 | 15000.0 | 121.1 |
System Benchmarks Index Score: | 235.7 |
Benchmark of 選手5:Linode 512 fremont 長男 / GNU/Linux on 日 9月 05 2010上に戻る
Test System Information
System: | 選手5:Linode 512 fremont 長男: GNU/Linux | |
OS: | GNU/Linux -- 2.6.32.12-linode25 -- #1 SMP Wed Apr 28 19:25:11 UTC 2010 | |
Machine: | i686: unknown | |
Language: | en_US.utf8 (charmap="UTF-8", collate="UTF-8") | |
CPUs: | 0: | Intel(R) Xeon(R) CPU L5420 @ 2.50GHz (5000.2 bogomips) Hyper-Threading, MMX, Physical Address Ext |
1: | Intel(R) Xeon(R) CPU L5420 @ 2.50GHz (5000.2 bogomips) Hyper-Threading, MMX, Physical Address Ext |
|
2: | Intel(R) Xeon(R) CPU L5420 @ 2.50GHz (5000.2 bogomips) Hyper-Threading, MMX, Physical Address Ext |
|
3: | Intel(R) Xeon(R) CPU L5420 @ 2.50GHz (5000.2 bogomips) Hyper-Threading, MMX, Physical Address Ext |
|
Uptime: | xxxxxxxxx |
Benchmark Run: 4 CPUs; 1 parallel process
Time: 20:52:12 - 21:20:57; 28m 45s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 12747873.6 | lps | 10.0 s | 7 | 116700.0 | 1092.4 |
Double-Precision Whetstone | 2299.1 | MWIPS | 10.1 s | 7 | 55.0 | 418.0 |
Execl Throughput | 1219.2 | lps | 30.0 s | 2 | 43.0 | 283.5 |
File Copy 1024 bufsize 2000 maxblocks | 262528.7 | KBps | 30.0 s | 2 | 3960.0 | 663.0 |
File Copy 256 bufsize 500 maxblocks | 74970.3 | KBps | 30.0 s | 2 | 1655.0 | 453.0 |
File Copy 4096 bufsize 8000 maxblocks | 613754.2 | KBps | 30.0 s | 2 | 5800.0 | 1058.2 |
Pipe Throughput | 416796.1 | lps | 10.0 s | 7 | 12440.0 | 335.0 |
Pipe-based Context Switching | 18598.1 | lps | 10.1 s | 7 | 4000.0 | 46.5 |
Process Creation | 2219.9 | lps | 30.0 s | 2 | 126.0 | 176.2 |
Shell Scripts (1 concurrent) | 3213.3 | lpm | 60.0 s | 2 | 42.4 | 757.9 |
Shell Scripts (8 concurrent) | 914.9 | lpm | 60.0 s | 2 | 6.0 | 1524.9 |
System Call Overhead | 466715.0 | lps | 10.0 s | 7 | 15000.0 | 311.1 |
System Benchmarks Index Score: | 430.6 |
Benchmark Run: 4 CPUs; 4 parallel processes
Time: 21:20:57 - 21:49:39; 28m 42s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 48374022.7 | lps | 10.0 s | 7 | 116700.0 | 4145.2 |
Double-Precision Whetstone | 9019.8 | MWIPS | 10.0 s | 7 | 55.0 | 1640.0 |
Execl Throughput | 4480.1 | lps | 29.3 s | 2 | 43.0 | 1041.9 |
File Copy 1024 bufsize 2000 maxblocks | 256742.1 | KBps | 30.1 s | 2 | 3960.0 | 648.3 |
File Copy 256 bufsize 500 maxblocks | 71965.2 | KBps | 30.0 s | 2 | 1655.0 | 434.8 |
File Copy 4096 bufsize 8000 maxblocks | 717374.5 | KBps | 30.0 s | 2 | 5800.0 | 1236.9 |
Pipe Throughput | 1644445.2 | lps | 10.0 s | 7 | 12440.0 | 1321.9 |
Pipe-based Context Switching | 128898.7 | lps | 10.0 s | 7 | 4000.0 | 322.2 |
Process Creation | 7071.2 | lps | 30.0 s | 2 | 126.0 | 561.2 |
Shell Scripts (1 concurrent) | 7559.7 | lpm | 60.0 s | 2 | 42.4 | 1783.0 |
Shell Scripts (8 concurrent) | 1026.2 | lpm | 60.3 s | 2 | 6.0 | 1710.3 |
System Call Overhead | 1441374.2 | lps | 10.0 s | 7 | 15000.0 | 960.9 |
System Benchmarks Index Score: | 1046.7 |
Benchmark of 選手6:Linode 512 atlanta 次男 / GNU/Linux on 日 9月 05 2010上に戻る
Test System Information
System: | 選手6:Linode 512 atlanta 次男: GNU/Linux | |
OS: | GNU/Linux -- 2.6.32.12-linode25 -- #1 SMP Wed Apr 28 19:25:11 UTC 2010 | |
Machine: | i686: unknown | |
Language: | en_US.utf8 (charmap="UTF-8", collate="UTF-8") | |
CPUs: | 0: | Intel(R) Xeon(R) CPU L5420 @ 2.50GHz (5000.2 bogomips) Hyper-Threading, MMX, Physical Address Ext |
1: | Intel(R) Xeon(R) CPU L5420 @ 2.50GHz (5000.2 bogomips) Hyper-Threading, MMX, Physical Address Ext |
|
2: | Intel(R) Xeon(R) CPU L5420 @ 2.50GHz (5000.2 bogomips) Hyper-Threading, MMX, Physical Address Ext |
|
3: | Intel(R) Xeon(R) CPU L5420 @ 2.50GHz (5000.2 bogomips) Hyper-Threading, MMX, Physical Address Ext |
|
Uptime: | xxxxxxxxx |
Benchmark Run: 4 CPUs; 1 parallel process
Time: 20:58:44 - 21:27:00; 28m 16s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 12945701.6 | lps | 10.0 s | 7 | 116700.0 | 1109.3 |
Double-Precision Whetstone | 2327.3 | MWIPS | 10.1 s | 7 | 55.0 | 423.2 |
Execl Throughput | 1290.6 | lps | 30.0 s | 2 | 43.0 | 300.2 |
File Copy 1024 bufsize 2000 maxblocks | 282905.4 | KBps | 30.0 s | 2 | 3960.0 | 714.4 |
File Copy 256 bufsize 500 maxblocks | 77275.5 | KBps | 30.0 s | 2 | 1655.0 | 466.9 |
File Copy 4096 bufsize 8000 maxblocks | 656152.8 | KBps | 30.0 s | 2 | 5800.0 | 1131.3 |
Pipe Throughput | 423063.0 | lps | 10.0 s | 7 | 12440.0 | 340.1 |
Pipe-based Context Switching | 26794.2 | lps | 10.0 s | 7 | 4000.0 | 67.0 |
Process Creation | 2287.9 | lps | 30.0 s | 2 | 126.0 | 181.6 |
Shell Scripts (1 concurrent) | 3349.3 | lpm | 60.0 s | 2 | 42.4 | 789.9 |
Shell Scripts (8 concurrent) | 999.7 | lpm | 60.0 s | 2 | 6.0 | 1666.1 |
System Call Overhead | 472515.0 | lps | 10.0 s | 7 | 15000.0 | 315.0 |
System Benchmarks Index Score: | 460.6 |
Benchmark Run: 4 CPUs; 4 parallel processes
Time: 21:27:00 - 21:55:26; 28m 26s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 51502179.7 | lps | 10.0 s | 7 | 116700.0 | 4413.2 |
Double-Precision Whetstone | 9321.4 | MWIPS | 10.1 s | 7 | 55.0 | 1694.8 |
Execl Throughput | 4630.4 | lps | 30.0 s | 2 | 43.0 | 1076.8 |
File Copy 1024 bufsize 2000 maxblocks | 282005.8 | KBps | 30.0 s | 2 | 3960.0 | 712.1 |
File Copy 256 bufsize 500 maxblocks | 73548.3 | KBps | 30.0 s | 2 | 1655.0 | 444.4 |
File Copy 4096 bufsize 8000 maxblocks | 791428.9 | KBps | 30.0 s | 2 | 5800.0 | 1364.5 |
Pipe Throughput | 1682919.4 | lps | 10.0 s | 7 | 12440.0 | 1352.8 |
Pipe-based Context Switching | 135096.3 | lps | 10.0 s | 7 | 4000.0 | 337.7 |
Process Creation | 7285.6 | lps | 30.0 s | 2 | 126.0 | 578.2 |
Shell Scripts (1 concurrent) | 8345.1 | lpm | 60.0 s | 2 | 42.4 | 1968.2 |
Shell Scripts (8 concurrent) | 1089.3 | lpm | 60.1 s | 2 | 6.0 | 1815.5 |
System Call Overhead | 1533638.3 | lps | 10.0 s | 7 | 15000.0 | 1022.4 |
System Benchmarks Index Score: | 1106.2 |
選手7:Linode 512 fremont 三男 / GNU/Linux on 日 9月 05 2010上に戻る
Test System Information
System: | 選手7:Linode 512 fremont 三男: GNU/Linux | |
OS: | GNU/Linux -- 2.6.32.16-linode28 -- #1 SMP Sun Jul 25 21:32:42 UTC 2010 | |
Machine: | i686: unknown | |
Language: | en_US.utf8 (charmap="UTF-8", collate="UTF-8") | |
CPUs: | 0: | Intel(R) Xeon(R) CPU L5520 @ 2.27GHz (4533.5 bogomips) Hyper-Threading, MMX, Physical Address Ext |
1: | Intel(R) Xeon(R) CPU L5520 @ 2.27GHz (4533.5 bogomips) Hyper-Threading, MMX, Physical Address Ext |
|
2: | Intel(R) Xeon(R) CPU L5520 @ 2.27GHz (4533.5 bogomips) Hyper-Threading, MMX, Physical Address Ext |
|
3: | Intel(R) Xeon(R) CPU L5520 @ 2.27GHz (4533.5 bogomips) Hyper-Threading, MMX, Physical Address Ext |
|
Uptime: | xxxxxxxxx |
Benchmark Run: 4 CPUs; 1 parallel process
Time: 21:00:16 - 21:28:12; 27m 56s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 14670559.9 | lps | 10.0 s | 7 | 116700.0 | 1257.1 |
Double-Precision Whetstone | 2149.3 | MWIPS | 9.8 s | 7 | 55.0 | 390.8 |
Execl Throughput | 1108.0 | lps | 29.9 s | 2 | 43.0 | 257.7 |
File Copy 1024 bufsize 2000 maxblocks | 293549.4 | KBps | 30.0 s | 2 | 3960.0 | 741.3 |
File Copy 256 bufsize 500 maxblocks | 76627.8 | KBps | 30.0 s | 2 | 1655.0 | 463.0 |
File Copy 4096 bufsize 8000 maxblocks | 740678.3 | KBps | 30.0 s | 2 | 5800.0 | 1277.0 |
Pipe Throughput | 415462.5 | lps | 10.0 s | 7 | 12440.0 | 334.0 |
Pipe-based Context Switching | 22441.1 | lps | 10.0 s | 7 | 4000.0 | 56.1 |
Process Creation | 1963.7 | lps | 30.0 s | 2 | 126.0 | 155.8 |
Shell Scripts (1 concurrent) | 2739.6 | lpm | 60.0 s | 2 | 42.4 | 646.1 |
Shell Scripts (8 concurrent) | 868.5 | lpm | 60.0 s | 2 | 6.0 | 1447.5 |
System Call Overhead | 424020.2 | lps | 10.0 s | 7 | 15000.0 | 282.7 |
System Benchmarks Index Score: | 432.5 |
Benchmark Run: 4 CPUs; 4 parallel processes
Time: 21:28:12 - 21:56:36; 28m 24s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 51832129.3 | lps | 10.0 s | 7 | 116700.0 | 4441.5 |
Double-Precision Whetstone | 7927.1 | MWIPS | 10.3 s | 7 | 55.0 | 1441.3 |
Execl Throughput | 4148.3 | lps | 30.0 s | 2 | 43.0 | 964.7 |
File Copy 1024 bufsize 2000 maxblocks | 290049.5 | KBps | 30.0 s | 2 | 3960.0 | 732.4 |
File Copy 256 bufsize 500 maxblocks | 75625.5 | KBps | 30.0 s | 2 | 1655.0 | 457.0 |
File Copy 4096 bufsize 8000 maxblocks | 957807.0 | KBps | 30.0 s | 2 | 5800.0 | 1651.4 |
Pipe Throughput | 1504306.9 | lps | 10.0 s | 7 | 12440.0 | 1209.2 |
Pipe-based Context Switching | 165229.2 | lps | 10.0 s | 7 | 4000.0 | 413.1 |
Process Creation | 6654.9 | lps | 30.0 s | 2 | 126.0 | 528.2 |
Shell Scripts (1 concurrent) | 7371.6 | lpm | 60.0 s | 2 | 42.4 | 1738.6 |
Shell Scripts (8 concurrent) | 960.0 | lpm | 60.1 s | 2 | 6.0 | 1600.0 |
System Call Overhead | 1456517.5 | lps | 10.0 s | 7 | 15000.0 | 971.0 |
System Benchmarks Index Score: | 1076.9 |
Benchmark of 選手8:さくらのVPS 980たん / GNU/Linux on Mon Sep 06 2010上に戻る
Test System Information
System: | 選手8:さくらのVPS 980たん: GNU/Linux | |
OS: | GNU/Linux -- 2.6.18-194.8.1.el5 -- #1 SMP Thu Jul 1 19:04:48 EDT 2010 | |
Machine: | x86_64: x86_64 | |
Language: | en_US.utf8 (charmap="UTF-8", collate="UTF-8") | |
CPUs: | 0: | Intel(R) Core(TM)2 Duo CPU T7700 @ 2.40GHz (5320.2 bogomips) x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET |
1: | Intel(R) Core(TM)2 Duo CPU T7700 @ 2.40GHz (5348.6 bogomips) x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET |
|
Uptime: | xxxxxxxxx |
Benchmark Run: 2 CPUs; 1 parallel process
Time: 00:35:21 - 01:03:06; 27m 45s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 9119937.4 | lps | 10.0 s | 7 | 116700.0 | 781.5 |
Double-Precision Whetstone | 2335.2 | MWIPS | 8.1 s | 7 | 55.0 | 424.6 |
Execl Throughput | 1102.9 | lps | 29.7 s | 2 | 43.0 | 256.5 |
File Copy 1024 bufsize 2000 maxblocks | 367732.0 | KBps | 30.0 s | 2 | 3960.0 | 928.6 |
File Copy 256 bufsize 500 maxblocks | 116640.4 | KBps | 30.0 s | 2 | 1655.0 | 704.8 |
File Copy 4096 bufsize 8000 maxblocks | 1038853.4 | KBps | 30.0 s | 2 | 5800.0 | 1791.1 |
Pipe Throughput | 1213946.8 | lps | 10.0 s | 7 | 12440.0 | 975.8 |
Pipe-based Context Switching | 27186.2 | lps | 10.0 s | 7 | 4000.0 | 68.0 |
Process Creation | 6273.2 | lps | 30.0 s | 2 | 126.0 | 497.9 |
Shell Scripts (1 concurrent) | 3099.7 | lpm | 60.0 s | 2 | 42.4 | 731.1 |
Shell Scripts (8 concurrent) | 695.4 | lpm | 60.0 s | 2 | 6.0 | 1158.9 |
System Call Overhead | 2205387.9 | lps | 10.0 s | 7 | 15000.0 | 1470.3 |
System Benchmarks Index Score: | 632.6 |
Benchmark Run: 2 CPUs; 2 parallel processes
Time: 01:03:06 - 01:30:51; 27m 45s
System Benchmarks
Test | Score | Unit | Time | Iters. | Baseline | Index |
---|---|---|---|---|---|---|
Dhrystone 2 using register variables | 13675892.5 | lps | 10.0 s | 7 | 116700.0 | 1171.9 |
Double-Precision Whetstone | 4443.0 | MWIPS | 8.0 s | 7 | 55.0 | 807.8 |
Execl Throughput | 4447.8 | lps | 30.0 s | 2 | 43.0 | 1034.4 |
File Copy 1024 bufsize 2000 maxblocks | 328808.6 | KBps | 30.0 s | 2 | 3960.0 | 830.3 |
File Copy 256 bufsize 500 maxblocks | 88841.8 | KBps | 30.0 s | 2 | 1655.0 | 536.8 |
File Copy 4096 bufsize 8000 maxblocks | 861454.7 | KBps | 30.0 s | 2 | 5800.0 | 1485.3 |
Pipe Throughput | 2594447.0 | lps | 10.0 s | 7 | 12440.0 | 2085.6 |
Pipe-based Context Switching | 531604.9 | lps | 10.0 s | 7 | 4000.0 | 1329.0 |
Process Creation | 12744.1 | lps | 30.0 s | 2 | 126.0 | 1011.4 |
Shell Scripts (1 concurrent) | 4586.9 | lpm | 60.0 s | 2 | 42.4 | 1081.8 |
Shell Scripts (8 concurrent) | 944.1 | lpm | 60.1 s | 2 | 6.0 | 1573.5 |
System Call Overhead | 4369902.5 | lps | 10.0 s | 7 | 15000.0 | 2913.3 |
System Benchmarks Index Score: | 1201.1 |
入力可能な文字数も残り少ないので今日はこのへんで。ではでは!
CodeIgniter上でデータベース利用方式でのSession使用時に、2度も3度も余計なsetcookie()を走らせないようにする。
皆様こんにちは。お久しぶりです。
今日は表題の小ネタ。(CodeIgniterの学習とは呼べないのでタイトルから外します。)
症状
以下のバグレポートの内容がCodeIgniter2.0の system/libraries/Session.phpでも直ってなさそうなので、俺俺修正コードを貼り付けておきます。参照:http://codeigniter.com/bug_tracker/bug/7358/
Description
When using session using a database every call to un/set_userdata results in a cookie being set. When using a DB the session cookie shouldn’t change when the userdata is changed. no need for another cookie being sent.
un/set_userdata calls sess_write which is where it sets the new cookie. simple fix would be to drop the $this->_set_cookie($cookie_userdata);
超俺訳:
データベース利用方式でセッションを使っているとき、
unset_userdataやset_userdataを毎回呼ぶ度に、クッキーへの書き込みが走ってるんだけど
そもそも保持したいデータはDBに入れてるのだから、unset_userdataやset_userdataしたタイミングでは
クッキー内容は何にも変わんねーよ。毎回クッキーに同じ値を書かなくてもいいじゃん。つかSet-Cookie:何回走らせてんだ。これバグだろ常考。
現状の動きを確認してみる
$config['sess_encrypt_cookie']= FALSE; で
クッキーの暗号化をしてなければ一発でわかる。
(ここでは3回setcookie()している。動かしたソースでset_userdataとかflash_dataが動いているため)
(写真赤丸内はSet-Cookie: csn=…ってなってるけど、$config['sess_cookie_name']のデフォルトだとSet-Cookie: ci_session=…)
$config['sess_encrypt_cookie']= TRUE; で
暗号化すると一見違うSet-Cookie:が走っているように見えるんだけど、
実はCI_Encryptのencodeを呼び出した時に呼ばれる_xor_encode()の中でmt_randが走っているからで復号した中身は一緒なのだ。
(確認は、$hoge=$this->CI->encrypt->decode($cookie_data); してmd5取ってvar_dump($hoge);してみれば良い。 )
修正ソース抜粋
いつもながら無保証です。
直前の$cookie_dataのmd5を保持しておいて、今回も同じだったら何もせず_set_cookie()を抜け出すって処理を入れてるだけ。
変更部分は、 //add start here 〜 //add end の間、他はオリジナルソースのSession.phpからコピーした。
あと、証拠の写真2記述のデバグ用に #$hoge=$this->CI->encrypt->decode($cookie_data); ってのをコメントアウトして入れている。
/application/libraries/MY_Session.php 内で_set_cookie()をオーバーライドする。
(MY_Session.phpが無ければ作るべし、MY_うんたらの説明はもう省略)
<?php if ( ! defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' ); class MY_Session extends CI_Session { function __construct () { parent :: __construct(); } //途中略(function _serialize()とかfunction _unserialize()とかのbugfix等々が間にある) // -------------------------------------------------------------------- /** * Write the session cookie * * @access public * @return void */ function _set_cookie($cookie_data = NULL) { if (is_null($cookie_data)) { $cookie_data = $this->userdata; } // Serialize the userdata for the cookie $cookie_data = $this->_serialize($cookie_data); //add start here //see:http://codeigniter.com/bug_tracker/bug/7358/ $cookie_md5 = md5($cookie_data); static $last_cookie_md5=''; if($last_cookie_md5 !== $cookie_md5){ $last_cookie_md5 = $cookie_md5; }else{ return; } //add end if ($this->sess_encrypt_cookie == TRUE) { $cookie_data = $this->CI->encrypt->encode($cookie_data); #debug #$hoge=$this->CI->encrypt->decode($cookie_data); #var_dump(md5($hoge)) ; } else { // if encryption is not used, we provide an md5 hash to prevent userside tampering $cookie_data = $cookie_data.md5($cookie_data.$this->encryption_key); } // Set the cookie setcookie( $this->sess_cookie_name, $cookie_data, $this->sess_expiration + time(), $this->cookie_path, $this->cookie_domain, 0 ); } //下略 }//endofclass /** * End of file MY_Session.php */ /** * Location: ./application/libraries/MY_Session.php */ ?>
修正後の動きを確認してみる
$config['sess_encrypt_cookie']= FALSE;のとき
$config['sess_encrypt_cookie']= TRUE;のとき
ってなかんじで、全く同一のSet-Cookie:重複が回避された。
ではでは!
Using Zend_Cache in CodeIgniter (Sample)
Sample Code (may be buggy)
Time line (about this code):
http://twitter.com/mataga/status/17738228243
http://twitter.com/mataga/status/17738331964
http://twitter.com/mataga/status/17738497243
http://twitter.com/mataga/status/17738815125
http://twitter.com/mataga/status/17739119936
<?php // Using Zend_Cache in CodeIgniter ( Sample ) // Version : 0.0.0.1 // see: http://framework.zend.com/manual/en/zend.cache.introduction.html // see: http://framework.zend.com/manual/ja/zend.cache.introduction.html class Lib_cache { private $_lifetime = 7200; //cache lifetime 2hours private $_automatic_serialization = true; //serialize data private $_cache_dir_name = 'data/cache/zendcache'; //cache dir (mkdir application/data/cache/zendcache) private $_default_tag_name_list = 'SYSTEM_CORE'; //Default Tag name for clean cache private $CI; private $_cache_use = false; private $_cache; private $_last_status = NULL; public function __construct( $params = array() ) { $this -> CI = &get_instance(); if ( $this -> CI -> config -> item( 'lib_cache_use' ) ) { # Put $config['lib_cache_use'] = true; on ./application/config.php // ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.BASEPATH.'application/my_classes/');//Change to the appropriate path require_once( 'Zend/Cache.php' ); $frontendOptions = ( isset( $params['frontendOptions'] ) )?$params['frontendOptions'] : array( 'lifetime' => $this -> _lifetime, 'automatic_serialization' => $this -> _automatic_serialization ); $backendOptions = ( isset( $params['backendOptions'] ) )?$params['backendOptions'] : array( 'cache_dir' => APPPATH . '/' . $this -> _cache_dir_name ); //application/data/cache/zendcache $this -> _cache = Zend_Cache :: factory( 'Core', 'File', $frontendOptions, $backendOptions ); $this -> _cache_use = true; } } // Get cache(load cache) public function get( $cache_id ) { return $this -> _cache_use ? $this -> _cache -> load( $cache_id ) : false ; } // Remove cache public function remove( $cache_id ) { if ( $this -> _cache_use ) { $this -> _last_status = $this -> _cache -> remove( $cache_id ) ; } } // Clean cache public function clean( $tag_name_list = NULL ) { if ( $this -> _cache_use ) { if ( is_null( $tag_name_list ) ) { $tag_name_list = $this -> _default_tag_name_list; } $tag_arr = explode( ',', $tag_name_list ); $this -> _last_status = $this -> _cache -> clean( Zend_Cache :: CLEANING_MODE_MATCHING_TAG , $tag_arr ); } } // Save cache public function save( $result, $cache_id , $tag_name_list = NULL ) { if ( $this -> _cache_use ) { if ( is_null( $tag_name_list ) ) { $tag_name_list = $this -> _default_tag_name_list; } $tag_arr = explode( ',', $tag_name_list ); $this -> _last_status = $this -> _cache -> save( $result, $cache_id , $tag_arr ); } } // Get last status public function get_last_status() { return $this -> _last_status; } }//endofclass /** #Example1 : Caching query result - in Some Class protected function load_table( $table_name, $fields = array() ) { $this -> load -> library( 'lib_cache' ); # Loading Lib_cache.php $this -> _set_table_name( $table_name ) ; if ( empty( $fields ) ) { $cache_id = 'base_model__load_table_' . md5( $table_name ); # Setting cache id if ( !$result = $this -> lib_cache -> get( $cache_id ) ) { # Getting cache data $result = $this -> db -> list_fields( $table_name ); $this -> lib_cache -> save( $result, $cache_id ); #Saving cache data } $this -> fields = $result; }else { $this -> fields = $fields ; } } */ /** * End of file Lib_cache.php */ /** * Location: ./application/libraries/Lib_cache.php */
(つぶやいてたら興味を持たれた方がいたので、取り急ぎアップ。作成時間1時間ちょっとなのでバグがあるかも。実験レベルです。画面ダンプ付きの詳しい説明は後日するかも)
VPSで遊ぶ -その5 Linode制御用のiphoneアプリを入れてみる。何処でもサーバ状況確認+再起動おk+鯖作成・DNS管理まで可能
こんにちは! 今日はVPSの小ネタ。
実験君環境などでお試し・安定性評価に使っていたLinode ( http://www.linode.com/ ) のVPSを
そろそろ本格的に台数を増やして使うことにしたので、公式iphoneアプリを入れてみた。
iphoneアプリの詳細は Linode Manager for iPhone - http://www.linode.com/iphone/ からどうぞ。
関連エントリー:
VPSで遊ぶ -その1 LinodeでVPS借りた。
VPSで遊ぶ -その2 もう一台Linodeで借りた。
VPSで遊ぶ -その3 Linodeのアトランタ(内陸部)とフレモント(西海岸)のping速度比較 - やっぱり西海岸は快適
VPSで遊ぶ -その4 Zend ServerをLinodeのVPS上に入れてCodeIgniterを動かしてみた。
VPSで遊ぶ -その6 LinodeとServersMan VPSとさくらのVPSとさくら専用鯖と自宅鯖との比較(秋のVPS&自宅鯖unixbench一人祭り結果 詳細)
VPSで遊ぶ -その7 LinodeとServersMan VPSとさくらのVPSの転送速度の簡易テスト結果
画面ダンプをぺたぺた貼ってみる
1)起動アイコン
アイコンはかっこいい。ちなみに左側のTouchTerm Proのssh経由で、緊急時にウチの鯖達を弄れるようにしているが、幸い必要になる機会は少ない。
2)ログイン画面
アカウントのID/PASSを入れてぽちっとな
3)鯖一覧
配下のVPS鯖がここにずらっと並ぶ事になる。評価中なのでまだ2台。
赤丸部分をクリックすると4)の画面へ
4)サーバの状況確認画面
各サーバの状況などがこの画面で確認・操作できる。
- オレンジ丸部分をクリックすると5)の再起動画面へ
- 青丸部分をクリックすると6)の稼動状況グラフ画面へ
5)サーバ再起動画面
再起動とシャットダウンがここでぽちっとな出来る。なんていうかこう素晴らしい。
スマートフォンを活用して仕事している気分。
4)の画面を下にスクロールしたところ。
この先は触っていないので想像で(迂闊に触ると鯖が初期化される罠w。root向けツールなので要注意)
- 紫丸をクリックすると8)のプロフィール管理画面へ
- 緑丸をクリックすると9)の新規プロフィール追加画面へ
- 黄丸をクリックすると10)のディスクイメージ確認・編集・削除画面へ
- 青丸をクリックすると11)のディスクイメージ新規作成画面へ
- 赤丸をクリックすると12)の別ディストリビューションをデプロイ(利用可能に)する画面へ
8)プロフィール管理画面
メモリの設定・新規作成したディスクの割り当て等出来るっぽいが、調べずに迂闊に触るのは怖いので眺めるだけ。
常に「ポチッとなは怖い」という感覚をもっておきませう。
9)新規プロフィール追加画面
要はプロフィールを複数作成して、鯖を色んな状態で稼動させることができるってわけね。
10)ディスクイメージ確認・編集・削除画面
Read Onlyに変えたり、ディスクサイズを変更したり、ディスクイメージを丸ごと削除出来たりと何でもアリですなしかし。
11)ディスクイメージ新規作成画面
こっちはディスクイメージの作成。
12)別ディストリビューションをデプロイ(利用可能に)する画面
32bitと64bitのOSがこれだけ選べる。
余っている未使用領域を使って別ディストリビューションが一発で作れちゃうっぽい。
画面ダンプのこの環境だと4)の画面のStorage部分の通り、残り4GB分余っているので、ディスクサイズを調整すると別OSとのデュアルブート・トリプルブート等が出来るように仕込めるってわけですね。
ていうかあれですな、iphoneだけで鯖作成が出来ちゃうなこれ。
13)IPアドレス確認、ホストのジョブ状況確認画面
4)7)の画面をさらに下にスクロールしたところ。
IPアドレスや、鯖側のJobの確認(再起動などの結果確認)ができる。
(この環境ではグローバルIPアドレスは月1ドル追加して2つにしている。)
ピンク色のJobは失敗しているところ。
ピンク色をクリックすると14)の詳細画面へ
14)IPアドレス確認、ホストのジョブ状況確認画面
ブートに失敗してるログの例、iphoneアプリで鯖再起動をかけてもこの様に確認できるわけですねGJ。
SSHで入れなくても、LISHでコンソールまで辿り着ける状態ならば、TouchTerm経由でなんとかなる事もあるかと。
iphoneだけでそこまでやるのは指的に苦しいが。
15)DNSマネージャ(DNS管理画面)
LinodeのDNSは使ってない(別の所を使っている)ので画面ダンプのみ。
ここでDNSの管理が出来るっぽい。
16)このiphoneアプリのabout画面
上記の通りAPI経由でこんだけ操作出来るのね。Linodeスゲー。
感想
転ばぬ先の安心感というか、「システム屋がスマートフォンを活用したいのってこういうことなんですよ」というのを実現しているのがスゲー。システム屋じゃないけど。国内のVPSサーバ屋さんもマジで頑張ってください。付け焼き刃の企画では追いつけませんぜ。
というわけで、弊社の鯖代のお金は今後国外に流れるのでした。微々たるものだけど。
アフィリリンク貼っておきます。
もし万が一収入があったら全額赤い羽根にでも寄付して国内にカネを還元するよ。そのときは画面ダンプ貼る。
Linode のアドレス:http://www.linode.com
ではでは!