Apache-Backhand
view release on metacpan or search on metacpan
Backhand.pm view on Meta::CPAN
The supremim integral power of 2 of the load seen thus far
=item cpu
CPU idle time (multiplied by 1000)
=item ncpu
Number of CPU
=item tmem
Total memory in bytes
=item amem
Available memory in bytes
=item numbacked
Number of requests backhanded
=item tatime
Averages time (in milliseconds) to serve a backhanded request
=back
This structure sounds worse than it is. It's really quite simple to use:
foreach my $server ($serverstats) {
print $server->{'mtime'}, "\n";
$server->{'load'} += 1;
}
Note that each of the elements of the hashes is magically tied directly (for
both reads and writes) into the shared memory segment where serverstats
resides. You can call load_serverstats() once, and use the returned structure
as much as you want - it will always reflect the contents of the underlying
shared structure. This has one drawback, however, which is that you cannot
call load_serverstats() until after the shared memory segment has been created
and attached. I recommend a PerlChildInit handler to do load_serverstats()
into a global variable.
=item B<load_personal_arriba>
This function returns a reference to a scalar variable which is magically
tied to the global mod_backhand_personal_arriba integer. This contains the
arriba speed of the local machine.
=back
=head1 CAVEATS
As explained above, you cannot PerlModule or use() or require()
Apache::Backhand until *after* mod_backhand (and mod_perl, of course) are
linked into the server.
As explained above, you cannot call load_serverstats() until *after* the
shared memory segment has been created and attached. The best place to do
this is the child init phase.
It's easy to make mod_backhand coredump by doing Bad Things to serverstats
(e.g. 'foreach (@{$serverstats}) { $_->{'mtime'} = time() }'...)
Even though I've provided the magic to make serverstats writeable, this should
be treated with care.
There is necessarily going to be a small amount of overhead when calling perl
candidacy functions. I highly recommend calling byAge *before* calling any
perl candidacy functions, because converting the server list into a perl array
and back again is one of the most expensive operations byPerl has to perform,
and byAge tends to knock out a lot of unnecessary work.
=head1 BUGS
Hopefully none.
=head1 AUTHOR
J. David Lowe, dlowe@pootpoot.com
=head1 SEE ALSO
perl(1)
=cut
( run in 2.002 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )