Hazelcast Storage Best Practices

This topic describes the Hazelcast server-side configurations that work best with the . You must make these changes manually, as the Gateway is unable to do so since it is behaving only as a client.
gateway94
This topic describes the Hazelcast server-side configurations that work best with the 
API Gateway
. You must make these changes manually, as the Gateway is unable to do so since it is behaving only as a client.
Instructions on configuring the Gateway to use Hazelcast is described in Connect to an External Hazelcast Datastore. That topic also describes which Hazelcast client configurations are supported by the Gateway (not all configurations are supported).
Contents:
Configuration for Hazelcast Map Data Structure
The Gateway uses the key value store implemented by the External Hazelcast Storage. Use these configuration options for the Hazelcast map data structure.
Enable Backup Reads
When the Gateway connects to an External Hazelcast Cluster, each request should have a multiple copies over the Hazelcast cluster nodes to avoid data loss. You can configure this one of two ways:
  • backup-count
    :
     
    This setting backs up map entries to other Hazelcast nodes in the cluster. The default value is
    1
    , which means it backs up to one other node. Setting this to
    2
    backs up a map entry to two other Hazelcast nodes. The maximum backup count is
    6
    . The backup occurs synchronously, so the backup has priority and will block other operations.
    You can disable backups by setting
    backup-count
    to
    0
    (zero). This is not recommended, but it may be necessary if performance is more important than backups. You must disable
    backup-count
    if you choose to enable
    async-backup-count
    .
  • async-backup-count
    : This is the same thing as
    backup-count,
    except that backups occur asynchronously and do not block other operations. The default value is
    0
    , which means asynchronous backups are disabled by default. Set this to another value depending on the number of nodes that you wish to back up to. Be sure to set
    backup-count=0
    if you enable
    async-backup-count
    .
The "default" map settings use these settings:
  • backup-count=1
  • async-backup-count=0
These defaults are used whether or not a
<map name="default">
section is explicitly stated in
hazelcast-client.xml
.
To set your own mapping, add a
<map name="newMapName">
section to
hazelcast-client.xml
as shown below:
<?xml version="1.0" encoding="UTF-8"?> <hazelcast xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.hazelcast.com/schema/config http://www.hazelcast.com/schema/config/hazelcast-config-3.10.xsd" xmlns="http://www.hazelcast.com/schema/config"> <map name="myMapName"> <backup-count>0</backup-count> <async-backup-count>2</async-backup-count> </map> </hazelcast>
In the example above synchronous backup is disabled, while asynchronous backup is set to back up to two Hazelcast nodes.
Map Eviction
The Gateway controls the life cycle of all key value pair and data entries. Do not configure expiration of data entries in Hazelcast. Do not configure these settings in
hazelcast-client.xml:
  • time-to-live-seconds
  • eviction-policy
  • max-size