We are running FreeBSD on two Dual 2.5GHZ Xeon's each with 2 gigs of ram. One is our web server and the other our mySQL database server.
The machines are connected directly with a cross connect cable. We are seeing transfer speeds of 8mb/s with scp between the two of them. There is no indication that there is anything slow about the connection between the two of them.
I have one page where a string of 150 very simple queries are run one after another. It always loaded fairly fast (~0.1 second load time) in the past on our old servers (same setup - one web and one database). Now the page is taking about 2 seconds to load.
I used the Advanced PHP Debugger (APD) profiler to see what functions were taking the most time because we thought it might be something wrong with PHP. The mysql_connect and mysql_select_db were taking the most time, but why so much?
Next I decided to time the queries from the command line on both the web server (where the page is loading slow) and locally on the database server:
-bash-2.05b$ time mysql -h localhost -u [removed] -p[removed] -D [removed] < queries
[query results removed]
real 0m0.026s
user 0m0.000s
sys 0m0.015s
su-2.05b# time mysql -h db0 -u [removed] -p[removed] -D [removed] < queries
[query results removed]
real 0m1.153s
user 0m0.000s
sys 0m0.020s
You can see the huge time difference. If I swap out the db0 alias for 192.168.0.1 the local address of the database server, it takes the same amount of time.
Does anyone have any clue as to why this might be happening?
Any help would be VERY much appreciated.
Thanks!