GET 24/7 LIVE HELP NOW

Announcement

Announcement Module
Collapse
No announcement yet.

5 secs fixed latency on cgi/perl connect

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 5 secs fixed latency on cgi/perl connect

    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.x xx.xxx ",
    "xxxxxxx", "xxxxxx", {'PrintError' => 1,'RaiseError' => 1});
    };
    print "error: $@";

    Any help would be really appreciated!
    andrea

  • #2
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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.

        Comment


        • #5
          Thanks,

          installing Samba server has solved the problem!!!!

          Thanks again.

          Comment


          • #6
            Greate, it's always nice to know when your tips pay off. )

            Comment


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

              Comment


              • #8
                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.

                Comment


                • #9
                  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.

                  Comment


                  • #10
                    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???

                    Comment

                    Working...
                    X