- 論壇徽章:
- 0
|
OpenBSD4.2 + mysql-server-5.0.45
OpenBSD4.4 + mysql-server-5.0.51a
pkg_add 直接安裝的 mysql-server-5.0.45 mysql-server-5.0.51a
在以下程序測試中,跑出來的效果很出人意料,在實際應用上,以每一秒鐘為單位,鏈接數(shù)據(jù)庫,也有不少這樣的錯誤:
- [Wed Dec 3 14:52:46 2008] [error] PHP Warning: mysql_connect() [<a href='funct
- ion.mysql-connect'>function.mysql-connect</a>]: Can't connect to MySQL server on
- '127.0.0.1' (61) in /vhost/www.abc.com/init.php on line 23
復制代碼
程序1:
- <?php
- /*
- // [url]http://bugs.mysql.com/bug.php?id=23443[/url]
- // [url]http://bugs.mysql.com/file.php?id=4673&text=1[/url]
- $link=mysqli_connect("127.0.0.1","root","") or die("can't connect");
- mysqli_select_db($link,"test") or die(mysqli_error($link));
- mysqli_query($link,"drop table if exists oom") or die(mysqli_error($link));
- mysqli_query($link,"create table oom(id int)") or die(mysqli_error($link));
- mysqli_query($link,"insert into oom(id) values (1),(2),(3),(4),(5)") or die(mysqli_error($link));
- for($i=0;$i<100000;$i++)
- {
- mysqli_query($link,"set @var".$i."=repeat('a',100000)") or print('1 - ' . mysqli_error($link) . "\n");
- mysqli_query($link,"select * from oom group by id") or print('2 - ' . mysqli_error($link) . "\n");
- }
- mysqli_close($link);
- */
- $link = mysql_connect('127.0.0.1', 'root', '') or die('111');
- mysql_select_db('test', $link) or die(mysql_error($link));
- mysql_query("drop table if exists oom", $link) or die(mysql_error($link));
- mysql_query("create table oom(id int)", $link) or die(mysql_error($link));
- mysql_query("insert into oom(id) values (1),(2),(3),(4),(5)", $link) or die(mysql_error($link));
- for ($i = 0; $i < 100000; $i++) {
- echo $i." => ";
- mysql_query("set @var".$i."=repeat('a',100000)", $link) or print('1 - ' . mysql_error($link) . "\n");
- mysql_query("select * from oom group by id", $link) or print('2 - ' . mysql_error($link) . "\n");
- }
- mysql_close($link);
- ?>
- 出錯信息:
- 43 => 10044 => 10045 => 10046 => 10047 => 10048 => 10049 => 10050 => 10051 => 10052 => 10053 => 10054 => 10055 => 2 - Out of memory (Needed 256008 bytes)
- 10056 => 2 - Out of memory (Needed 256008 bytes)
- 10057 => 2 - Out of memory (Needed 256008 bytes)
復制代碼
程序2:
- <?php
- for ($i = 0; $i < 100000; $i++) {
- $link = mysql_connect('127.0.0.1', 'root', '', true);
- echo "$i => ";
- var_dump($link);
- }
- ?>
- 出錯信息:
- 3127 => resource(3059) of type (mysql link)
- 3128 => resource(3060) of type (mysql link)
- 3129 => resource(3061) of type (mysql link)
- 3130 => resource(3062) of type (mysql link)
- 3131 => resource(3063) of type (mysql link)
- 3132 => resource(3064) of type (mysql link)
- 3133 => resource(3065) of type (mysql link)
- PHP Warning: mysql_connect(): Can't connect to MySQL server on '127.0.0.1' (65) in /home/test.php on line 4
復制代碼
程序3:
- use DBI;
- $dsn = "DBI:mysql:database=test;host=127.0.0.1;port=3306";
- for ($i = 0; $i < 5000; $i++) {
- $dbh = DBI->connect($dsn, 'root', '');
- if (!$dbh) { exit 1; }
- print $i, ' ', $dbh, "\n";
- }
- 出錯信息:
- 25 DBI::db=HASH(0x877f9240)
- 226 DBI::db=HASH(0x877f9a8c)
- 227 DBI::db=HASH(0x877f993c)
- 228 DBI::db=HASH(0x877f9e88)
- 229 DBI::db=HASH(0x877f927c)
- 230 DBI::db=HASH(0x877f94b0)
- 231 DBI::db=HASH(0x877f9084)
- 232 DBI::db=HASH(0x877f9bb8)
- 233 DBI::db=HASH(0x877f9b34)
- 234 DBI::db=HASH(0x877f9dc8)
- 235 DBI::db=HASH(0x863f915c)
- DBI connect('database=test;host=127.0.0.1;port=3306','root',...) failed: Can't connect to MySQL server on '127.0.0.1' (65) at 2.pl line 4
復制代碼
以上幾個程序在同樣的硬件配置中,freebsd ,linux 跑出來的結(jié)果是以上結(jié)果的十倍以上
是不是OpenBSD系統(tǒng)里面限制了什么????
http://www.openbsdonly.org/viewtopic.php?f=17&t=640
大家有沒有新的提意,提示什么的???
[ 本帖最后由 cnduly 于 2008-12-3 18:26 編輯 ] |
|