Magento Performance: Adding more MySQL Servers
Magento provides a really handy options to scale well. The feature which i am going to talk about is very little know. Magento allows to add mysql slave server to put load of “read” queries on different server.
The mysql server has to do a lot of things like adding and updating records at high frequency, manage locks, conflicts etc etc. If we can get our server free from read only queries it can perform updates and other operations at fast pace. MySQL provides feature of Master Slave replication for this purpose.
In master slave replication a server called Master takes care of all updates, schema changes etc etc and let other servers take care of queries which only need to read data. Once replication is set slave server keep its self synced with master (its enough to know at the moment, in some other post will explain master slave replication in detail).
Back to topic, we can add a slave server to share load with other server. To add read server in Magento you will need to edit the config file app/etc/local.xml. You will a block of <default_setup> in which details of main or master server are there. You can add new server by following code
<default_read>
<connection>
<host><![CDATA[host]]></host>
<username><![CDATA[useronslave]]></username>
<password><![CDATA[secret]]></password>
<dbname><![CDATA[dbname]]></dbname>
<active>1</active>
</connection>
</default_read>
This will shift the load of read queries on slave server and give more space to breath on master server. For more refer to Magento’s official documentation.
Thanks a ton. It really helpppppp