Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

After building my webapp on a first boot i create 2 connections to mysql on debian then 1-2 (r/w) for every page after that. The connection consistently take 5.2 seconds to connect. Debian is in a VM running in my OS. Why is the connection taking this long?

At times it will take < 0.1 seconds which is great but 5.2 x2-3 on every run is to much. Has anyone experience this problem? how do i solve it?

note: I am using .NET to connect. Not that it matters. and its mysql v5

-edit- After checking firewall settings and doing many things i could not figure the problem out. I found a noinstall release of mysql and used that. Connections are lightning fast.

share|improve this question

4 Answers 4

Obfuscurity may be right. First thing I would check is reverse DNS. To troubleshoot this try setting the --skip-name-resolve flag to mysqld:

http://dev.mysql.com/doc/refman/5.0/en/server-options.html#option_mysqld_skip-name-resolve

Also make sure to add your hostname/ip to /etc/hosts

share|improve this answer
    
We had this problem. On every connect (even if you are using IP's) the mysqld server will do a reverse lookup of your IP. If you add skip-name-resolve to the my.cnf file it will skip this. The DNS timeout is 5 seconds. –  Slashterix Oct 19 '10 at 21:43

Are you using a hostname or IP address to connect? Sounds like you might be experiencing slow DNS resolution.

share|improve this answer
    
but its... on my local comp and VM. Not even the network. I am specifying ip address and the host is win7 –  acidzombie24 May 23 '10 at 21:38

I would consider reviewing firewall setup on the host machine.

Since this is a VM, it is a possibility that the connection from the web application to the database is being examined by the Firewall or content filter running on Host machine

share|improve this answer

If you are on a debian system, I have noticed that the having the mDNS avahi daemon running can cause issues. I noticed this because I was able to do instant forward and reverse lookups via dig, but still had 5 second timeouts connecting to mysql. Looking at a packet capture, I could see 3 mDNS queries over 5 seconds before the connection succeeded. Disabling or uninstalling the avahi daemon resolved this issue for me.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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