Skip to content

Configure cache maxmemory-reserved setting#

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

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": "2023-04-01",
  "name": "[parameters('name')]",
  "location": "[parameters('location')]",
  "properties": {
    "minimumTlsVersion": "1.2",
    "redisVersion": "latest",
    "sku": {
      "name": "Premium",
      "family": "P",
      "capacity": 1
    },
    "redisConfiguration": {
      "maxmemory-reserved": "615"
    },
    "enableNonSslPort": false
  },
  "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@2023-04-01' = {
  name: name
  location: location
  properties: {
    minimumTlsVersion: '1.2'
    redisVersion: 'latest'
    sku: {
      name: 'Premium'
      family: 'P'
      capacity: 1
    }
    redisConfiguration: {
      'maxmemory-reserved': '615'
    }
    enableNonSslPort: false
  }
  zones: [
    '1'
    '2'
    '3'
  ]
}

Comments