I had a similar problem recently.

I wrote a startup script for mod_perl to
(1) set up a persistent database connection (in my case, MySQL),
(2) declare some global variables to use within the script.
(3) pre-load the script to be used by the outside world

Changes that will be referenced "every now and then" can be updated quickly in MySQL without problems. Remember to keep your tables small and properly indexed. The fewer UPDATE statements, the better. My final solution used one UPDATE statement, which meant the table was locked for a minimum amount of time without a chance of data corruption from an ill-timed SELECT statement by another child process.

Changes that must be immediately available to all can be stored in the global variable(s). Any future children will instantly have the correct info.

Doing this, I was able to maintain correct information without problems with up to 30 script calls per minute. No storage of session data was necessary. The script for the outside world becomes very small -- get the info, make UPDATEs if necessary, and spit out an answer...


In reply to Re: Improving efficiency - repeated script hits at small interval by shambright
in thread Improving efficiency - repeated script hits at small interval by BUU

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.