I want to deploy a servlet on a two-nodes tomcat cluster, which use hazelcast caching. The setup is as follow:
- two VM. each with tomcat7 setup.
- a java program to instantiate the hazelcast on each VM. distributed cache is created across the two VM independent of the tomcat context
The servlet creates hazelcast client connection, and access the IMAP in hazelcast.
I noted, in some forum, saying to instantiate the hazelcast in contextInitialized() function in the tomcat. So, whenever the tomcat context starts, hazelcast will start; the tomcat context is destroyed, hazelcast will be destroyed too.
I am in doubt whether instantiating the hazelcast in contextInitialized() function will be more efficient and appropriate for tomcat-hazelcast integration? Or there is actually no much different if use my current java program to create the hazelcast, independent of the tomcat context lifecycle?
I am currently facing a problem of long response time of the servlet when multiple users access the serlvet webpage. I also use IMAP lock to make sure appropriate concurrency process. So, want to know how to tune it for better performance. Appreciate for any advice.
Thanks! Ryan