I'm using
Tomcat 4.1.12 on a Win2K server to host a
servlet which uses
JNI to call a DLL. I would like to run multiple instances of this
servlet calling separate instances of the DLL. That part is no problem
simply by giving each instance a unique name (both servlet class and
DLL). However, I'd like to run each instance in its own process space
because of the memory requirements of the DLL. The DLL gets initialized
to a certain data set and then subsequent queries use that data. The
initialization takes considerable time and memory, so we hold initialized
instances in memory for later queries instead of re-initializing on each
call. Because the memory required by an initialized DLL, we need to put
them in separate process spaces.
So far, the only way I've found to do this is to run multiple
instances of Tomcat. That's simple enough using the CATALINA_BASE
setting and launching multiple copies of the server. However, it would
be simpler if I could run one instance of Tomcat and designate certain
parts of it to run out of process, say at the context, host, or engine
level.
Is it possible to set a context within the Tomcat server to run in its
own process space?
It's been suggested that what we're doing isn't suitable for servlets
and we need another architecture. That may be the answer, and it would
certainly be possible to use a wrapper to initialize these DLLs as separate
applications which accepted remote calls. The only reason we've been using
servlets is to take advantage of the HTTP query processing already provided
by the server without rebuilding that part in a customer listener, but now
that we're hitting the wall in memory requirements, we may have to move
to a different architecture to separate our DLL processes. I'm open to
suggestion on what a new architecture should look like if the answer to the
servlet question is a simple "you can't".