Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-dev] HttpClient "associate" bugs

Hi All,

I found a issue about HttpClient, as we know, before each HttpExchange
be sent, it will associate with an idle HttpConnection first, this
associate function is simple like this:

void associate(AbstractHttpConnection connection)
    {
        if (connection.getEndPoint().getLocalHost()!= null)
            _localAddress = new
Address(connection.getEndPoint().getLocalHost(),connection.getEndPoint().getLocalPort());
        _connection = connection;
        if (getStatus() == STATUS_CANCELLING)
            abort();
    }

But in one of my online service, one day, i found that It cost me
about 50 ~ 200 ms to connect to other http service if i use Jetty
HttpClient, it is unnormal, usually, it cost only 1 - 2 ms. So,
problem comes, at last, i found this associate function make this
happen.

"connection.getEndPoint().getLocalHost()" cost usually 50 ~ 200 ms, it
use function getCanonicalHostName() of Java InetAddress class. In some
cases, this function will go through DNS server to get the host name,
so its time taken is very long.

As this associate function was invoked before each http package sent
(In Jetty 7.4, this function was invoked twice one we sent a http
package), it is very important and we should keep its time taken is
short. So, why don't we  change

connection.getEndPoint().getLocalHost()

to

connection.getEndPoint().getLocalAddr()

It will works well, and will prevent this kind of problems. I do not
know whether it is a bug, but i hope you guys can fix it, thank you.

-- 
Best Regards
----------------------------------------------------
Tiger Gui [tigergui1990@xxxxxxxxx]


Back to the top