GlassFish team member. Alexis has posted 2 posts at DZone. View Full User Profile

Tomcat Today, GlassFish Tomorrow?

07.03.2008
| 108897 views |
  • submit to reddit

While there are indeed several advantages to using GlassFish vs. Tomcat, it's probably useful to know that Sun is the original creator of Tomcat and that any application running today on Tomcat should run just fine (no modification whatsoever) on GlassFish.

Grizzly

Historically, if you wanted to get good HTTP performance from Tomcat you really needed to have a the Apache web server to sit in front of Tomcat which involved more setting up and extra administrative work. Since GlassFish v1 (May 2006), Grizzly is the HTTP frontend of the application server. It's a 100% Java nio framework that provides the same performance as Apache only it's written in Java and integrated straight into the application server. While using Apache or Sun Web Server in front of GlassFish is quite possible, it's certainly no longer needed for performance reasons. Grizzly is also used for other protocols such as IIOP and now SIP (project Sailfin). Finally, Grizzly is the key technology for implementing Comet (aka Reverse Ajax, aka Ajax Push) which enables so very interesting push scenarios (from server to clients).

Full Java EE 5 support

Support for Java EE 5 (and soon Java EE 6) has always been a key priority for the GlassFish project. It delivered its first Java EE 5- certified implementation more than two years ago. This allowed developers to enjoy the much simplified EJB 3.0 specification, JAX-WS, and more goodness early on but it also provided dependency injection in the web tier (in servlet or JSF managed beans). Tomcat is not a full blown application server so while it may be enough for some developments, many companies find themselves maintaining a stack of frameworks and libraries on top of Tomcat when a GlassFish provides a JPA persistence engine (Toplink), a full web services stack (Metro), an application model (EJB3), and more, all out of the box. Java EE 6 profiles should help improve that situation for the industry as a whole.

Admin Tools

Administration and monitoring tools is what GlassFish users coming from Tomcat get as an immediate benefit. From web tools to command- line tools, GlassFish has an extensive set of features ranging from application (un)deployment, to JNDI resource creation, to all sorts of configuration details. All is JMX-based, exposed using MBeans (called AMX) and usable from JMX tools such as JConsole or the new VisualVM (specific plugin for GlassFish there). GlassFish also provides a fully- integrated monitoring feature called Call-Flow which reveals very accurately where time is being spent in the application before a response is sent. GlassFish also comes with a self-monitoring framework capable of implementing administrative rules such as the addition of a new node to a cluster if the average response time goes beyond a certain threshold.

Documentation

Technical information for GlassFish comes in various forms complementing one another quite well. The official documentation is extensive and complete (20+ books, from Developer's Guide to Deployment Planning Guide). There's also the Java EE tutorial, Enterprise Tech Tips, GlassFish user FAQs, blogs from engineers, forums and mailing lists.

Clustering

Full clustering is built right into GlassFish with no need to move to some other codebase or for-pay version of the product. In fact, you can even upgrade from a "developer" profile to a "cluster" profile. Clustering in GlassFish means the grouping technology (heartbeats, centralized admin), the load-balancing, but also the stateful data in- memory replication. Project Shoal is the GlassFish sub-project that does the heavy-lifting for most of these features. It uses JXTA under the covers which has the nice side-effect or requiring little to no configuration. GlassFish clustering make no assumption about the load- balancing technology used - it provides Web Server plugins but also works with hardware load-balancers. Such load-balancers do not need to know where the replicas are. Finally, Sun also offers a 99.999% solution with an in-memory distributed database (HADB). It has greater performance degradation, but probably unmatched availability.

Performance

Sun has literally worked for years on the performance of GlassFish - Grizzly, EJB container, Servlet container, Web Services, OpenMQ implementation, etc... The best result of this has been the SPECjAppServer world record published late last year and putting GlassFish in first place ahead of Weblogic and WebSphere (Tomcat isn't a full app server and thus isn't listed there, while JBoss has never published results). This is the first time one could claim that you no longer need to choose between open source and performance, you can have both. Performance is a strong priority for Sun.

Support from Sun

GlassFish is free and open source (dual CDDL + GPLv2 license), but Sun also has a business strategy to monetize GlassFish thru services. One such service is the subscription that covers access to patches and interim releases, access to support and escalation of bugs as well as indemnification. Sun also recently announced the GlassFish and MySQL unlimited offering (see http://www.sun.com/aboutsun/pr/2008-06/sunflash.20080627.1.xml) .

Tooling

While the NetBeans/GlassFish integration is very good, there is clearly no "NetBeans prerequisite" to use GlassFish. In fact Sun is the main developer of an open source plugin for Eclipse WTP to use GlassFish v2 and even v3. Both NetBeans and Eclipse users can get the plugin right from the IDE (for Eclipse, it's a WTP plugin for Eclipse 3.3 or 3.4). There is also support for GlassFish in IntelliJ and Oracle has announced support in JDeveloper.

 

Tomcat, GlassFish v3

GlassFish has made a lot of efforts to appeal to developers. Its a single, small download of about 60MB, has auto-deploy capabilities, starts pretty fast for an application server with GlassFish v2 (probably the best full-blown application server startup time). To be fair to Tomcat or Jetty, they are still perceived by many as lighter- weight and faster to start. GlassFish v3 is all about being modular (based on OSGi), extensible and very developer friendly. The recently released TP2 (Tech Preview 2) starts in less than a second, starts/ stops containers and resources as needed and provides support for scripting technologies such as Rails, Groovy, PHP and more. There is also an Embedded mode for GlassFish which enables developers to use GlassFish via an API for testing or embeddability purposes. GlassFish v3 is scheduled to be aligned with Java EE 6 and released mid-2009. In the mean time there will be regular refreshes.



 

Published at DZone with permission of its author, Alexis MP.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Lukas Zapletal replied on Thu, 2008/07/03 - 4:26am

No disadvantages? Strange... Anyway nice review of new features.

eduardo pelegri... replied on Thu, 2008/07/03 - 5:10am

Small clarification - the original contributors to Tomcat included also the JServ group.  The project was lead by James Duncan Davidson, at Sun.  Wikipedia seems to have a reasonable account of the history.  The early JSP and Servlet specs also had historical background, even going back before Tomcat.  - eduard/o

Dmitry Namiot replied on Thu, 2008/07/03 - 7:04am

Do you know any hosting with GlassFish?

Cody A_ replied on Thu, 2008/07/03 - 7:57am

Any comments on comparing Glassfish vs. JBoss AS ??? I.E. Clustering support, (amt. of config), ease of config for lb, performance, etc...?

David Heffelfinger replied on Thu, 2008/07/03 - 8:19am in response to: Dmitry Namiot

eApps (http://www.eapps.com) offers GlassFish hosting.

Matthew Schmidt replied on Thu, 2008/07/03 - 9:13am

For those thinking about using GlassFish, DZone has an upcoming Refcard on GlassFish scheduled for July 14th.  Subscribe to the RSS feed to get notice of the release.

Steven Baker replied on Thu, 2008/07/03 - 5:04pm

tomcat > glassfish

nuf said

Will Hartung replied on Thu, 2008/07/03 - 6:40pm in response to: Lukas Zapletal

Initial memory footprint, mostly. Complexity, perhaps, but if you want to compare oranges to oranges, I don't think that GF is any more complex than Tomcat if you stick to Tomcats feature set as a subset of GF features. Internally it's more complicated, but operationally, I don't think so.

GF starts off larger than Tomcat out of the box. For those trying to "stay small", it can be an issue. For a larger deployment, I don't think it really matters.

We'll see how v3 affects this, as it will be more modular. GF is pretty much already lazy loading everything, so it's not that you (quite) pay for stuff you don't use, but it is a bigger system than Tomcat.

It would be interesting to compare start up of a GF instance vs a Tomcat instance, particularly one where you remove the admin console from GF. The console no doubt has some impact, even if you don't use it.

You don't need the console to run GF, though it is one of its shining features -- it's really pretty good. But you can use the command line and do most everything on a running GF instance, and it doesn't need the console GUI webapp installed for that to work.

Also, GF has the other EJB services running, and those will have their impact above what Tomcat installs out of the box.

So, what I don't know is how much bigger would GF be if you managed to remove services to bring it down to Tomcats level. But even then, I think the minimum Tomcat would be smaller than the minimum Glassfish.

I will say, as a plain ol servlet container, if you configure your server via editing XML files, I don't think there's a real difference between the two. If you go via the GUI web console, the GF console is tops and does a good job of presenting everything you need, so I think out of the crate GF is "easier to use" than Tomcat. Tomcat has a console, but it's really a second class citizen in the project and the community.

Peformance wise, I think the two teams play against each other, and any given day one or the other might be on top, but never really more than a couple of points either way of difference. Jean Francois is doing really fine work on Grizzly (which also works in Tomcat), and keeps on top of the NIO and Comet stuff.

Seriously, I think it's a matter of taste in a reasonable deployment between the two.

GFs main benefit is that you have the rest of the JEE stack there ready and waiting should you ever want it.

Adding a JMS queue, and an MDB, for example, to an existing servlet spec only system is maybe a 15-30 minute process with the GF container. I think it would be much more with Tomcat as you hunt down and assemble the component parts.

 

Kenneth Mark replied on Thu, 2008/07/03 - 9:43pm

Nice review but I would also suggest this article from TheServerSide: Scaling Your Java EE Applications

Varun Nischal replied on Sat, 2008/07/05 - 2:22am

Hi Alexis,

Nice article, I am new to this area, I mean Java EE! I have no prior experience working with these servers. Though, few days back, I started working with few Web Frameworks, executed some tutorials (basic Web Applications) on JSF and Struts using NetBeans 6.1! I deployed both the projects once by Glassfish V2 and then, by Tomcat Apache..

I found out, Tomcat deployed the Web Application faster than Glassfish. My system became too slow when Glassfish was running, esp. NetBeans, it was looking like it might hang any moment..

Any suggestions on how to improve performance, or I missed some tips and tricks for performance enhancement?

Thanks!

Remigijus Bauzys replied on Sun, 2008/07/06 - 4:37am

I'm started to use glassfish more than 1,5 years ago. It's been very stable and I had no issues sine then, I and my team are very happy with it. I had no doubt about using it, if I had requirement for EJB. Nether less sometime I use glassfish to host applications what does not require Application Server functionality.

Based on what I said before and knowing that Tomcat is just a Servlet Container real questions are:

 

  • Can I use grizzly without glassfish just for http communications?
  • Does grizzly is deeply integrated into glassfish, and can it be reused in other projects, maybe tomcat itself?
  • Does glassfish v3 (together with grizzly and servlet container) can be packaged as separate small install package for little web aplications, and in case if it can would I be able to use these nice administration tools? 

 

 

John Clingan replied on Wed, 2008/07/09 - 4:05pm in response to: Remigijus Bauzys

For the first two bullets, yes. Please visit the Grizzly project page: https://grizzly.dev.java.net/. I recommend you post questions to the Grizzly User's alias: https://grizzly.dev.java.net/servlets/ProjectMailingListList

For the last bullet, sure, no reason why you wouldn't be able to, although you may want to engage the community alias on module dependencies to see what you can remove and how to go about what you want to do in more detail. You can also embed GlassFish v3:

https://embedded-glassfish.dev.java.net/
http://weblogs.java.net/blog/kohsuke/archive/2008/04/glassfish_v3_ju.html

 

John Clingan
GlassFish Product Line Manager

Romualdo Rubens... replied on Wed, 2008/07/16 - 1:09pm

Hi guys,

Ok, now GF is the best choice over Tomcat (TC) with Apache (AP), but and what about a lot PHP apps running on AP ???

So, that's my doubt: is GF able to run PHP apps while serving Java (Web) apps as with AP (PHP) with TC (Java) ???

My best regards.

Cody A_ replied on Mon, 2008/09/15 - 11:59am

Does anyone have information regarding whether the functionality of Grizzly is possible using Sub Web Server? (e.g. is Sun Web Server blocking?)

 I cannot find much info on this.

 Please let me know...

sal man replied on Sun, 2009/09/06 - 10:58am

I think Tomcat Web Application faster than Glassfish. Glassfish can make hang during running when NetBeans, it can be hang any time. http://java.dzone.com/articles/glassfish-and-tomcat-whats-the

Hareton Hunter replied on Mon, 2011/03/21 - 7:37am

When I first read the title of the post, I asked myself many questions like: what is the difference between Tomcat and GlassFish? What is the difference between WebLogic and GlassFish? How to migrate from WebLogic to GlassFish? How to use GlassFish from Eclipse? Tastes differ, but I think that it's wonderful that we can choose. I'm a Java programmer and I use both Tomcat & Weblogic and GlassFish for my web applications. And I know that the future is for popular, powerful, stable, secure and user friendly webservices, web applicationas and technologies. It's my opinion. So the stronger will survive.

Felicity Span replied on Mon, 2011/05/16 - 11:25am

Awesome post. Very informative. 

Kalaman Manji replied on Wed, 2011/07/27 - 12:54pm in response to: Dmitry Namiot

Did you find out any hosting that provide GlassFish ? If no I can help you.

 Regards, Manji @ Email Sender

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.