March 2008

March 15, 2008

replicate by pgpool

>> 構成
pgpool - 192.168.0.50
master - 192.168.0.11
secondary - 192.168.0.16
$ vi /usr/local/pgpool/etc/pgpool.conf
listen_address = '192.168.0.50'
port = 5433

backend_host_name = '192.168.0.11'
backend_port = 5432

secondary_backend_host_name = '192.168.0.16'
secondary_backend_port = 5432

replication_mode  = true
load_balance_mode = true
>> ベンチマーク
プライマリキーで取得するSELECTを3回発行するプログラム。
プライマリキーは1〜100000の中からランダムに生成。
データは10万件。
$ ab -n 500 -c 100 -k http://www.example.com/testapp
[ 単一サーバ(192.168.0.11) ]
Requests per second:    247.18 [#/sec]
Time per request:       4.046 [ms]

Requests per second:    273.41 [#/sec]
Time per request:       3.658 [ms]

Requests per second:    269.48 [#/sec]
Time per request:       3.711 [ms]
[ load barancing & connection pooling ]
Requests per second:    261.33 [#/sec]
Time per request:       3.827 [ms]

Requests per second:    261.51 [#/sec]
Time per request:       3.824 [ms]

Requests per second:    256.63 [#/sec]
Time per request:       3.897 [ms]
後者の方が気持ち速いが、ほとんど変わらず。コネクションプーリングによるパフォーマンス向上がバランサ(というかpgpool自体)のオーバーヘッドで相殺されている感じ。
パフォーマンスが変わらずフェイルオーバーできるというのは結構良いかもしれない。

March 13, 2008

postgresql logging

PostgreSQLでログ(クエリログ)を採る方法。

PostgreSQL 8.3.0

"log_statement"を有効にする。
$ vi /usr/local/pgsql/data/postgres.conf

log_statement = 'all'
ログディレクトリを作成。
$ mkdir /usr/local/pgsql/logs
起動時にログファイルを指定する。
$ cd /usr/local/pgsql
$ ./bin/pg_ctl -o -i -D ./data -l logs/pglog.log start &


March 12, 2008

html specification

要素の属性値に"<"や">"は使用可能なのか。
HTMLの仕様を覗いてみると、次のような記述が見つかった。
Authors wishing to put the "<" character in text should use 
"&lt;" (ASCII decimal 60) to avoid possible confusion with 
the beginning of a tag (start tag open delimiter). 
Similarly, authors should use "&gt;" (ASCII decimal 62) in 
text instead of ">" to avoid problems with older user agents 
that incorrectly perceive this as the end of a tag (tag close 
delimiter) when it appears in quoted attribute values.
"&lt;"や"&gt;"を使用すべきといってるものの、"<"や">"は使用できないと言ってるわけではなさそうだ。

でもこのバリデーションにはこける。
http://validator.w3.org/

"should"ではなく"must"なのだろうか。

March 10, 2008

ActiveRecord

なんか最近、ActiveRecordってなんだかなぁと思う日々。

たまに出くわすのが、「せっかくActiveRecordを使っているからSQLを発行するのはなんか嫌」というもの。ちょっとしたサブクエリ投げれば済むものを、テーブル設計をそれ用に変更したり、難解なAPIで頑張ったり。

DAOがあるなら、特にSELECTに関しては、全部SQL(できればHQLのようなもの)で書いてもいいんじゃないかと思う今日この頃。


Sabel

Sabel PHP Frameworkを開発しています。
http://www.sabel.jp/

Search
Categories
Tags
Recent Articles
Archives