1

I am currently running a virtualized environment for my web and db server. When I access the web server or the MySQL server individually, they are both fast. I also have websites running on the web server that do not require the db server and those all load quickly. However, when I access my hosted website that requires the web server to call from the db server, there is about a 5-7 second latency for every page load. This has been confirmed with both a very simple site and with a Word Press setup as well. Here is the config:

Web server - CentOS 6.5, Apache 2.2.15

DB server - CentOS 6.5, MySQL 5.1.73

My question is, are the servers continuously authenticating with one another (and thus causing latency) on every single db call? If that is the case, does anyone know how to permanently authenticate between the two?

I might be way off on this assumption and authentication could have nothing to do with it. I am completely open to any and all ideas at this point. Thank you very much.

V/R,

Tony

2
  • Are you connecting to MySQL over a private or public network? Are you using an IP or domain name? If you try to load a PHP page (e.g. phpinfo) that does not have a DB call it is fast? Mar 26 '14 at 17:00
  • This is over a local private network using IP addresses. Logs show that my query times are in the .0003 - .0005 range.
    – Bearicorn
    Mar 27 '14 at 19:45
0

Update 17 April 2014

DNS was indeed the culprit. Once I added each server to the others dns host file, the latency disappeared. To put down specifically what I did.

I first went to my dns host files located at /etc/hosts (note it is hosts, not hosts.conf) on both servers and added each server: 192.168.0.1 server 1 192.168.0.2 server 2

I then went to the nsswitch configuration file located at /etc/nsswitch.conf and made sure that both config files (one on each server) contained the following line: hosts: files dns

I then pinged the host name and was able to resolve the private IP. Latency is now gone!!! Thank you for all the help and answers all.

V/R,

Tony


* Old post stuffs under here *

That's a lot of latency even for setting up the connection and authenticating, are the web service and db server on the same virtual machine (same server)? If not there may be a DNS resolution issue.

I suggest to write the simplest php code that connects to the db using mysql_connect first (which doesn't persist connections) and the newer mysqli which persists connections http://ca3.php.net/manual/en/mysqli.quickstart.connections.php and check how long they take, this will rule out an issue with the web application code.

Another test is to go to the (web) server and connect to the db manually with the mysql command and see how long it takes.

In all these tests besides the connection you can add doing a simple select query.

2
  • The two servers are different virtual machines. I will continue working this and leave my findings once I determine the root cause of the issue. Cheers!
    – Bearicorn
    Mar 27 '14 at 19:43
  • @user3465046 glad you figured it out. BTW not sure but I think you should have edited your question or added an answer and not edit my answer (not that I mind)? Apr 17 '14 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.