ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


Action unknown: siteexport_addpage
v5:reference:loadbalancer:getloadbalancedconnection

getLoadBalancedConnection

Applies To

ADOdb Load Balancer

Syntax
 int getLoadBalancedConnection(
       string $connectionType = 'write|readonly'
       )

Description

The method getLoadBalancedConnection() returns the appropriate node number for the connection type, taking into account the connection type, the connection weight, whether connections are pinned and if there are any failed connection in any of the nodes.


To ensure the accuracy of the response, you should have executed at least one statement against the load balancer connection

In the following example, we have 4 nodes, 1 write and 3 readonly

NodeTypeWeight
0write1
1readonly50
2readonly30
3readonly40
  • If we make a call to getReadOnlyConnection('write'), the return value is always 0 (zero)
  • If we make a call to getReadOnlyConnection('readonly'), the return value is 1
  • If we disconnect node 1 or the connection fails, the return value is 3
v5/reference/loadbalancer/getloadbalancedconnection.txt · Last modified: 2017/05/11 00:34 by mnewnham