Quick question about Webware

Geoffrey Talvola gtalvola at nameconnector.com
Wed Apr 24 10:47:29 EDT 2002


Thomas Weholt wrote:
> When you create a servlet using WebWare is it loaded on each 
> request or is a
> instance kept in memory?
> I mean, what if the servlet uses some module or piece of code 
> that takes a
> while to load, how is this solved in WebWare?

Webware-specific questions should be directed to the webware-discuss mailing
list.  You can subscribe at
http://lists.sourceforge.net/lists/listinfo/webware-discuss .

But the answer to your question is that the module containing the servlet
code is imported only once, and a pool of servlet instances is maintained in
memory.  Instances are created and added to the pool as needed based on the
number of simultaneous requests for that servlet.  For example, if there are
currently 2 instances of a servlet in the pool, and 3 simultaneous requests
for that servlet come in, then one additional instance will be created and
added to the pool.

What does this all mean?  Basically, after the first access to a given
servlet, it runs fast :-)  Servlets are never unloaded from memory, but are
always reused.

If you have some time-consuming initialization steps, you can force them to
happen when the appserver first starts up by placing them into an
__init__.py in the same directory as your servlets.  This gets imported when
the appserver starts up.

- Geoff





More information about the Python-list mailing list