Details
-
Type:
Improvement
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 6.0.0
-
Fix Version/s: 6.1.2rc1
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
I've noticed that for each HashSessionManager that's created – and Jetty seems to create one per web app context – Jetty takes a thread out of the thread pool and blocks that thread to do periodic session cleanup. So, we end up creating a thread per web app context, and each such thread spends most of its time sleeping.
It'd be a lot more scalable if Jetty used a timer for this, so that there can be one thread per Jetty server that is doing the cleanup for lots of web apps. That way, we have fewer threads. Furthermore, this way the thread pool remains to be used for short-running tasks, which is what thread pools are good for, rather than for one task that typically lasts for the lifetime of the web app.
I was able to add this feature pretty easily to "trunk" by adding a "TimerManager" interface to org.mortbay.thread, and an implementation that uses the java.util.Timer class. Then, it was a pretty small change to AbstractSessionManager to get it to use this, and it also meant that a bunch of complex code could be eliminated from that class. I'll attach the patch.
The downside of what I did is that it uses java.util.Timer, which I believe may not be available on all editions of Java (such as Java ME). If that's an issue, I'm sure we can come up with a timer implementation that does not require this class from the JVM.
The JAR that I attached includes three new classes for the "org.mortbay.thread" package, plus patches for AbstractSessionManager and Server to use them.
probably a good idea.... but I think I will defer for a few weeks.
The solution must work on 1.4 - but a pluggable 1.5 solution would be good.
There are quiet a few things that need this timer behaviour, so I would want a solution that
could be used for sessions, rollover logs, etc, etc.
So thanks for the patch.... ping me if I have not commented on it in 2 weeks.