Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Servlet Deployment - To Embed or Not - Tomcat/Jetty

I have several webapps deployed to production. I have used Tomcat as my servlet engine for ~10 years now. I'm considering moving to embedding Jetty model from the deploy-a-war-into-Tomcat model.

These webapps are deployed over several servers and some of the are horizontally scaled (using nginx IP hash based partitioning).

I see some advantages:

  • I can configure my servlet engine for a particular webapp (instead of having a generic configuration for Tomcat which is running several different webapps)

  • It's easier to horizontally scale my webapp by running multiple Jetty instances (configured to listen on different ports) on the same host. I could also do this with Tomcat (and I have run multiple tomcat instance on the same host in the past), but I've moved to using Debian packages (.deb archives) for deployment and it's not as easy to run multiple Tomcats using this method.

  • My deployment package (.deb) is more "complete" at build time i.e. I don't have to be sure the Tomcat instance is configured correctly.

And disadvantages:

  • More instances of a servlet engine running on a server means more resources being used

  • I've never used Jetty. I don't think I have any Tomcat-specific stuff going on in my webapps, but I'm not sure.

My main concern is the amount of resources that Jetty will use. If I had one Tomcat instance running 4 webapps, what will the difference in resources (memory/processor) be with four Jetty instances running?

This question is probably too open-ended, but I'm curious to know if I'm overlooking something or if anybody has any experience moving from Tomcat to (embedded) Jetty.

like image 656
three-cups Avatar asked Feb 18 '11 16:02

three-cups


1 Answers

The web container I've found easiest to embed in a jar file (and it is still a valid WAR too) is Winstone (http://winstone.sourceforge.net/).

Jenkins - http://jenkins-ci.org/ - use this container so it has been pretty stress-tested. Note that it is Servlet 2.4 only.

like image 161
Thorbjørn Ravn Andersen Avatar answered Oct 14 '22 22:10

Thorbjørn Ravn Andersen