The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Argon::Cluster

SYNOPSIS

    use EV; # use libev as event loop (see AnyEvent for details)
    use Argon::Cluster;

    my $cluster = Argon::Cluster->new(
        port         => 8000,
        host         => 'localhost',
        queue_limit  => 128,
    );

    $cluster->start;

DESCRIPTION

An Argon::Cluster is a manager on an Argon network. Argon::Nodes are configured (via the manager parameter) to report their availability to the cluster. The cluster manages nodes registered in this way and routes Argon::Messages to the most available node (based on past performance and the number of tasks it has queued vs the number of worker processes it has available).

If a node disconnects, it is automatically unregistered from the cluster until such a time as it reconnects. Any messages which had been routed to the node will fail and an error message returned to the requesting client (since it is impossible to retry the task without knowing what state it was in when the node failed).

Argon::Cluster inherits Argon::Server.

METHODS

new(host => ..., port => ...)

Creates a new Argon::Cluster. The node does not automatically start listening.

Parameters:

host

Required. Hostname of the device to listen on.

port

Required. Port number on which to listen.

queue_limit

Required. Size of the message queue. Any messages that come in after the queue has been filled with be rejected. It is up to the client to retry rejected messages.

Setting a large queue_limit will decrease the number of rejected messages but will make the server vulnerable to spikes in traffic density (e.g. a DOS attack or an unanticipated increase in traffic). Setting a lower queue_limit ensures that high traffic volumes do not cause the server to become bogged down and unresponsive. Note that in either case, the client will be waiting a longer time for a response; in the second case, however, the server will bounce back from traffic spikes much more quickly than in the first.

start

Starts the server. Blocks until shutdown is called.

shutdown

Causes the server to stop at the next available cycle. Onced called, each client will be disconnected and any pending messages will be failed.

AUTHOR

Jeff Ober mailto:jeffober@gmail.com

LICENSE

BSD license