« Paper: Wikipedia's Site Internals, Configuration, Code Examples and Management Issues | Main | Who can answer or analyze the image store and visit solution about alibaba.com?Thanks »
Thursday
Oct252007

Should JSPs be avoided for high scalability?

I just heard about some web sites where Velocity templates are used to render HTML instead of using JSPs and all the processing in performed in servlets. Can JSPs cause issue with scalability?

Thanks,
Unmesh

Reader Comments (5)

I have not heard of any particular problems with JSPs. As they are compiled into servlets running on an optimized application server the performance is usually sufficient. Scalability is more of an architecture issue and can be addressed with the usual load balancing and caching techniques. Those strategies work fine with JSPs. If you are including EJBs in your stack, then that doesn't scale especially well (http://www.cc.gatech.edu/classes/AY2005/cs6210_spring/papers/ejb.pdf).

December 31, 1999 | Unregistered CommenterTodd Hoff

I have seen sometimes that if you include too much logic into the jsp page using Tag Libraries, the response time increases.
So probably, Model 1 architecture is bad with respect to scalability?

December 31, 1999 | Unregistered CommenterAnonymous

That´s really true in case you are using many tag libs, because they usually generate code overhead... when you are able to go for the scriptlets, since they´re just java code that will be painlessly compiled into the generated servlet for your jsp

December 31, 1999 | Unregistered CommenterAnonymous

I don't think jsp and servlets have many serious scalability issues in the model, but there have been issues raised about the actual functionality of Servlets, amongst others its lack of support for non-blocking IO (nio). The issue with JSP's being directly tied to Servlets renders it unable to do templating for more than just web pages, like dumb console screens, code generators, etc. If you are using templating for any of these things, you might be better off just using e.g. Velocity, and don't bother with using JSP.

BTW, if you would like to see a Java framework that does things a bit differently, as well as supporting NIO, check out the http://www.restlet.org/">Restlet framework.

December 31, 1999 | Unregistered CommenterKyrre Kristiansen

Depends on how the JSPs are being used.

JSPs get compiled into classes, which get loaded into the permanent generation of the JVM. That's exactly what it sounds like... permanent. The only realistic way to remove them is to restart the JVM. If the set of all JSPs is finite, then there's no problem.

There's a common anti-pattern. however, of using JSP fragments as content (as opposed to using HTML fragments.) These JSPs get created by marketers or web designers, then deployed to the production environment via a CMS.

The problem here is that there is no limit to how many JSP fragments might be deployed. I've seen ten thousand JSP fragments in a single directory. Once a sizable fraction of these get loaded into the JVM, the permanent generation gets full and you start to see badly degenerating GC behavior, such as full collections every few seconds.

There are also serious security problems with JSPs-as-content, but since you were asking about scalability, I'll stick to the topic at hand.

Michael T. Nygard
michael@michaelnygard.com
http://www.michaelnygard.com/

Author of "Release It!"
http://pragmaticprogrammer.com/titles/mnee/index.html

December 31, 1999 | Unregistered CommenterNygard

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>