My environment: apache/2.2.21 (WIN32) php/5.4.3
Test code:
Selectdb ("NPM")->selectcollection ("User"), $user = $c->findone (' userName ' = ' admin ', ' passWord ' = ' admin '); if ($user) {echo var_dump ($user);} echo Var_dump ($db);? >
Use the Apache Concurrency Test tool ab.exe test, test the command as follows
D:\apache2.2\bin>ab.exe-n http://192.168.15.21/a.php
Test results:
Concurrency level: 1Time taken for tests: 0.266 secondscomplete requests: 100Failed requests: (connect:0, receive:0, length:58, exceptions:0) Write errors: 0Total transferred: 888192 byteshtml transferred: 870668 bytesrequests per second: 376.47 [#/sec] (mean) time per request: 2.656 [MS] (mean) time per request: 2.656 [MS] (mean, across all concurrent Requests) Transfer rate: 3265.41 [Kbytes/sec] Received
PHP error message:
[13-jun-2012 07:40:26 UTC] PHP Notice: unknown:localhost:27017:pool Done (0x3877a10) in Unknown on line 0
Reply content:
My environment: apache/2.2.21 (WIN32) php/5.4.3
Test code:
Selectdb ("NPM")->selectcollection ("User"), $user = $c->findone (' userName ' = ' admin ', ' passWord ' = ' admin '); if ($user) {echo var_dump ($user);} echo Var_dump ($db);? >
Use the Apache Concurrency Test tool ab.exe test, test the command as follows
D:\apache2.2\bin>ab.exe-n http://192.168.15.21/a.php
Test results:
Concurrency level: 1Time taken for tests: 0.266 secondscomplete requests: 100Failed requests: (connect:0, receive:0, length:58, exceptions:0) Write errors: 0Total transferred: 888192 byteshtml transferred: 870668 bytesrequests per second: 376.47 [#/sec] (mean) time per request: 2.656 [MS] (mean) time per request: 2.656 [MS] (mean, across all concurrent Requests) Transfer rate: 3265.41 [Kbytes/sec] Received
PHP error message:
[13-jun-2012 07:40:26 UTC] PHP Notice: unknown:localhost:27017:pool Done (0x3877a10) in Unknown on line 0
First, it is recommended that you set the pool size of PHP MONGO before you initialize the Mongo
object
Mongopool::setsize (100);
This improves the connection efficiency of the MONGO, especially in the case of large concurrency. In addition, your AB command is used incorrectly
- You use
-n 100
, this number is too small, usually set in more than thousand
- You do not use
-c
parameters to set the number of concurrency, resulting in AB is based on the total limit to pressure concurrency, so it is not scientific
You should use
Ab.exe-n 1000-c http://192.168.15.21/a.php
This is done with 1000 requests in 100 concurrent. You can adjust these two parameters according to your own situation.
Finally, there are sometimes errors, not instability, each server has its limits, such as you now use Windows XP to test the performance of the server, its hardware, as well as the degree of software optimization (such as the number of semi-open connections), will greatly affect the final performance.
If you want to scientifically test server performance, it is recommended to use a dedicated server and choose a standard optimized Linux operating system.
Try the lastest version of MONGO PHP driver
Check this out:
https://github.com/mongodb/mongo-php-...