Hazelcast is default implementation for cache / memory-grid because

  • mature and feature-rich solution
  • not only for caching data but also for computation in clustered environment
  • offers first-class Spring support (Spring cache abstraction layer, Spring Boot support, Spring configuration in common)
  • does support management tools, like Hazelcast management center

OpenHub framework uses Spring cache abstraction layer or Spring Boot (auto-configuration) for decoupling from specific cache implementation. Then it's possible to use different cache providers (such as Redis, ehCache, ...) without making changes in the code (only configuration).

Nevertheless there are implementations which use directly Hazelcast's features, for example org.openhubframework.openhub.core.throttling.ThrottleCounterHazelcastImpl for throttling counting.

Configuration in OpenHub

There is default Hazelcast configuration in the file config/ohf_hazelcast.xml

Cluster configuration

By default, hazelcast is configured as standalone single-node. For cluster deployment it should be configured accordingly, see hazelcast specification for more info: (Hazelcast configurationCluster - Discovery Mechanisms).

OpenHub framework uses Spring Boot Hazelcast support for auto-configuration. There is parameter spring.hazelcast.config which can change configuration file.

# the location of the configuration file to use to initialize Hazelcast.
# the default Hazelcast configuration

Spring Boot supports Hazelcast in two ways:

Both ways have different configuration Spring Boot parameters:  spring.hazelcast.config (has higher priority) vs spring.cache.hazelcast.config

Hazelcast is configured in XML file by default because it's often necessary to change it for target environment - set how instances in the cluster will communicate, set specific data structures etc. That's why OpenHub framework prefer XML configuration to configuration in the code. Nevertheless projects have possibility to directly set-up com.hazelcast.config.Config (that has higher priority than XML configuration).

public Config hazelCastConfig() {
    Config config = new Config();

    return config;

or use org.springframework.boot.autoconfigure.cache.CacheManagerCustomizer:

public CacheManagerCustomizer hazelCastCacheManagerCustomizer() {
    return new CacheManagerCustomizer<HazelcastCacheManager>() {
        public void customize(HazelcastCacheManager cacheManager) {

Data structures configuration

Regardless of sth configuration style (XML vs API) it's necessary to configure data structures which are used in OpenHub framework (or in the project).

There is the full example of Hazelcast configuration with detailed description of all configuration parameters.

The OpenHub framework uses the following data structures:

NameData structure typeUsageCommon parameters
throttlingmapthrottling counting

Distributed map for counting throttling.
Configuration has several interesting points - we need computation as fast as possible, accuracy is not crucial:

  • no backups
  • eviction-policy = Least Recently Used)
  • merge policy = entry with the latest update wins
config_paramsmapconfiguration parameters caching

Distributed map for caching configuration parameters.
Main parameters:

  • no backups
  • eviction-policy = Least Recently Used
  • time-to-live-seconds = 600 seconds (10 minutes)
  • max-idle-seconds = 3600 (1 hour)

There is org.openhubframework.openhub.core.config.CacheNames class with all defines cache names.