Search code examples
javatomcatdynamic-class-loaders

Performance cost of dynamic class loading in JAVA


I develop applications using a customized version of Tomcat. There is support for dynamic class loading, which I use a lot in test and development environments, and I'm curious about the impact of using it in production environment also.

By my knowledge, dynamic class loading is not to be used in production due to performance issues, due to the class loader polling classes at each access.

But, this applcation server support configuration of polling frequency for loading new classes.

If I understand it correctly, if I configure the dynamic class loading to poll every reasonably large amount of time (ie. 1hour) I should avoid most adverse performance impacts.

In production, this mechanism would be used in a limited number of ways:
1) emergency patching without user downtime (fixes would be released at the first shutdown)
2) permanent patching of classes of which we do not have the source (legacy third party libs)

Is this a reliable solution?

Thanks


Solution

  • IMHO you should not use the feature for production.
    Apart from the polling overhead there may be lot of other scenario which would not cause problems in a dev environment

    Few things that come to my mind are

    1. Impact on any constants that are inlined during compiletime
    2. Impact on perm space
    3. You lose track of the version you have deployed in production
    4. there can be mistakes like missing a classfile during the patch