I am using Hazelcast in a Spring Boot application. I am just using it in memory, but it's taking up to a minute to get the object. The size of the object can vary depending on what the user uploads, in this case the object is 13.46715625 MB. I am looking for performance tuning recommendations to help improve time to fetch.
Our Config.
@Bean
Config config() {
Config config = new Config();
config.setProperty("hazelcast.logging.type", "slf4j");
config.setProperty("hazelcast.jmx", settings.getJmx().toString());
config.setClusterName(settings.getName());
config.getCPSubsystemConfig().setCPMemberCount(settings.getCpMembers()).setGroupSize(settings.getCpGroup());
if (!CommonUtils.isEmpty(settings.getInterfaceToUse()))
config.getNetworkConfig().getInterfaces().setEnabled(true).addInterface(settings.getInterfaceToUse());
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(settings.getMulticastEnabled());
if (settings.getKubernetesEnabled())
config.getNetworkConfig().getJoin().getKubernetesConfig().setEnabled(true)
.setProperty("namespace", settings.getNameSpace()).setProperty("service-name", "hazelcast-service");
else
config.getNetworkConfig().getJoin().getKubernetesConfig().setEnabled(false);
return config;
}
@Bean
HazelcastLockProvider lockProvider(HazelcastInstance hazelcastInstance) {
return new HazelcastLockProvider(hazelcastInstance);
}
Properties Local
hazelcast.name=local
hazelcast.multicast-enabled=true
hazelcast.kubernetes-enabled=false
Dev
hazelcast.name=app-dev
hazelcast.cp-group=3
hazelcast.cp-members=3
hazelcast.multicast-enabled=false
hazelcast.kubernetes-enabled=true
hazelcast.name-space=app-dev
Our application code to add object into cache:
Specification specification = getSpecificationMap().get(cacheKey);
I saw in a post somewhere the map should be configured as a singleton.
public IMap<String, Specification> getSpecificationMap() {
if (specificationMap == null)
specificationMap = hazelcastInstance.getMap("specification_map");
return specificationMap
}
Dependencies
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-spring</artifactId>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-hazelcast4</artifactId>
<version>5.0.1</version>
</dependency>
Any performance enhancements you could recommend would be much appreciated. Thanks in advance.
The serialization method you choose for your objects can have a significant impact on overall performance. It may not explain all of the delay you're seeing (that would require profiling the app to see what's actually happening), but it is likely to be a contributing factor (especially if you're using Java serialization).
See https://hazelcast.com/blog/comparing-serialization-options/ and https://hazelcast.com/blog/compact-serialization-added-to-serialization-benchmark-suite/