Java Servlets: Performance

ajax, java, servlets

Solution

There is no performance reason to have more than one servlet. In a web application, only a single instance of a servlet class is instantitated, no matter how many requests. Requests are not serialized, they are handled concurrently, hence the need for your servlet to be thread safe.

Problem

I am working on a web application in Java which gets data from servlets via AJAX calls. This application features several page elements which get new data from the server at fairly rapid intervals. With a lot of users, the demand on the server has a potential to get fairly high, so I am curious: Which approach offers the best performance: Many servlets (one for each type of data request)? Or: a single servlet that can handle all of the requests?

Original source