Vawani
Vawani

Reputation: 399

Can I configure Hazelcast in non spring based web application

I want to create a cluster of web application which is developed with servlet and JSP. Now I need to cache data across instance, so any body can help me on the steps to configure this, any reference or any pointer be helpful. thanks in advance

Upvotes: 0

Views: 154

Answers (1)

A.K.Desai
A.K.Desai

Reputation: 1294

Yes, you can. I answered a similar question just now and I believe it holds good for this scenario as well.

My suggestion would be to make use of NearCache feature of Hazelcast clients so you can de-couple the Hazelcast node from tomcat.

Hazelcast Cluster: Setup a Hazelcast cluster with the IMap configuration and implement a MapStore which should take care of loading the IMap with the cache eligible segments. Also make use of Event Handlers to take care of refreshing the cache.

Tomcat Servlet Layer: Startup the Hazelcast clients on each of the tomcat servers and enable the NearCache on those clients. Once the Hazelcast client is up, the NearCache settings will take care of sync'ing the contents from its cluster. Both the tomcat instances would be up-to-date with the cache contents.

Things to remember:

  1. The number of nodes in the HZ Cluster depends on the size of the cache. Recommendation is to keep the Max Heap size to be around 4GB to avoid GC Overheads and spin up as many nodes as required.
  2. The NearCache will be part of the tomcat container itself, so allocate proper heap size when starting up tomcat.
  3. Partition the map contents properly and keep it small size to avoid I/O issues, as there will be data transfer between cluster and tomcat container during sync.

Let me know if this suits your architecture and have any questions.

Reference for NearCache:
http://docs.hazelcast.org/docs/3.6/manual/html-single/index.html#configuring-client-near-cache

Upvotes: 1

Related Questions