CodeIgniter+MySQL/PostgreSQL ABテスト 2007-11-10 23:41:01
技術情報
web2 から web1 へ ab でアクセス
Apacheチューニングなし
MySQLレプリケーション、その他チューニングなし
[root@web2~]# ab -n 100 -c 1 http://10.0.0.2/CodeIgniter154/?/blog/
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 10.0.0.2 (be patient).....done
Server Software: Apache/2.2.3
Server Hostname: 10.0.0.2
Server Port: 80
Document Path: /CodeIgniter154/?/blog/
Document Length: 910 bytes
Concurrency Level: 1
Time taken for tests: 0.742100 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 110200 bytes
HTML transferred: 91000 bytes
Requests per second: 134.75 [#/sec] (mean)
Time per request: 7.421 [ms] (mean)
Time per request: 7.421 [ms] (mean, across all concurrent requests)
Transfer rate: 144.19 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 6 6 1.0 7 9
Waiting: 5 5 1.0 6 8
Total: 6 6 1.0 7 9
Percentage of the requests served within a certain time (ms)
50% 7
66% 7
75% 7
80% 7
90% 7
95% 7
98% 7
99% 9
100% 9 (longest request)
web2 から web1 へ ab でアクセス
Apacheチューニングなし
PostgreSQL(pgpool)、その他チューニングなし
[root@web2~]# ab -n 100 -c 1 http://10.0.0.2/CodeIgniter154/?/blog/
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 10.0.0.2 (be patient).....done
Server Software: Apache/2.2.3
Server Hostname: 10.0.0.2
Server Port: 80
Document Path: /CodeIgniter154/?/blog/
Document Length: 278 bytes
Concurrency Level: 1
Time taken for tests: 0.672888 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 47000 bytes
HTML transferred: 27800 bytes
Requests per second: 148.61 [#/sec] (mean)
Time per request: 6.729 [ms] (mean)
Time per request: 6.729 [ms] (mean, across all concurrent requests)
Transfer rate: 66.88 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 5 5 1.0 6 7
Waiting: 5 5 0.1 5 6
Total: 5 5 1.0 6 7
Percentage of the requests served within a certain time (ms)
50% 6
66% 6
75% 6
80% 6
90% 6
95% 6
98% 6
99% 7
100% 7 (longest request)
若干PostgreSQLの方が速いようですが、データベースを酷使するようなデータを含んでいないため、あまり参考にはならないでしょう。
参考データ
MyNETS(ソーシャルネットワーキングソフトウェア)
http://usagi.mynets.jp/
同じサーバーにインストールし、MySQLを使用しました。
Server Software: Apache/2.2.3
Server Hostname: 10.0.0.2
Server Port: 80
Document Path: /mynets111/
Document Length: 11308 bytes
Concurrency Level: 1
Time taken for tests: 9.794924 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1167700 bytes
HTML transferred: 1130800 bytes
Requests per second: 10.21 [#/sec] (mean)
Time per request: 97.949 [ms] (mean)
Time per request: 97.949 [ms] (mean, across all concurrent requests)
Transfer rate: 116.39 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 1
Processing: 96 97 0.8 97 101
Waiting: 90 91 0.8 91 95
Total: 96 97 0.8 97 101
Percentage of the requests served within a certain time (ms)
50% 97
66% 97
75% 98
80% 98
90% 98
95% 98
98% 100
99% 101
100% 101 (longest request)
負荷分散プロキシ+CodeIgniterの実験会続(PostgreSQL) 2007-11-10 23:17:30
技術情報
Poundによるロードバランサーを軸にした、webサーバー×2台、DBサーバー×2台の構成。
データベースはPostgreSQLによるレプリケーション(pgpool)構成です。
postgres -V
postgres (PostgreSQL) 8.1.9
CodeIgniterを書き込み及び読み込みのデータベースレプリケーションに対応させました。
CodeIgniter_1.5.4/system/application/config/database.php
[php]
$active_group = "default";
$db['default']['hostname'] = "10.1.1.4";
$db['default']['username'] = "username";
$db['default']['password'] = "password";
$db['default']['database'] = "codeigniter";
$db['default']['dbdriver'] = "postgre";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['write']['hostname'] = "10.1.1.3";
$db['write']['username'] = "username";
$db['write']['password'] = "password";
$db['write']['database'] = "codeigniter";
$db['write']['dbdriver'] = "postgre";
$db['write']['dbprefix'] = "";
$db['write']['active_r'] = TRUE;
$db['write']['pconnect'] = TRUE;
$db['write']['db_debug'] = TRUE;
$db['write']['cache_on'] = FALSE;
$db['write']['cachedir'] = "";
[/php]
write配列の設定を追加しています。
書き込みと読み込みはblogのサンプルプログラムを使用しました。
CodeIgniter_1.5.4/system/application/controllers/blog.php
[php]
load->helper('url');
$this->load->helper('form');
$this->load->database();
$this->load->scaffolding('entries');
}
function index()
{
$data['title'] = "My Blog Title";
$data['heading'] = "My Blog Heading";
$data['query'] = $this->db->get('entries');
$this->load->view('blog_view', $data);
}
function comments()
{
$data['title'] = "My Comments Title";
$data['heading'] = "My Comments Heading";
$this->db->where('entry_id', $this->uri->segment(3));
$data['query'] = $this->db->get('comments');
$this->load->view('comment_view', $data);
}
function comment_insert()
{
$this->load->database(write);
$this->db->insert('comments', $_POST);
redirect('blog/comments/'.$_POST['entry_id']);
}
}
?>
[/php]
書き込み(insert)にて、書き込みデータベースをロードしている箇所にご注目ください。
おまけ
PostgreSQL用のインサートデータです。
[sql]
CREATE TABLE entries (
id serial NOT NULL,
title text default NULL,
body text NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE comments (
id serial NOT NULL,
entry_id int4 NOT NULL,
body text NOT NULL,
author text NOT NULL,
PRIMARY KEY (id)
);
[/sql]
負荷分散プロキシ+CodeIgniterの実験会続(MySQL) 2007-11-10 22:51:05
技術情報
Poundによるロードバランサーを軸にした、webサーバー×2台、DBサーバー×2台の構成。
データベースはMySQLによるレプリケーション構成です。
mysql -V
mysql Ver 14.14 Distrib 5.1.22-rc, for redhat-linux-gnu (x86_64) using readline 5.0
CodeIgniterを書き込み及び読み込みのデータベースレプリケーションに対応させました。
CodeIgniter_1.5.4/system/application/config/database.php
[php]
$active_group = "default";
$db['default']['hostname'] = "10.1.1.4";
$db['default']['username'] = "username";
$db['default']['password'] = "password";
$db['default']['database'] = "codeigniter";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['write']['hostname'] = "10.1.1.3";
$db['write']['username'] = "username";
$db['write']['password'] = "password";
$db['write']['database'] = "codeigniter";
$db['write']['dbdriver'] = "mysql";
$db['write']['dbprefix'] = "";
$db['write']['active_r'] = TRUE;
$db['write']['pconnect'] = TRUE;
$db['write']['db_debug'] = TRUE;
$db['write']['cache_on'] = FALSE;
$db['write']['cachedir'] = "";
[/php]
write配列の設定を追加しています。
書き込みと読み込みはblogのサンプルプログラムを使用しました。
CodeIgniter_1.5.4/system/application/controllers/blog.php
[php]
load->helper('url');
$this->load->helper('form');
$this->load->database();
$this->load->scaffolding('entries');
}
function index()
{
$data['title'] = "My Blog Title";
$data['heading'] = "My Blog Heading";
$data['query'] = $this->db->get('entries');
$this->load->view('blog_view', $data);
}
function comments()
{
$data['title'] = "My Comments Title";
$data['heading'] = "My Comments Heading";
$this->db->where('entry_id', $this->uri->segment(3));
$data['query'] = $this->db->get('comments');
$this->load->view('comment_view', $data);
}
function comment_insert()
{
$this->load->database(write);
$this->db->insert('comments', $_POST);
redirect('blog/comments/'.$_POST['entry_id']);
}
}
?>
[/php]
書き込み(insert)にて、書き込みデータベースをロードしている箇所にご注目ください。
sourceforge.jpに承認されました 2007-10-09 21:10:21
お知らせ
sourceforge.jpにて当サイトの成果物が管理できるようになります。
http://sourceforge.jp/projects/codeigniter/
CodeIgniter日本語版
Rapyd Library日本語版
などのリリースを予定しています。
将来的にはSVNによるリソース管理を行いたいと考えております。
日本CodeIgniterユーザ会について 2007-09-16 04:04:07
お知らせ
日本CodeIgniterユーザ会は、国内におけるCodeIgniterユーザ間の交流、そしてコミュニティ形成を目指す、非営利かつ任意の団体です。
(注、任意団体は届出が不必要なものを指す)
日本CodeIgniterユーザ会の主な活動内容は、掲示板やメーリングリストによる情報交換、ユーザ会Webサイト運営を中心とするCodeIgniter利用促進のための啓蒙活動、CodeIgniter勉強会の主催などです。
日本CodeIgniterユーザ会は、CodeIgniterに興味を持ち、そしてCodeIgniterのより一層の活用を望む方であれば、スキルレベルの上下を問わず、どなたでも自由に参加することが可能です。日本CodeIgniterユーザ会への登録は、メーリングリストへの参加によって完了しす。もちろん、参加は無料ですので、お気軽に加入ください。
