Firstly, what’s the controller thread? It’s a background process in Lucee which
- cleans up temp files
- validates pooled jdbc and http connections
- expires sessions and applications
- polls the deploy directory
- and a range of other things
But I got tired of being asked about long running controller threads, and not being able to provide any concrete answers on how to figure out what was taking so long…
So I’ve just added in some additional logging of how long each step takes
https://luceeserver.atlassian.net/browse/LDEV-5670
By default, when any step exceeds the default 20s threshold it will be logged out to the application.log, when the log level is set to INFO.
There is a new env var / sys prop since 6.2.2.62-SNAPSHOT / 7.0.0.270-SNAPSHOT which allows configuring the logging threshold in seconds for long running steps.
LUCEE_CONTROLLER_LOG_THRESHOLD
/ lucee.controller.log.threshold
Default is 20, set to 0 to disable this logging
Here’s an example of the threshold at 1ms (manually set via code to demonstrate, the setting only accepts integers so normally the minimum threshold is 1000ms)
-------------- Start Tests -----------
"INFO","ControllerThread:1","06/26/2025","14:36:03","lucee.runtime.engine.Controler",
"checkTempDirectorySize took 94ms"
"INFO","ControllerThread:1","06/26/2025","14:36:03","lucee.runtime.engine.Controler",
"clearUnused took 31ms"
"INFO","ControllerThread:1","06/26/2025","14:36:03","lucee.runtime.engine.Controler",
"clearUnusedDBConnections took 28ms"
"INFO","ControllerThread:1","06/26/2025","14:36:03","lucee.runtime.engine.Controler",
"clearUnusedHttpConnections took 5ms"
"INFO","ControllerThread:1","06/26/2025","14:36:03","lucee.runtime.engine.Controler",
"Web Context [D:\work\lucee6\ant] took 164ms"
It’s normal for these processes to take some time, proportional to the amount of connections, temp files, onSessionEnd(), onApplicationEnd() etc which are being processed in the background.
A server under high load may take longer to run the background controller thread as it runs at a lower thread priority than normal requests