tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Costin Manolache <>
Subject Re: Multi-homing/Virtual named hosts
Date Sat, 01 Apr 2000 06:19:57 GMT
There are 3 steps for implementing virtual hosts:
- change the configuration ( server.xml ) and find an intuitive way to specify
virtual hosts ( maybe similar with other servers).

- add a property to Context ( host for example ) and make sure we set it at

- change SimpleMapper to take into account the host property - that's the only
difficult part and the main reason we don't have it.
The problem with SimpleMapper is that it's very... complex ( and is the result
of a long evolution and many fixes ). I would rather start a new mapper.

The mapper needs to:
- define an efficient data structure. The most frequent operation is match by
prefix and vhost, then match by extension. Probably a tree or something
- implement an efficient alghoritm - with a lot of care in parsing ( avoid
string duplicates, etc)
- receive notification when a context is added and change it's internal
structure, etc

You can also try to play with SimpleMapper, it shouldn't be difficult to hack
it, but I would rather spend the time writing a new one. There is a lot of
theory about how to do efficient matching, and that is probably the most
expensive operation in tomcat ( or any other server ).

As a note, the API makes the parsing to be a 2 step process - you first need to
extract the context and then use the context config to parse the rest of the
request. It doesn't have to be implemented that way - it will be much faster to
do the full parsing in first step.

I think this is one of the most important aspects of the current tomcat design
- we want to be able to be fast and reduce the overhead by using a smart
alghortim, and the interceptor allows that - you'll have access to all the
mappings and you can construct a global structure ( or partition it by anything
- you have control ).

Please don't try to partition the problem by adding a VirtualHost object and
finding the host and then the context and so on. IMHO it's a bad alghoritm, and
doesn't fit the current model. I don't know how said it, but optimization means
choosing the right alghoritms and structures.


Richard Vowles wrote:

> Hi all,
> I have just joined this list so I don't know if this is a FAQ question, but
> have there been any thoughts on how to implement multi-homing? My initial
> belief after reviewing the source code and the XML files is that the server
> name(s) need to be added as a "primary key" on the <Context> element in the
> server.xml - and recognised as such in the code. This would mean that there
> could be two (or more!) contexts with a path = "", in which case the server
> name is matched (in fact the server name should always be matched, probably
> with comma seperated wildcard capability).
> I know it isn't in the release plans for the current version but I need it
> and I'm happy to implement it for inclusion in a later release version (if
> someone else isn't already), but I would like to maintain adherence to the
> overall structure of how it is intended to be done...
> Richard
> ---
> Richard Vowles, Infrastructure Architect, Inprise New Zealand
> home-email: ", work-email: ""
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message