Skip to content

Configure cache maxmemory-reserved setting#

Performance Efficiency · Azure Cache for Redis · Rule · 2020_12 · Important

Configure maxmemory-reserved to reserve memory for non-cache operations.

Description#

Azure Cache for Redis supports configuration of the maxmemory-reserved setting. The maxmemory-reserved setting configures the amount of memory reserved for non-cache operations. Non-cache operations include background tasks, eviction, and compaction.

By reserving memory for these operations, you prevent Redis cache from using all available memory for cache. If enough memory is not reserved for these operations it can lead to performance degradation and instability.

Setting this value allows you to have a more consistent experience when your load varies. This value should be set higher for workloads that are write heavy.

When memory reserved by maxmemory-reserved, it is unavailable for storage of cached data.

Recommendation#

Consider configuring maxmemory-reserved to at least 10% of available cache memory.

Examples#

Configure with Azure template#

To deploy caches that pass this rule:

  • Set the properties.redisConfiguration.maxmemory-reserved property to at least 10% of the cache memory.

For example:

Azure Template snippet
{
  "type": "Microsoft.Cache/redis",
  "apiVersion": "2024-03-01",
  "name": "[parameters('name')]",
  "location": "[parameters('location')]",
  "properties": {
    "redisVersion": "6",
    "sku": {
      "name": "Premium",
      "family": "P",
      "capacity": 1
    },
    "redisConfiguration": {
      "aad-enabled": "True",
      "maxmemory-reserved": "615"
    },
    "enableNonSslPort": false,
    "publicNetworkAccess": "Disabled"
  },
  "zones": [
    "1",
    "2",
    "3"
  ]
}

Configure with Bicep#

To deploy caches that pass this rule:

  • Set the properties.redisConfiguration.maxmemory-reserved property to at least 10% of the cache memory.

For example:

Azure Bicep snippet
resource cache 'Microsoft.Cache/redis@2024-03-01' = {
  name: name
  location: location
  properties: {
    redisVersion: '6'
    sku: {
      name: 'Premium'
      family: 'P'
      capacity: 1
    }
    redisConfiguration: {
      'aad-enabled': 'True'
      'maxmemory-reserved': '615'
    }
    enableNonSslPort: false
    publicNetworkAccess: 'Disabled'
  }
  zones: [
    '1'
    '2'
    '3'
  ]
}

Configure with Azure Verified Modules

A pre-validated module supported by Microsoft is available from the Azure Bicep public registry. To reference the module, please use the following syntax:

br/public:avm/res/cache/redis:<version>

To use the latest version:

br/public:avm/res/cache/redis:0.7.2

Comments