Hello monks,
I'm building a medium-sized web application which currently runs under plain-ol' CGI. I have about 10 modules that each correspond to a table in the database (using an interface similar to
Class::DBI). These DB object modules are all
use'd by the main module (MyApp), and this main module is
use'd by the CGI script as such:
# application.pl
use MyApp;
MyApp->run;
Each page request takes about .5-.6 seconds to execute, which is a little much for my taste. So I wanted to try running it under mod_perl. I profiled the program, and found that MyApp::BEGIN takes up about 70% of the execution time, because it in turn loads the other dozen modules. (In fact, that's the only thing I can see that is done in BEGIN) It was my understanding that in mod_perl, the modules would be loaded once and then stay resident in memory for subsequent requests, thus saving the time taken by BEGIN. However, this didn't turn out to be the case. In fact, things were about 5-10%
slower under mod_perl.
Am I missing something big here? I'm quite new to mod_perl, and perhaps there is a more optimized way to load all my modules. How should I structure my application so that the modules are memory-resident in mod_perl? It would be really nice to get request times down to around .1 or .2 seconds. Thanks in advance!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.