What's your typical database connection time?


#1

After giving up on Support, I’ve decided to monitor MySQL database connection and query timings more closely. I swear that in the past, connection times used to take <0.1 seconds, but now I’m consistently seeing connections taking between 0.1 and 0.3 seconds, which I think is slow. Before I have another round with Support, can anyone tell me how long your database connections take? I’m not talking about the connection + query, just the connection. As it stands now, my queries are taking about half of the time that the connection takes!


#2

I just ran 100 trials on my account (shared web server and MySQL VPS), and got:

MINIMUM: 1.6 ms (0.001588 sec)
AVERAGE: 5.5 ms (0.0055 sec)
MAXIMUM: 30 ms (0.0296 sec)

0.1 to 0.3 sec (100 to 300 ms) is, needless to say, pretty high. It does look like you’re on a shared MySQL server (inki) that’s got an above-average load; ask Support about getting that moved. Alternatively, upgrading to a MySQL VPS will likely give you even better results.


#3

On my psmysql connection times usually take 0.00507784 seconds but I am monitoring every connection made to the mysql server like

	$callTimes['dbConnect'] = microtime(TRUE);
	$db = new Database('mysql:host='.DB_SERVER.';dbname='.DB_NAME, DB_USER,DB_PASS);  
	
	$callTimes['dbConnect'] = microtime(TRUE) - $callTimes['dbConnect'];

And then I log it in the database, out of 4804 connections 62 of them took more than 3 seconds.That is 1.2% of all connections taking more than 3 seconds which is kinda annoying.

After searching the web for some time I found these links, I don’t know if they are the cause of the issue.

http://serverfault.com/questions/51317/c…-3-seconds

http://www.linuxquestions.org/questions/...ost3057064

When it is slow like this it is always around 3 seconds.

I am on psmysql57998 if that makes a difference. Made a support ticket sometime ago but they said it is fine.


#4

Thanks andrewf and Finglor. I’ve seen similar questions on servefault, specifically the 3-second /ipv6 thing, but I wasn’t sure how good my memory was since I haven’t logged anything. I was sure that <100 ms was the norm, but I didn’t have any evidence.

Personally, I’m not too concerned with it being so slow. I’m more concerned that there might be a problem, as there was in the past which Dreamhost initially acknowledged, accepted blame, and promised they were working on it. But it seems to me that there may still be a problem and I’d like them to know about it. The problem is, the last time I tried to inform them that a problem may still exist, they turned around and blamed me for the problem which I’m pretty sure it is not.

At least knowing what ballpark figures to expect, I can try to inform them yet again that there might be something they may want to look into.


#5

Whatever you did, andrewf, thanks! Connection times are back down to 5-10 ms and queries are generally under 15 ms as well. There’s still an occasional >1 second connection time, but it’s already looking better than a few hours ago.