geektron has asked for the wisdom of the Perl Monks concerning the following question:
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:
and the PIDs are verified as part of the handler, and one step further, the spikes are from cache access, not from cache setting.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
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" ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Cache::FileCache, CPU utilization, and bottlenecks ....
by perrin (Chancellor) on Jan 10, 2005 at 23:39 UTC | |
by simonm (Vicar) on Jan 11, 2005 at 03:15 UTC | |
by geektron (Curate) on Jan 11, 2005 at 17:26 UTC | |
by geektron (Curate) on Jan 10, 2005 at 23:45 UTC | |
|
Re: Cache::FileCache, CPU utilization, and bottlenecks ....
by redhotpenguin (Deacon) on Jan 10, 2005 at 22:38 UTC | |
by geektron (Curate) on Jan 10, 2005 at 23:46 UTC | |
by geektron (Curate) on Jan 11, 2005 at 06:05 UTC | |
by redhotpenguin (Deacon) on Jan 11, 2005 at 16:16 UTC |