0

What would happen if you had code that would open and close a lot of MySQL connections constantly?

For instance if you have a pool of processes forking themselves constantly at the rate of >200 fork/second and each fork open a connection, does an action and close the connection.

marcgg
  • 65,020
  • 52
  • 178
  • 231
  • Ask on serverfault.com, but one might be hitting this limit: http://stackoverflow.com/questions/651665/how-many-socket-connections-possible – Wrikken Jan 12 '12 at 18:12

2 Answers2

1

MySQL can accumulate and refuse connections if any process slow down and not release the connection on the second you expected.

Other problem is the authentication, database selection, and TCP connection (if running in another server) latency time, is a significant time when there is a large number of connections per second.

For PHP you can use persistent connections, but i never made a benchmark to know the real benefit (in numbers). You can read something about it in mysql perfomance blog.

Paulo H.
  • 1,228
  • 10
  • 15
1

Depending on how many connections MySQL is configured to accept you will most likely be refused connection the question is how quickly this will happen.

Karlson
  • 2,958
  • 1
  • 21
  • 48