i had to recently rewrite a mod_perl handler that was using Apache::CacheContent ( see: Apache::CacheContent and unforeseen side effects ).

now, i'm seeing way too much CPU utilization from the new Cache::FileCache-based handler. (at least, the bossman thinks it's too much load.)

with maybe a few requests/sec to this site, CPU is somewhere around 30% ... I've added PID logging in the handler to confirm that the CPU spikes are from this handler, and not from some other runaway process....

the output from top looks something like this:

PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMM +AND 6199 nobody 15 0 14384 14M 5520 S 29.6 0.6 0:07 0 http +d 6251 nobody 15 0 14816 14M 5808 S 12.9 0.7 0:05 0 http +d
and the PIDs are verified as part of the handler, and one step further, the spikes are from cache access, not from cache setting.

is there any way to lighten the CPU load?

and the relevant part of the handler ...

$did ||= 1100; my $cache = new Cache::FileCache ( { namespace => 'mySpace', default_expires_in => '600', } ); my $data = $cache->get( $did ); warn "using data from cache! (PID: $$) " if DEBUG and $data; if ( ! $data ) { use Net::SSLeay qw(get_https post_https sslcat make_headers make_ +form); my $url = "*****"; $SIG{ALRM} = sub { return DECLINED; }; alarm(15); my ($page, $response, %reply_headers) = get_https($secureHost, 443, "$url"); alarm(0); ### process $page to get $data .... warn "setting cache now for $did (PID: $$) " if DEBUG; $cache->set( $did, $data, "600" ); }

In reply to Cache::FileCache, CPU utilization, and bottlenecks .... by geektron

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.