Open Sourcing Centrifuge — Process Warmup Engine

Paymon Teyer
Salesforce Engineering
2 min readNov 1, 2018
Centrifuge — by Greg Emmerrich

When the JVM restarts in a production environment, it noticeably affects the performance of the server. The JVM has to reload classes, rerun its JIT compiler on any hot code paths, trigger reflection inflation, reinitialize objects and dependency injections, populate component caches, and so on.

We can minimize the performance impact of JVM restarts by allowing individual components to execute arbitrary warmup logic themselves, after a cold start. To support this aim, we’ve implemented Centrifuge as a library responsible for executing warmup tasks. Centrifuge also manages resource usage and handles failures. It allows users to register and configure warmup tasks either descriptively or programmatically.

Centrifuge supports two categories of warmup tasks:

  • Blocking tasks, which prevent the application from returning to the available server pool until they complete. Blocking tasks must be executed in order for the application to function correctly. Examples of blocking tasks are: executing source code generators, or populating a cache from storage for use by a service (in order to meet SLA requirements).
  • Non-blocking tasks, which execute asynchronously and don’t interfere with the application’s readiness. Non-blocking tasks do work that is needed after an application restarts, but are not required immediately for the application to be in a consistent state. Examples of non-blocking tasks are: warmup logic that triggers JIT compilation on hot code paths, or eagerly triggering dependency injection and object creation.

Centrifuge also schedules tasks, monitors and manages threads, handles exceptions and retries, and provides status reports.

You can find instructions for using Centrifuge here: https://github.com/salesforce/centrifuge. Try it out and let us know how it goes!

--

--