https://bz.apache.org/bugzilla/show_bug.cgi?id=65208
Bug ID: 65208
Summary: Multi-threaded loading of servlets
Product: Tomcat 9
Version: 9.0.40
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P2
Component: Catalina
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: -----
Created attachment 37788
--> https://bz.apache.org/bugzilla/attachment.cgi?id=37788&action=edit
Implementation of a context which loads servlets in parallel
I'm not sure if this is something that you would like to add to Tomcat, but for
us it made a huge difference on the startup time to have the servlets load
using multiple threads instead of single threaded.
We have a lot of dynamic jsp files in our database (sort of a CMS system). So
to avoid adding time on the first request to those files we register them as
servlets using ServletContext.addJspFile(...) to pre-compile them. But since
we have thousands of those it takes very long time to compile them using the
single threaded approach currently implemented in Tomcat. Our server has many
cores that is just idling during this time, so I wanted to put them in use.
What I did was I override the loadOnStartup method in StandardContext and added
the possibility to use Tomcat's executor service to parallelize the loading of
servlets. I don't think this breaks any rules, since the JSP spec says "The
container may choose the order of loading of servlets with the same
load-on-startup value".
So I thought I would share the code (see attached file) and some benchmarks
with you so that you can decide if this is something for you or not.
Development environment, compiling 200 jsp files:
Single threaded: 70 seconds
Using 8 CPU cores: 30 seconds
Production environment, compiling 12.000 jsp files:
Single threaded: 17 minutes
Using 96 CPU cores: 4 minutes
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]