Home » Performance » MySQL » 5 secs fixed latency on cgi/perl connect
icon9.gif  5 secs fixed latency on cgi/perl connect [message #1380] Fri, 08 June 2007 07:29 Go to next message
ready2fly  is currently offline ready2fly
Messages: 3
Registered: June 2007
Junior Member
Hi,

we are experiencing a 5 seconds latency while connecting to a mySQL server DB (windows) through a perl script running on an apache server (linux).

Both www and db server are almost in idle status and they are connected throug a switched gb lan and are on the same subnet.

Addressing between the two is based on IPs to avoid dns resolution latency.

We get same delay using php directly.
We tryed to connect to different DBs but we always receive 5 secs of delay.
We get no errors in connection, just delay.

Here is the script we are using:

#! /usr/bin/perl -w

print "Content-Type: text/plain\n\n";

# Connect to the database.
eval {
require DBI;
my $dbh = DBI->connect("DBI:mysql:database=xxxxxxx;host=xxx.xxx.xxx.xxx ",
"xxxxxxx", "xxxxxx", {'PrintError' => 1,'RaiseError' => 1});
};
print "error: $@";

Any help would be really appreciated!
andrea
Re: 5 secs fixed latency on cgi/perl connect [message #1384 is a reply to message #1380 ] Fri, 08 June 2007 16:55 Go to previous messageGo to next message
sterin  is currently offline sterin
Messages: 324
Registered: March 2007
Location: Sweden
Senior Member
Is there some relevant reason why you are running the MySQL DBMS on Windows instead of Linux like with your web server?

And do you have a firewall between the DB and the Apache server?

The reason why I'm asking is that I have many times noticed that Windows does some fishy stuff in the background to try to establish credentials of the host it is connecting to/from by connecting to TCP ports 445 and 139.

So if you are dropping packets to these ports in the firewall or something like that you can get similar effects.

It could be something like this that causes what you are experiencing now.

My best suggestion is that you use Linux as DB server also.

[Updated on: Fri, 08 June 2007 16:56]

Re: 5 secs fixed latency on cgi/perl connect [message #1386 is a reply to message #1384 ] Fri, 08 June 2007 17:09 Go to previous messageGo to next message
ready2fly  is currently offline ready2fly
Messages: 3
Registered: June 2007
Junior Member
We are running our application in hosting through our ISP.......
If it was for me: Unix forever....

Anyway www and DB are both in the same subnet in DMZ, no firewall between them.

The DNS in properly configured and works fine.

We obtain this delay (always 5 secs) only in connect, every subsequent operation works fine.
Re: 5 secs fixed latency on cgi/perl connect [message #1392 is a reply to message #1380 ] Sat, 09 June 2007 05:11 Go to previous messageGo to next message
sterin  is currently offline sterin
Messages: 324
Registered: March 2007
Location: Sweden
Senior Member
Yes and that could be the Windows credential check.

Because whenever a windows server receives a new TCP connection it tries to authenticate the other server.
So it starts with trying to connect to the other server and in the end if the other server is not answering it continues anyway.

I read about someone that solved it by installaing Samba on the Linux server which means that the windows credential check actually gets a response.

Best tip I can give.
Re: 5 secs fixed latency on cgi/perl connect [message #1396 is a reply to message #1380 ] Mon, 11 June 2007 10:10 Go to previous messageGo to next message
ready2fly  is currently offline ready2fly
Messages: 3
Registered: June 2007
Junior Member
Thanks,

installing Samba server has solved the problem!!!!

Thanks again.
Re: 5 secs fixed latency on cgi/perl connect [message #1397 is a reply to message #1380 ] Mon, 11 June 2007 10:27 Go to previous messageGo to next message
sterin  is currently offline sterin
Messages: 324
Registered: March 2007
Location: Sweden
Senior Member
Greate, it's always nice to know when your tips pay off. Smile
Re: 5 secs fixed latency on cgi/perl connect [message #2623 is a reply to message #1380 ] Wed, 13 February 2008 15:16 Go to previous messageGo to next message
nateh  is currently offline nateh
Messages: 2
Registered: February 2008
Junior Member
Another possible solution:
In your my.ini:
skip-name-resolve
Re: 5 secs fixed latency on cgi/perl connect [message #2624 is a reply to message #2623 ] Wed, 13 February 2008 15:33 Go to previous messageGo to next message
sterin  is currently offline sterin
Messages: 324
Registered: March 2007
Location: Sweden
Senior Member
nateh wrote on Wed, 13 February 2008 21:16

Another possible solution:
In your my.ini:
skip-name-resolve

Except that that has absolutely nothing to do to this specific problem since this was about windows checking credentials and not a DNS issue.

And even if you do want to tinker with that setting I would say that you can leave name resolve on.
Because usually you only have very few hosts (couple of web servers for example) that connect to the DB and then all these hosts will be available in the host_cache in mysql, which means that the performance impact is marginal at best. And that means that you might as well keep it.

Unless you have really screwed up your DNS settings and then I think you should fix the DNS settings instead.
Re: 5 secs fixed latency on cgi/perl connect [message #2625 is a reply to message #2624 ] Wed, 13 February 2008 16:33 Go to previous messageGo to next message
nateh  is currently offline nateh
Messages: 2
Registered: February 2008
Junior Member
Whoa - why so hostile?

I beg to differ - I experienced similar symptoms in a similar configuration as the original poster. (5-6 second delay while connecting from a Linux client to a Windows server)

In my installation, the Windows MySQL server first tried to use NetBIOS to figure out the name of the client, and it took about 5 seconds to fail. I watched this process by using Ethereal to capture the packets as the client connected to the server.

I also verified that it was a server, not a client issue by making a simple "netcat" connection to the mysql host like so:
time echo "" | nc my-mysql-host 3306 >/dev/null

After setting skip-name-resolve the server no longer attempts the NetBIOS lookup. Just to double check, I commented the option out, restarted MySQL, and the problem came right back.
Re: 5 secs fixed latency on cgi/perl connect [message #2629 is a reply to message #2625 ] Thu, 14 February 2008 00:30 Go to previous message
sterin  is currently offline sterin
Messages: 324
Registered: March 2007
Location: Sweden
Senior Member
nateh wrote on Wed, 13 February 2008 22:33

Whoa - why so hostile?


Sorry, when I reread my post I realized that it sounded very hard and that was not my intention! Written very fast is the only excuse that I can give (I know it's not a good one).

I'm curious. When you experienced these problems:
How was your DNS setup on the server?
And did you have a PTR record for the web server IP in your reverse domain???
Previous Topic:MySQL
Next Topic:Mysql Data on GC-Ramdisk
Goto Forum:
  


Current Time: Thu Jul 9 15:38:34 EDT 2009

Total time taken to generate the page: 0.01531 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.