How can the mysql queries for reads and writes be sent to different servers?
-
Imagine a scenario where there is a single mysql master database server and two slaves, one nearer to the primary and one in the local vicinity in order to reduce the query traffic. Now I would like any database updating queries(insert, update and deletes) to be directed to the master server and any reads to be directed to any of the slave servers. How can that be achieved? I use php for my application development
-
Answer:
PHP extension mysqlnd-ms can automatically or with hints detect and balance your read queries against a collection of defined slaves. See: http://php.net/manual/en/book.mysqlnd-ms.php specifically http://www.php.net/manual/en/mysqlnd-ms.rwsplit.php For Java applications you would need to declare the transaction as read-only and at the transaction boundary the query is balanced. http://dev.mysql.com/doc/refman/5.5/en/connector-j-reference-replication-connection.html
Matthew Montgomery at Quora Visit the source
Related Q & A:
- How can I delete saved graphics from email sent to me from my Yahoo folder?Best solution by Yahoo! Answers
- How can I delete attachments that have been sent to my email account?Best solution by Yahoo! Answers
- How can I see the attachments that were sent to my e-mail?Best solution by Yahoo! Answers
- How can I see messages that were sent in mail 5's conversation view?Best solution by Ask Different
- How can I correct sent emails from showing a wrong return address?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.