Tomcat, Precompile JSP Pages

B

boanator

I have a website that consists of almost 200 JSP Pages. The server
hosting this site is running Tomcat. When Tomcat starts up, it kicks
off a servlet that will precompile all of the JSP pages. This servlet
pings every single JSP page in the website. When the JSP page is
pinged, it is forced to compile. It takes nearly 2 hours to compile
all of the JSP pages using this servlet. The server is a solaris 8
machine with a 333 MHz Processor and 128 Mb of RAM.

Here are my questions:
1) Should compiling 200 JSP Pages take 2 hours on this machine?
(If not, then the time is being spent trying to run each JSP page
after it is compiled.)
2) Is the server machine too slow?
3) Is there another way to precompile JSP Pages without pinging them?

Any advice would be appreciated. Thanks in advance.
 
D

Daniel Dyer

I have a website that consists of almost 200 JSP Pages. The server
hosting this site is running Tomcat. When Tomcat starts up, it kicks
off a servlet that will precompile all of the JSP pages. This servlet
pings every single JSP page in the website. When the JSP page is
pinged, it is forced to compile. It takes nearly 2 hours to compile
all of the JSP pages using this servlet. The server is a solaris 8
machine with a 333 MHz Processor and 128 Mb of RAM.

Here are my questions:
1) Should compiling 200 JSP Pages take 2 hours on this machine?
(If not, then the time is being spent trying to run each JSP page
after it is compiled.)
2) Is the server machine too slow?
3) Is there another way to precompile JSP Pages without pinging them?

Any advice would be appreciated. Thanks in advance.

I believe Tomcat includes an Ant task for pre-compilation of JSPs.

Alternatively, it might be worth investigating using Jikes for the
compliation (if you are not using Java 5 features). I've used it in the
past (a couple of years ago) with JBoss/Tomcat to speed up JSP compilation
considerably.

I also found this with a quick search on Google:

http://codinginparadise.org/weblog/2005/01/tomcat-jsp-precompilation-is-slow.html

Dan.
 
A

Andrea Desole

I have a website that consists of almost 200 JSP Pages. The server
hosting this site is running Tomcat. When Tomcat starts up, it kicks
off a servlet that will precompile all of the JSP pages. This servlet
pings every single JSP page in the website. When the JSP page is
pinged, it is forced to compile. It takes nearly 2 hours to compile
all of the JSP pages using this servlet. The server is a solaris 8
machine with a 333 MHz Processor and 128 Mb of RAM.

Here are my questions:
1) Should compiling 200 JSP Pages take 2 hours on this machine?
(If not, then the time is being spent trying to run each JSP page
after it is compiled.)

mmmm.... 200 pages in 2 hours is 36 seconds per page. It looks a bit
slow, but it's possible. It also depends on how complex your pages are.
After all, your machine is not really the fastest possible
2) Is the server machine too slow?

that depends on what you have to do. If you use it at home, no. If you
use it to host the site of a big company with 10000 users a day, yes

3) Is there another way to precompile JSP Pages without pinging them?

Ant used to have a jspc task, which was using Tomcat's compiler. I
undesrtand from the documentation that you should use the specific task
that comes with Tomcat, if you are using a newer version.
Anyway, jspc is probably your answer
 
T

Tor Iver Wilhelmsen

I have a website that consists of almost 200 JSP Pages. The server
hosting this site is running Tomcat. When Tomcat starts up, it kicks
off a servlet that will precompile all of the JSP pages. This servlet
pings every single JSP page in the website.

That's not the way to do a precompile - since you also trigger all the
business logic like session management etc.

Either predeclare the JSPs as servlets with load-on-startup in
web.xml, or Tomcat's JSP compilation Ant task.
 
T

Thomas Hawtin

I have a website that consists of almost 200 JSP Pages. The server
hosting this site is running Tomcat. When Tomcat starts up, it kicks
off a servlet that will precompile all of the JSP pages. This servlet
pings every single JSP page in the website. When the JSP page is
pinged, it is forced to compile. It takes nearly 2 hours to compile
all of the JSP pages using this servlet. The server is a solaris 8
machine with a 333 MHz Processor and 128 Mb of RAM.

Clearly something wrong. Are you sure it's a CPU problem? Is it
swapping? Or is it garbage collecting too much (use -Xms -Xmx to
increase heap size)?

Perhaps better than a servlet, but without precompiling, is to generate
a web.xml that loads all JSPs on start up. No need for anything fancy.
Even find and sed could do the generation.

Tom Hawtin
 
R

Roedy Green

off a servlet that will precompile all of the JSP pages.

Does it do this even if the JSP pages have not changed?

I have not used Tomcat, but that behaviour seems unreasonable.

Has something changed which is legitimately triggering this orgy of
recompilation?

Are you clearing Tomcat's cache of java and class files forcing this
behaviour?

Compilation is slow because Javac needs a ton of ram. Perhaps you can
buy a bit more for your beast to max it out.

I noticed that Ant-style compilation which loads a JVM once is much
much faster than invoking Javac for each batch. Perhaps Tomcat has a
option to use Ant-style compilation.
 
T

Thomas Hawtin

Roedy said:
Compilation is slow because Javac needs a ton of ram. Perhaps you can
buy a bit more for your beast to max it out.

Recent version of Tomcat use the Eclipse JDT compiler by default.
I noticed that Ant-style compilation which loads a JVM once is much
much faster than invoking Javac for each batch. Perhaps Tomcat has a
option to use Ant-style compilation.

Last time I looked Tomcat's compiler configuration was "in an unfinished
state".

Tom Hawtin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top