1

I have an issue concerning PDO persistent connection. Now this may not be an actual problem, but I can't seem to find any post addressing this behavior.

I'm using the good old PDO in a persistent connection mode for my web app. Now I'm creating a new connection via new PDO(...).

When I run this script a new connection (C#1) is getting established and a MySql process (P#1) to accommodate the persistent connection.

So, I run the script again creating a new conction (C#2) and expecting C#2 to use the P#1 from the last connection. Every time I run this script a new process appears while the last one is still alive (in sleep mode).

On my production server there are about 350 prossers (in sleep) at any given time from 3 defrent users (all users connect from the same apache server).

The question: is this situation valid?

Ryan B
  • 3,364
  • 21
  • 35
Daniel
  • 2,288
  • 1
  • 14
  • 22
  • persistent connections with mysql are generally a bad idea. it is VERY easy to get into a deadlock situation. – Marc B Aug 13 '14 at 15:00

1 Answers1

0

found my answer

They cause the child process to simply connect only once for its entire lifespan, instead of every time it processes a page that requires connecting to the SQL server. This means that for every child that opened a persistent connection will have its own open persistent connection to the server. For example, if you had 20 different child processes that ran a script that made a persistent connection to your SQL server, you'd have 20 different connections to the SQL server, one from each child.

http://php.net/manual/en/features.persistent-connections.php

Daniel
  • 2,288
  • 1
  • 14
  • 22