Posts tagged Apache
YMC vs CPI
1月 7th
VPSのbenchmark。 目的:ネットワーク帯域など、クライアントから見たHTTPのレスポンス性をチェックする。
測定環境 apache上げて単純なHTMLファイルの転送。
ファイルの内容:
<html><body><h1>It works!</h1></body></html>
apache benchのオプション:
% /usr/local/apache2/bin/ab -n 1000 -c 2
Requests per second: 34.84 [#/sec] (mean)
Requests per second: 163.67 [#/sec] (mean)
結果 4.7倍 CPIが高速!
VPSのHTTP速度
10月 19th
jpgファイル: 145.19 KB % /usr/local/apache2/bin/ab -n 100 接続元:Fiberbit
測定結果平均リクエスト完了時間 @YMC: 259ms CloudFront: 48ms CPI: 141ms
YMC VPSベンチマーク
9月 8th
YMCのVPSを使っています。 しかしながら、ページ表示速度が遅いのでまず静的HTMLでベンチマーク取ってみました。 利用しているサービスはカスタム10。
測定環境- 回線:100Mbps 光ファイバ(goo スピードテストで66.37Mbps)
- ルータ経由数:21
以下、測定結果。 重要なポイントだけ引用。
% date
Tue Sep 8 01:54:15 JST 2009
% /usr/local/apache2/bin/ab -n 100
Server Software: Apache/2.2.11
Document Length: 18661 bytes
Concurrency Level: 1
Time taken for tests: 11.174 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1896400 bytes
HTML transferred: 1866100 bytes
Requests per second: 8.95 [#/sec] (mean)
Time per request: 111.743 [ms] (mean)
Time per request: 111.743 [ms] (mean, across all concurrent requests)
Transfer rate: 165.73 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 23 24 0.5 24 26
Processing: 73 87 51.1 76 350
Waiting: 23 25 More > PHP 5.2.10 configure error
6月 20th
PHP5.2.10が出たので開発環境へインストール。
5.2.8と同じオプションでconfigureしたのにこんなエラーが出た。
% ./configure --enable-mbstring --enable-soap --enable-zend-multibyte --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-curl --with-curlwrappers --with-gd --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-zlib-dir=/usr/lib --with-mcrypt
.....
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl -dir>/include/curl/
環境は、
# cat /etc/issue Debian GNU/Linux 5.0 \n \l
headerファイルインストールして解決
# aptitude install libcurl4-gnutls-dev
apacheのKeepAliveTimeout
6月 13th
mixiでは以下の値らしい。
KeepAlive On KeepAliveTimeout 1 MaxKeepAliveRequest 20
思ったこと: KeepAliveTimeoutは1でいいんだ。
PHPでQRCode
3月 7th
PHPでQRコードを作る方法。 Extensionを使う。
インストール
wget http://www.opendogs.org/pub/php_qr-0.3.1.tgz tar zxvf php_qr-0.3.1.tgz cd php_qr-0.3.1 phpize ./configure --enable-qr make install /usr/local/apache2/bin/apachectl graceful
PHPコード
< ?php
$qr = new QRCode();
$qr->setMagnify(3);
$qr->setFormat(QRCode::FMT_GIF);
$qr-addData($data);
$qr->finalize();
header('Content-type: image/gif');
print $qr->getSymbol();
上記以外にもオプションがいっぱい用意されている。 APIリファレンスが見づらいなぁ。
携帯ページで使うapacheのリダイレクト
12月 1st
携帯では、temporary moved(302)を返すべき!
moved permanent (301)を返すと、DoCoMoで警告がでちゃいます。auでは出ないことを確認しました。
警告を出さないようにするためには、Found(302)を返します。RedirectディレクティブのデフォルトがFoundなので、以下のように書けば問題ないです。
Redirect /service http://foo2.bar.com/service
以下でも同義
Redirect temp /service http://foo2.bar.com/service
mod_rewriteだと以下のように
RewriteRule ^/service/(.*) http://foo2.bar.com/service/$1 [R=302,L]
複数台で運用しているサーバのアクセスログを1つに統合する
11月 30th
複数台のフロントエンドサーバでapacheが動いている場合を想定します。
その場合、アクセスログが複数のサーバにまたがってしまいます。
こんなかんじ。
- web-01.access-log.20071130
- web-02.access-log.20071130
- web-03.access-log.20071130
webalizerやawstatsといったアクセスログ解析ソフトではこのファイルの状態では解析できない。
なぜなら、webalizerやawstatsのデフォルトでは1つのファイルのみを入力として受け付け、時系列順に記録されていなければならない。
この問題を解決するスクリプトを発見しました。awstatsの中に入っているlogresolvemerge.plというperlスクリプトです。
使い方は超簡単。引数に統合したいファイルを指定して実行すると、標準出力に時系列順にそろったレコードが出力される。
例:
% perl logresolvemerge.pl /path/to/log/*access.log.20071130|more
引数にgz圧縮されたファイルを指定してもちゃんと動きます。至れり尽くせりなスクリプト。
★おまけ情報★ ある日まで、commonフォーマットでアクセスログを取っていて、ある時点からcombinedフォーマットでログを取りだした場合、1つのアクセスログの中に2種類のフォーマットのログが混入してしまう。
そこで見つけたのがこの方法。commonフォーマットをcombinedフォーマットにする方法。 http://www.trisweb.com/archives/2007/02/15/convert-apache-common-logs-to-combined-logs/
3回シェルのコマンドを実行すればできちゃう!CUIはすばらしい。
参照:
最近のコメント