Cris,

On 4/14/21 08:03, Berneburg, Cris J. - US wrote:
cs> Your only other spec-compliant option is to use a Servlet with 
load-on-startup set
cs> and do your work in the init() method, which is ... ugly.

I was thinking of a servlet request (or something) that is called on
startup that could also be called later on-demand(?).
How would you trigger that servlet to be called on startup? Some kind of script that does catalina.sh && sleep $time && curl http://example.com/load-stuff ??

How would you determine the value of $time? What if it fails?

cs> We have a primary application at $work where we need to have a lot of 
information
cs> in memory to be able to do important stuff.  [...] We loaded 100% of it 
every time at startup.
cs> [...] I switched to loading things on-demand and it made not only a 
significant performance
cs>  improvement on startup [...] it significantly reduced the memory footprint 
of the
cs> in-memory cache of data

How were you "careful about cross-thread synchronization", synchronized blocks?

That's one way to do it. You can also use thread-safe classes which either implement their thread-safety in one of a few different ways, synchronized blocks being one of those strategies.

cs> We also have a user-initiatable process to "reload" the data

Where do you do the loading and reloading, a in a servlet request?

Yes, but the idea there was to "freshen" the data from the database if it had been altered by some other process e.g. an update from a database where new content is added, then migrated into production via direct SQL drop. So it really was a "reload" operation. These days, it's an "unload" operation. :)

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to