At the place of my work we deal with a number of processes each of which is utilizing at least one database connection. This strains our database of reasources which led me to look at ways of reducing the number of opened database connections at any one time by having central process that would 'serve' a readily available database handle to an open connection to any any script requiring one.

I've been searching PerlMonks for nodes which would cover the same issue, but didn't find exactly what I was looking for. For example, the author of this node is talking about sharing a database connection between parent process and a number of child processes. However, I'm concerned about having a stand alone process which would 'serve' database connections to any number of 'external' processes upon request.

I'm now wondering just how should I approach this problem? One option could be to have the central process share database handler objects (such as DBI objects) with external scripts. For this I might find the Shared.pm module useful. However, I'm not sure if sharing a scalar or an array is a totally different matter than sharing a database handler object? Another option would be to simply have the central process accept requests from external processes in form of SQL statements and return data via a socket connection etc.

I'd appreciate it if you could point me in the right direction. I'm somewhat sure there must be some Perl modules that would enable me to implement this easier than if I had to do it on my own.


"There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith

In reply to Sharing database connections over multiple (non child) processes. by vladb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.