views:

92

answers:

2

For Jetty, Tomcat, or any other servlet container of your choice, what's the average footprint (memory, and any other notable resources) of a basic servlet? This includes any other basic objects that you almost always need per servlet, such as a view resolver.

I'm not looking for a quantitative number in particular, but any indicative answer that could give an idea of how "heavy" or "lightweight" a servlet is.

Thanks in advance

+4  A: 

I don't think this is something that you're getting much benefit from asking on Stack Overflow. The variability in the definition of "basic", and the different versions of servlet software, are going to be much greater than the amount of effort required to test this yourself.

Simply create a "hello-world" type servlet that has no fields, fire up your servlet container(s) of choice with this WAR and measure memory usage. This will broadly give you the overhead of the servlet container, which you can then subtract from your actual memory measurements when seeing how "heavyweight" the target servlet is.

The numbers will be much more useful if you generate themselves using the actual target version of the servlet container on the actual system in question, than someone replying here saying "47MB" or similar.

Andrzej Doyle
+1, though I would probably add a number of the same servlet, just to get a more statistically meaningful figure. Even so, I would imagine the overhead associated with each servlet is going to be negligible compared to the overhead of the vm and servlet container libraries, native socket libraries etc.
mdma
I expect so much as well. But since Amr presumably believes otherwise, he's going to take that in more strongly if he measures it himself; people telling him something that sounds "implausible" won't have the same impact.
Andrzej Doyle
A: 

The container size is pretty irrelevant (Tomcat or Jetty, not Websphere or anything like that) unless you're doing embedded programming. The Servlet size can be as small as you need it or as large as you need it. Generally speaking, stateless web applications will have less overhead per thread than stateful ones.

Loki