Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

So here's the problem: I have a CGI application for creating web pages which currently stores a representation of the links and data of a web site in a perl hash-of-hashes structure that I write to disk with Data::Dumper (see This is fine for a dozen medium sized web pages, but at some point, loading the data file for each CGI execution is going to make this app slow. Using mod_perl would solve this (right?), but my target users are either on shared servers (and thus don't have mod_perl) or don't want to deal with setting up a database. I also know I can use as a faster file storage solution, but that still writes to disk. So I started thinking about how it might be possible to retrieve persistent data through a Unix socket.

Here's the idea: Multiple CGI processes all talk to a persistent process that just hands them the perl hash (or accepts an updated hash) through a Unix socket. The process would die after a timeout period. It would be started by the inital CGI request, which would check if the process existed and create one if it didn't. Another way to think of this idea: it's just a home-made database connection, but the data is cached in memory (it doesn't read from disk on every request, only the first one, or after a modify).

Is this possible? (I think it is). Is this just a bad idea? Comments? I'm not avoiding mySQL, but I am catering to users who either don't have access to a database or don't want to set one up.


In reply to CGI data from memory w/o mod_perl by Anonymous Monk

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2023-03-25 04:24 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (62 votes). Check out past polls.