The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Beekeeper::Service::Router::Worker - Route messages between backend and frontend buses

VERSION

Version 0.09

SYNOPSIS

DESCRIPTION

Router workers pull requests from all frontend brokers and forward them to the single backend broker it is connected to, and pull generated responses from the backend and forward them to the aproppiate frontend broker which the client is connected to.

Additionally, routers include some primitives that can be used to implement session management and push notifications. In order to push unicasted notifications, routers will keep an in-memory shared table of client connections and server side assigned addresses. Each entry consumes 1.5 KiB of memory, so a table of 100K sessions will consume around 150 MiB for each Router worker.

If the application does not bind client sessions the routers can scale horizontally really well, as you can have thousands of them connected to hundreds of brokers.

But please note that, when the application does use the session binding mechanism, all routers will need the in-memory shared table, and this shared table will not scale to a great extent as the rest of the system. The limiting factor is the global rate of updates to the table, which will cap around 5000 bind operations (logins) per second. This may be fixed on future releases by means of partitioning the table. Meanwhile, this session binding mechanism is not suitable for applications with a large number of concurrent clients.

Router workers are not created automatically. In order to add Router workers to a pool these must be declared into config file pool.config.json:

  [
      {
          "pool_id" : "myapp",
          "bus_id"  : "backend",
          "workers" : {
              "Beekeeper::Service::Router::Worker" : { "worker_count": 4 },
               ...
          },
      },
  ]

SEE ALSO

Beekeeper::Worker::Extension::RemoteSession, which is the interface to the RPC methods exposed by this worker class.

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.