Forum Moderators: phranque

Message Too Old, No Replies

150 mySQL queries fast locally, but too long accross cross connect

         

moheybee

5:16 pm on Apr 15, 2005 (gmt 0)

10+ Year Member



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!

freeflight2

5:28 pm on Apr 15, 2005 (gmt 0)

10+ Year Member



what does 'ping' say?
on a 100mbit network I am getting:
64 bytes from 192.168.1.100: icmp_seq=0 ttl=64 time=0.224 ms
64 bytes from 192.168.1.100: icmp_seq=1 ttl=64 time=0.177 ms

moheybee

5:37 pm on Apr 15, 2005 (gmt 0)

10+ Year Member



It's fast.

su-2.05b# ping db0
PING db0 (192.168.0.1): 56 data bytes
64 bytes from 192.168.0.1: icmp_seq=0 ttl=64 time=0.097 ms
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.092 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.117 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.111 ms
64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=0.102 ms
64 bytes from 192.168.0.1: icmp_seq=5 ttl=64 time=0.090 ms
64 bytes from 192.168.0.1: icmp_seq=6 ttl=64 time=0.102 ms
64 bytes from 192.168.0.1: icmp_seq=7 ttl=64 time=0.105 ms
^C
--- db0 ping statistics ---
8 packets transmitted, 8 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.090/0.102/0.117/0.009 ms