9

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.

three-cups
  • 4,375
  • 3
  • 31
  • 41
  • One other note: running multiple servlet processes means that each process will have it's own port. Said another way, separate processes cannot share a single port. – three-cups Feb 18 '11 at 23:35
  • I think my biggest problem with Jetty is all the options it gives! Tomcat makes you go one way. Jetty seems to let you do whatever you want. – three-cups Feb 18 '11 at 23:36
  • I'm thinking of writing a generic jetty startup script that takes a port, and a list of webapp/context pairs. This seems like it would give me the most flexibility. Maybe there is already one of these scrips out there? I'm going to look at .../bin/jetty.sh in the jetty 7 distributions. – three-cups Feb 18 '11 at 23:37
  • Nobody seems to know. I can find nothing on multi-instance cpu/memory usage beyond, "set java X accordingly", or try it in x,y,z containers and see what happens. As a guess, Tomcat probably needs at least 128mb (Jetty less) per instance, but then, does each instance have its own vm? Surprised at the dearth of info on the net on jvm + X container per instance memory footprint. – virtualeyes Mar 15 '11 at 05:12

3 Answers3

2

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.

TWA
  • 12,756
  • 13
  • 56
  • 92
Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
0

I also was used to Tomcat, so in my new project I tried using Jetty to learn about it.

In an enterprise environment (where you have production / testing / development servers) I would stick to Tomcat, mainly because it helps you in getting to separate code from configuration files (now I am working in setting the conf files in a separate jar, because that way when I move changes from testing to production they do not have to manually update the jars that I'll pass to sysadmin).

Other issue is that it looks like that Jetty has changed ownership not so long ago, and looking for info often got me to the old version.

Apart from that, using Jetty is not that different from Tomcat; had to run a little through docs for finding where everything is, but structure is (as last what I have seen, I have not tried anything too complicated) more or less like Tomcat.

SJuan76
  • 24,532
  • 6
  • 47
  • 87
0

Well I think there is no direct answer;

I might not fully understand the ".deb" part as I'm not a debian freak :)

I prefer having an instance of tomcat with a number of configurations aka CATALINA_HOME folders where you may specify apps and ports running, so you can always have all your configs separately and change the tomcat instance if needed.

Also, see related post: Jetty: To embed or not to embed?

Community
  • 1
  • 1
Zilvinas
  • 5,518
  • 3
  • 26
  • 26