ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:loadbalancer:enable_sticky_sessionsl

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
v5:reference:loadbalancer:enable_sticky_sessionsl [2017/04/23 19:49] – created mnewnhamv5:reference:loadbalancer:enable_sticky_sessionsl [2017/05/11 01:14] (current) – [Description] mnewnham
Line 3: Line 3:
 <WRAP right box> <WRAP right box>
 == Applies To == == Applies To ==
-ADOdb Load Balancer+[[v5:loadbalancer:index|ADOdb Load Balancer]]
 == See Also == == See Also ==
 [[v5:reference:loadbalancer:addconnection|AddConnection()]]\\ [[v5:reference:loadbalancer:addconnection|AddConnection()]]\\
 == Syntax == == Syntax ==
-   bool $enable_sticky_sessions+   bool $enable_sticky_sessions=true
 </WRAP> </WRAP>
 ===== Description ===== ===== Description =====
  
-The public class variable ''$enable_sticky_sessions'' pins the execution of commands to the last connection used.+The public class variable ''$enable_sticky_sessions'' pins the execution of commands to the last connection used. The default value for this is **true**. 
 +The normal behavior of the load balancer is to re-use the first found connection, as the overhead of establishing a database connection is generally larger than that of running multiple simple queries against a single connection.
  
 +The primary use-case for disabling this is if you are running a substantial number of heavy queries and want to truly load balance at the per-query level rather than the per-request level. 
 +
 +Since connecting to the database can take longer than running a few queries, it is less efficient to startup 5 connections to run 5 separate queries, when all 5 queries could be run on a single connection in less time. However if you need to run 1000 queries in a row (ie: batch job), it might be better to startup 5 connections and load balance all 1000 queries across those connections.
 --------------------------- ---------------------------
 ===== Usage ===== ===== Usage =====
 <code php> <code php>
  
-$response = $db->removeConnection(2);+$db->enable_sticky_sessions = false;
  
 </code> </code>
v5/reference/loadbalancer/enable_sticky_sessionsl.1492969781.txt.gz · Last modified: 2017/04/23 19:49 by mnewnham