- 1 minute read

Today I stumbled over an unexpected performance leak. Looking up for simple variables in the JNDI context sometimes seems to consume some 20 ms. At other times, the lookup takes only a few microseconds.

I didn't find out yet why and when this happens, but a quick survey of the web revealed that this is quite a common problem, and frequently the lookup times are much worse (up to ten seconds).

Most of the time is consumed by creating the initial context, so you should cache it. If possible, you should cache the objects you look up, too. But before you do, measure the time the JNDI lookup really needs: Things like this are likely to be improved in new versions of the application server, and they depend on your individual configuration.


Comments