Mysql – Slow thesql performance between 2 servers

MySQL

I have 2 servers, both running Ubuntu server 11.10.
The first server runs Apache and PHP and it connects to a Mysql database on the second server.

The problem is slow mysql response on the second server.mysql logs does not show any errros other than: 120526 12:56:27 [Note] Plugin 'FEDERATED' is disabled. but that does not prevent mysql from starting/restarting.

I tried to run queries from inside the mysql server using the same php app on the first server and it was very fast. but when the same php app requests data from the first server to the mysql server the response is really slow and the database is not big.

How can i find whats causing the problem ?

Note: am using IP address when connecting via php app from server 1 to server 2, so i dont think this is DNS related.

Thanks

Best Answer

There can be many factors that affect mysql performance:

  1. Make sure you are comparing the same queries locally vs. remotely.
  2. Check the network bandwidth/delay between the two servers.
  3. Try starting mysql server with --skip-name-resolve option. This disables DNS resolution which may cause unneeded delays.