RoundRobinSelector vs StickyRoundRobinSelector

edit

RoundRobinSelector vs StickyRoundRobinSelector

edit

In a similar vein as the connection pool, there is a PHP-specific selector that may be useful to some environments.

The selector’s job is to return a single connection from an array of connections. The default is a round-robin selector that operates on a randomized list of hosts. This ensures an even load of traffic across your cluster. Round-robin’ing happens on a per-request basis (e.g. sequential requests go to different nodes).

Considering the nature of many PHP scripts, it is possible this is a sub-optimal strategy due to overhead of creating new connections. For that reason, there is a slightly modified StickyRoundRobinSelector class.

This class prefers to use the same connection for every request, but if the node is dead (due to a previous connection failure) it will round-robin to the next node. Using the default randomizeHosts = true setting, this still ensures even distribution of load across the cluster. The load will simply be round-robin’ed on a per-script basis rather than a per-query basis.