Uploaded image for project: 'PHP Legacy Driver'
  1. PHP Legacy Driver
  2. PHP-347

MongoPool not working as expected when using php-fpm / cgi - a pool seems to be created per each child process

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 1.2.7
    • Fix Version/s: 1.3.0RC1
    • Component/s: pecl-mongo
    • Labels:
      None
    • Environment:
      php 5.3.10, using php-fpm with apc, suhosin extensions on Ubuntu 10.04
    • # Replies:
      1
    • Last comment by Customer:
      true

      Description

      While trying to predictably reproduce problems similar to issue PHP-202 I came across this:

      MongoPool::info() reports only 1-2 used connections:

      [192.168.100.52:27017....5164] => Array
      (
      [in use] => 2
      [in pool] => 0
      [remaining] => 148
      [total] => 150
      [timeout] => 5000
      [waiting] => 0
      )

      [192.168.100.35:27017....5164] => Array
      (
      [in use] => 1
      [in pool] => 1
      [remaining] => 148
      [total] => 150
      [timeout] => 5000
      [waiting] => 0
      )

      [192.168.100.19:27017....5164] => Array
      (
      [in use] => 1
      [in pool] => 1
      [remaining] => 148
      [total] => 150
      [timeout] => 5000
      [waiting] => 0
      )

      [192.168.100.39:27017....5164] => Array
      (
      [in use] => 0
      [in pool] => 1
      [remaining] => 149
      [total] => 150
      [timeout] => 2000
      [waiting] => 0
      )

      while on the actual server running php I see a lot more open connections (which shouldn't be happening in the first place):

      > netstat -na | grep 27017 | grep ESTABL | awk '

      {print $5}

      ' | sort | uniq -c

      294 192.168.100.19:27017
      105 192.168.100.35:27017
      50 192.168.100.39:27017
      101 192.168.100.52:27017

      > netstat -na | grep 27017 | tail

      tcp 0 0 192.168.100.21:35765 192.168.100.19:27017 ESTABLISHED
      tcp 0 0 192.168.100.21:36798 192.168.100.19:27017 ESTABLISHED
      tcp 0 0 192.168.100.21:36642 192.168.100.19:27017 ESTABLISHED
      tcp 0 0 192.168.100.21:35884 192.168.100.19:27017 ESTABLISHED
      tcp 0 0 192.168.100.21:32908 192.168.100.52:27017 ESTABLISHED
      tcp 0 0 192.168.100.21:52508 192.168.100.35:27017 ESTABLISHED
      tcp 0 0 192.168.100.21:54889 192.168.100.35:27017 ESTABLISHED
      tcp 0 0 192.168.100.21:36541 192.168.100.19:27017 ESTABLISHED
      tcp 0 0 192.168.100.21:40160 192.168.100.39:27017 ESTABLISHED

      As you can see from PHP output, we have limited the connection count in the pool to 150, but according to MongoPool::info() only 1-2 seem to be used. Since we are running 50 php-fpm instances my only explanation is that the pool is limited per child process. Which would make it quite ineffective - the actual limit would be 7500 cons. Or that is how it is supposed to work? Also the actual connection count reported by netstat would mean that some child's should have more than a few connections, but I ran MongoPool::info() many, many times and did not hit a child with more than 1 to .100.19 (which has most conns according to netstat). It could be bad luck though.

      Or have I misunderstood completely how MongoPool works and the situation described above is expected? Would using a 5 connection limit in MongoPool be reasonable?

        Attachments

          Activity

            People

            Assignee:
            derick Derick Rethans
            Reporter:
            edmnc Edmunds Kalnins
            Participants:
            Last commenter:
            Rathi Gnanasekaran
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since reply:
              7 years, 46 weeks, 2 days ago
              Date of 1st Reply: