v5:reference:loadbalancer:getloadbalancedconnection
This is an old revision of the document!
getLoadBalancedConnection
Applies To
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.
In the following example, we have 4 nodes, 1 write
and 3 readonly
Node | Type | Weight |
---|---|---|
0 | write | 1 |
1 | readonly | 50 |
2 | readonly | 30 |
3 | readonly | 40 |
- 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.1493250821.txt.gz · Last modified: 2017/04/27 01:53 by mnewnham