ets-berkeley-edu/calcentral — pull request #2089 by ctweney (2014-02-06 18:14:29+00:00)
Title: CLC-3197 Part 2: Smarter DelayedCacheCleaner impl, plus more proxies refactored

https://jira.ets.berkeley.edu/jira/browse/CLC-3197

I found that TorqueBox::ScheduledJob was inappropriate for the DelayedCacheCleaner, because it spun up an entirely new Ruby app instance for every deletion.

I rewrote DelayedCacheCleaner as a TorqueBox message processor. On receipt of a message it starts a new thread that sleeps for the specified delay, then deletes the cache key.

To minimize thread overhead I've enabled jruby thread pooling when starting Torquebox.

I tested this on my laptop with 10K cache deletions, and the thread count increased to 1000 then gradually backed down to ~200 (a normal level) as Jruby figured out how to reuse the sleeping threads. CPU usage was 65% or less throughout this test, so I'm satisfied that it should work in production, even under load-test conditions.

This pull also includes refactorings of the CalLink and Bearfacts proxies to use the generic exception handling (and associated delayed-cache deletion).