ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:loadbalancer:mysql_replication:automatic_control

Differences

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

Link to this comparison view

Next revision
Previous revision
v5:loadbalancer:mysql_replication:automatic_control [2016/10/12 04:16] – created mnewnhamv5:loadbalancer:mysql_replication:automatic_control [2017/04/29 04:01] (current) mnewnham
Line 1: Line 1:
-<- v5:loadbalancer:mysql_replication:creating_connections|Creating Connections ^ v5:loadbalancer:index|ADOdb Loadbalancer ^ v5:loadbalancer:mysql_replication:manual_control|Manual Configurations ->+<- v5:loadbalancer:mysql_replication:creating_connections|Creating Connections ^ v5:loadbalancer:index|ADOdb Loadbalancer ^ v5:loadbalancer:mysql_replication:debugging|Debugging ->
 ~~NOTOC~~ ~~NOTOC~~
 ====== Automatic Control Of Statement Execution ====== ====== Automatic Control Of Statement Execution ======
 +Once we have assigned the primary ''write'' server, we can assign ''readonly'' servers. These servers are used to delegate readonly SQL operations, thereby reducing the load on the primary server. The Load balancer class can automatically determine which SQL statements can be delegated onto secondary nodes. There is no limit to the number of secondary servers that can be created.
 +<code php>
 +$db = new ADOdbLoadbalancer;
 +
 +$db0 = new ADOdbLoadbalancerConnection('mysqli','write',1,'host1','user','pass','database');
 +$db->addConnection($db0);
 +
 +$db1 = new ADOdbLoadbalancerConnection('mysqli','readonly',2,'host2','user','pass','database');
 +$db->addConnection($db1);
 +
 +$db2 = new ADOdbLoadbalancerConnection('mysqli','readonly',3,'host3','user','pass','database');
 +$db->addConnection($db2);
 +
 +/*
 +*  Keep adding readonly servers
 +*/
 +</code>
 +
 The load balancer automatically controls the execution of SQL statements through ADOdb by parsing the statement and directing the execution to the appropriate server: The load balancer automatically controls the execution of SQL statements through ADOdb by parsing the statement and directing the execution to the appropriate server:
   - Statements that require read-write access to the database are directed to the primary server.   - Statements that require read-write access to the database are directed to the primary server.
v5/loadbalancer/mysql_replication/automatic_control.1476238565.txt.gz · Last modified: 2017/04/21 11:30 (external edit)