-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

André,

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="somealias.company.com">
> </Host>
> 
> and multiple requests comes in with a header
> Host: somealias.company.com
> 
> 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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrlzaIACgkQ9CaO5/Lv0PA2NwCfRJrZoLE59xxW+UYDOUrM3jBm
Lc0AnRq303TSx3+Aqro1HrUUD4xjBZzA
=jfna
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to