tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: How can I prevent Quartz multiple execution after tomcatrestart
Date Mon, 26 Oct 2009 16:26:10 GMT
Hash: SHA1


On 10/26/2009 11:52 AM, André Warnier wrote:
> Assuming there is a single (and default) Host, like this :
> <Host name="locahost" ...>
>   <Alias name="">
> </Host>
> and multiple requests comes in with a header
> Host:
> then indeed the fact of having this Alias, would be faster than not
> having it, wouldn't it ?

In the case of a single default <Host> with no aliases, you'll get:

1 string compare in findIgnoreCase (compares requested hostname)
1 string compare in find (compares default hostname)
1 string compare in internalMap (compares default hostname to itself)

In the case of a single <Host> with the <Alias>, you'll get:

Hmm. Re-reading the code for findIgnoreCase, line 1037 is making me
frown a bit. It seems that the requested hostname is /always/ compared
to the first <Host> element. If the requested hostname is "inferior" to
the name of the first <Host>, then -1 is returned and the default host
is used.

> And in such a case, Chuck's comment that
> "Note that if you have only one <Host>, <Alias> elements are completely
> superfluous."
> would be, in fact, incorrect. Ha !

I'm still undecided until I see an explanation of the line of code above.

> We need one of these nice graphs showing the respective gains here..
> Don't you feel tempted ?

No, but I'll happily look at your graph once completed ;)

> About your optimisation suggestions, I see another possible one :
> If this is a keep-alive connection, then the same Tomcat thread will
> handle subsequent browser requests over that same connection.

There's a check for an existing previously-chosen host at the top of
internalMap. I suspect that this is already handled once the first of
several keep-alive requests is handled.

> As far as I know, there isn't really a case where a browser will issue
> multiple requests over the same connection, if not addressed to the same
> Host.

It would certainly break a lot of clients and servers if the above
weren't true: there would be no guarantee that all the "Host" headers
would resolve to the same IP address, so the connection might be
invalid. On the other hand, issuing a different Host in the middle of a
series of keep-alive requests might actually confuse certain components
of the server if they all expect the Host to remain constant.

> So the thread could also cache a pointer to the Host entry
> obtained in the first request of the connection, and re-use it without
> lookup for subsequent requests over the same connection.

Yeah, I think this is already being done. See above.

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message