Tuesday, November 15, 2005

What does Pooling means with respect to servlets?

Servlets are multi-threaded. You only need one instance to service all of your requests because each request is handled in a separate thread.

With servlets that implement SingleThreadedModel, on the other hand, a new instance is created for each request. At the end of that request, the instance is destroyed. This creates a lot of overhead and slows down the request/response cycle. To alleviate(make easier) this problem the makers of many servlet engines decided to pool(combine, add together) and recycle a number of instances, much in the same way that database connection pools do with database connections.

Since the SingleThreadedModel has been deprecated, it makes no sense to start using them now. They are still supported for for the sake of older apps that rely on them and developers should understand how they should work if they ever run into them while working on an existing application.


Post a Comment

<< Home