• Post Reply Bookmark Topic Watch Topic
  • New Topic

Optimum number of servlets in an application  RSS feed

 
Prantik Biswas
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't get the chance to go through previous posts so please bear with me if this has been asked before.

I just wanted to know how does increasing the number of servlets in a web app influence the performance of the web container. What would constitute a good design practice when it comes to deciding the number of servlets in your app.

thanks in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
143
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would constitute a good design practice when it comes to deciding the number of servlets in your app.


As many as it needs.

Yeah, I know that's about as helpful as "you must cook it until it is done", but it's the correct answer.

You should be more mindful of what makes the most sense to the clarity and structure of the application.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How much gas do I need for a car?
 
Prantik Biswas
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for replying...

Given a situation where the app could be designed using a controller servlet with say 50 helper classes or 50 individual servlets. Which one would be more preferable and why?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
143
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, it depends upon your application structure.

Personally, I use a Front Controller servlet that handles most incoming requests and delegates processing to many action/helper classes. That makes sense for me as I've written a light-weight framework that makes setting up such a scenario very easy, and it keeps the web.xml file smaller.

As such, most of my web apps have only a handful of servlets as that makes the most sense for the way I've structured my apps.

But I in no way claim that that's what's best for all apps. Again, it depends how you want to structure the application.

Note: asking "should I use the Front Controller Pattern?" is a distinctly different question from "how may servlets should I have?"
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just wanted to know how does increasing the number of servlets in a web app influence the performance of the web container.

I can't think that the number of servlets has much effect at all during normal running. Having a large number might mean that initial server startup is a tiny bit slower but thats about it.
Strive for clarity of design. If you are worried about performance, make use of one of the many tools for measuring your real application.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!