NAME

Beekeeper::Service::Supervisor - Worker pool supervisor

VERSION

Version 0.09

SYNOPSIS

my $status = Beekeeper::Service::Supervisor->get_services_status(
    host => '.*',
    pool => '.*',
    pool => '.*',
);

print "$_: $status->{$_}->{load}\n" foreach keys %$status;

Beekeeper::Service::Supervisor->get_services_status(
    on_success => sub {
        my ($status) = @_;
        print "$_: $status->{$_}->{load}\n" foreach keys %$status;
    },
    on_error => sub {
        my ($error) = @_;
        die $error->message;
    },
);

DESCRIPTION

A Supervisor worker is created automatically in every worker pool.

It keeps a shared table of the performance metrics of every worker connected to every broker, and routinely measures the CPU and memory usage of local workers.

These metrics can be queried using the methods provided by this module or using the command line client bkpr-top.

Reported performance metrics

nps

Number of received notifications per second.

cps

Number of processed calls per second.

err

Number of errors per second generated while handling calls or notifications.

mem

Resident non shared memory size in KiB. This is roughly equivalent to the value of RES minus SHR displayed by top.

cpu

Percentage of CPU load (100 indicates a full utilization of one core thread).

load

Percentage of busy time (100 indicates no idle time).

Note that workers can have a high load with very little CPU usage when being blocked by synchronous operations (like slow SQL queries, for example).

Due to inaccuracies of measurement the actual maximum may be slightly below 100.

METHODS

get_services_status ( %filters )

Returns the aggregate performance metrics of all active services.

Services can be filtered by host, pool and class.

get_workers_status ( %filters )

Returns the individual performance metrics of every worker of all active services.

Services can be filtered by host, pool and class.

get_services_status_async ( %filters, on_success => $cb, on_error => $cb )

Asynchronous version of get_services_status method.

Callbacks on_success and on_error must be coderefs and will receive respectively Beekeeper::JSONRPC::Response and Beekeeper::JSONRPC::Error objects as arguments.

get_workers_status_async ( %filters, on_success => $cb, on_error => $cb )

Asynchronous version of get_workers_status method.

SEE ALSO

bkpr-top, bkpr-restart, Beekeeper::Service::Supervisor::Worker.

AUTHOR

José Micó, jose.mico@gmail.com

COPYRIGHT AND LICENSE

Copyright 2015-2023 José Micó.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language itself.

This software is distributed in the hope that it will be useful, but it is provided “as is” and without any express or implied warranties. For details, see the full text of the license in the file LICENSE.