Persistent Connections seemingly not working using PHP driver

290 views
Skip to first unread message

Harry B

unread,
Nov 1, 2010, 6:32:23 PM11/1/10
to mongodb-user
I'm using 1.0.10 php driver.

I'm connecting with:

$this->conn = new Mongo("{$host}", array( 'persist' => $database .
rand(1,100) ) );

On the mongo database server if I do db.serverStatus(); then I've seen
current connections go up into 200's

Why aren't the connections limited to the total number of
possibilities for my persistent connection string?

Also, what is a reasonable number of persistent connections to have
open? Suppose the db server has 8 GB of ram (the mongo database is
3.5GB) and the web app gets accessed by 25k users in a 3 hr time
period and every page hits the db.

Kristina Chodorow

unread,
Nov 2, 2010, 11:57:33 AM11/2/10
to mongod...@googlegroups.com
Does your application server spawn multiple PHP processes?  Each process will use its own pool of persistent connections.  Also, I just found a bug with PHP 5.3 where it's not closing persistent connections properly (PHP 5.2 works).  So, you might be hitting one or both of those.

You'll probably be able to saturate the network before you hit the connection limit, so if you can figure out how much each connection can send and the total capacity of your network, that's the max number of connections that will be useful.



--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


Message has been deleted

Harry B

unread,
Nov 2, 2010, 2:51:42 PM11/2/10
to mongodb-user
Thanks Kristina,

I am using PHP 5.3.2-1ubuntu4.2 with fastcgi.

I will disable persistent connections for now.

I had issues with my web app recently and I think it was due to the
mongo server. It had a spike and was hitting 87% CPU utilization and a
4+ load. I was getting 504 errors and blank pages.

My plan is to setup a replica set and do distributed reads. Read to
write ratio is about 14/1.

I have a large Amazon EC2 instance (7.5 GB memory 4 EC2 Compute Units)
for my mongo server but will be setting up a replica set so it should
help.

If you have any tips or additional insight that would be greatly
appreciated.

I'm expecting a similar traffic level this week and want to be
prepared.



On Nov 2, 8:57 am, Kristina Chodorow <krist...@10gen.com> wrote:
> Does your application server spawn multiple PHP processes?  Each process
> will use its own pool of persistent connections.  Also, I just found a bug
> with PHP 5.3 where it's not closing persistent connections properly (PHP 5.2
> works).  So, you might be hitting one or both of those.
>
> You'll probably be able to saturate the network before you hit the
> connection limit, so if you can figure out how much each connection can send
> and the total capacity of your network, that's the max number of connections
> that will be useful.
>
> On Mon, Nov 1, 2010 at 6:32 PM, Harry B <ballsa...@gmail.com> wrote:
> > I'm using 1.0.10 php driver.
>
> > I'm connecting with:
>
> > $this->conn = new Mongo("{$host}", array( 'persist' => $database .
> > rand(1,100) ) );
>
> > On the mongo database server if I do db.serverStatus(); then I've seen
> > current connections go up into 200's
>
> > Why aren't the connections limited to the total number of
> > possibilities for my persistent connection string?
>
> > Also, what is a reasonable number of persistent connections to have
> > open? Suppose the db server has 8 GB of ram (the mongo database is
> > 3.5GB) and the web app gets accessed by 25k users in a 3 hr time
> > period and every page hits the db.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "mongodb-user" group.
> > To post to this group, send email to mongod...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > mongodb-user...@googlegroups.com<mongodb-user%2Bunsu...@googlegroups.com>
> > .

Kristina Chodorow

unread,
Nov 8, 2010, 11:13:24 AM11/8/10
to mongod...@googlegroups.com
You should try 1.0.11, there were some improvements to persistent connections.  I'd suggest using persistent connections, just less of them (and let us know if the number of connections to the server creeps up over time).


To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages