We have an application running on 1 or 2 nodes, depending on the environment, with a shared cache based on Hazelcast.
One of the requests on the application triggers about 1000 requests on this cache (all cache hits).
In a single node configuration this works nicely. Specifically each request takes less then 10ms.
But if we use 2 nodes, each cache request takes about 20-200ms. We thought this would be due to Hazelcast getting the data from the remote node, which of course involves network traffic. So we configured it to use a NearCache, which to our understanding should result in about the same access speed as a single local cache. But it doesn't, it doesn't seem to have an effect on the performance at all.
So now I'm wondering:
- How can I check if the NearCache configuration actually works?
- How can I get read performance close to a local cache, but updates (asynchronously) communicated to the/all remote caches, which I thought I would get by configuring a NearCache?
We initialize our cache with the following configuration:
HazelcastConfiguration.getOrCreateCache(
cacheName,
new CacheConfig<K, CR>()
.setNearCacheConfig(new NearCacheConfig())
.setExpiryPolicyFactory(
HazelcastConfiguration.createExpiryPolicyFactory(expiryAfterModification)),
cacheManager
);