Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Think about Loose Coupling

Comment on


I have an application which forks of child processes to do all the work. At the moment, every child process creates its own database connection, does its work and closes the database connection again. This causes a lot of connections to be made to the database.

What I would like to do is to create one database connection, and let all child processes use this same connection. But sometimes the database connection drops, and a new one needs to be created.

Question 1: Is it wise to use the same database handle for all child processes?
Question 2: How do I check if a database handle has been destroyed (e.g. connection lost) without performing a query? I want the server process only to create the database connection, and check if it is still usuable by child processes or otherwise restore it.

In reply to Sharing database handle by Marcello

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (7)
    As of 2014-03-14 19:07 GMT
    Find Nodes?
      Voting Booth?

      Have you used a cryptocurrency?

      Results (310 votes), past polls