Dev-Picayune

picayune: of little value or importance

Some Long MySQL Connection Delays

This issue has been documented before, but it took me awhile to understand what the real problem was and what my options for resolving it were.

So what happened? I had a VM (Ubuntu Hardy) chillin’ on my local dev box. That local VM was a test environment to verify the performance of a django app being hosted on a VM with Apache and mod_wsgi. And wouldn’t you know it? It was slow… very slow. As in 5 seconds per browse to display or anytime it had to hit the database. Dropping to the command-line revealed that it was the actual connecting to the mysql server (which is a separate server) that was taking most of all that time.

As it turns out, MySQL’s name lookup (reverse address resolution) was causing the slowdown. You can turn off MySQL’s reverse lookup using the “–skip-name-resolve” option. But since changing the configuration of a running MySQL server (production) is not an option, I had to figure out something else. The VM was getting a DHCP address and since our in-house (Windows-based) DNS doesn’t do well at tracking the names of DHCP’d clients that are Linux boxes, our DNS stinks at getting the name in any timely fashion. But, if you assign the client a static IP that has an official name in our DNS, voila! You have a nice, fast connection time again. A Windows box in my office, that gets assigned an IP via DHCP is fine as well, presumably because our DNS server plays well with other Windows boxes.

As I stated earlier, you can disable the name lookup but then you have to use IP addresses if you want to support security based on the connecting client’s machine. Making sure there are DNS entries for the clients seems to fix it. Again, this is mostly just for my own record if nothing else. I certainly don’t want to see this crop up again and not remember what I figured out.

No comments

No comments yet. Be the first.

Leave a reply

For spam filtering purposes, please copy the number 4132 to the field below: