NoSQL-high concurrency under Apache+mongodb php driver instability

Source: Internet
Author: User
Tags findone php error dedicated server

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

    1. You use -n 100 , this number is too small, usually set in more than thousand
    2. 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-...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.