I have a high load website served by two servers: web server with nginx
and php
, and database server with mysql
. Web server serves all the static content and connects to MySQL and outside world through single interface - eth0
.
On peak hours, traffic on this interface gets close maximum, and ping time to mysql server get very high (up to 100ms, even though servers are on the same LAN).
So, my question is: will setting up another network interface dedicated only to MySQL connections on web server solve high latency problem?
If yes, what tools do I use, to forward mysql connections through different network interface? How to set up interfaces properly, do I need different IP adresses on the interfaces?
Both servers have ubuntu-server
.
If you are maxing out the bandwidth on the interface and seeing high latency you will very likely see a benefit from running the MySQL connection over a different interface.
You don't have to do anything special to make it use the other interface, but yes, it will need an IP address in a different network to eth0.
Give the MySQL server an IP such as 10.0.0.1/255.255.255.0 and eth1 on the web server 10.0.0.2/255.255.255.0. You can use any private IP range you like really and you could use a smaller netmask, the important thing is that it's a different range to eth0 on the web server. That way, when the web server connects to 10.0.0.1, it will know it has to use eth1 for that.