Event Handler Bean: Single instance per handler action for major performance improvements


Currently, any time an event is run with runEvent(), a new ehBean instance is created and the metadata of both the target CFC and the target method are queried with getMetadata().

Looking through the code suggests to me that this is not necessary and should only be done once per event in the lifetime of a production application.

In our own application, I have overwritten the logic here and made it so that:

  • We create a local variables struct cache of ehBeans in HandlerService.cfc, with the event name as the key and the bean as the value.

  • We only query metadata once for a bean, and set a "yes I've read metadata" flag on the bean so that the getHandler() method can check before reading the metadata

Preliminary tests so a really significant performance improvement (our applications make use of runEvent() a lot), doubling throughput and keeping response times lower than the previous highest throughput level.

If this sounds like a good idea, happy to share what we have done, but figured you may have an approach you'd prefer to take.


Luis Majano


Dominic Watson



Fix versions