The Heroku Redis Maxmemory Policy

By

Learn how the Heroku Redis maxmemory-policy setting controls eviction when memory fills up, compare options like allkeys-lru, and set it from the Heroku CLI.

~~~

Heroku’s Redis add-on is now called Heroku Key-Value Store. You still provision it as heroku-redis, and under the hood it runs Valkey, the open source fork of Redis. Heroku dropped its free plans in November 2022, so the cheapest tier today is Mini: 25 MB of memory for a maximum of $3/month (prices checked in September 2026). The next one, Premium 0, gives you 50 MB for $15/month.

25 MB fills up fast with a few thousand keys, depending on what you store.

Heroku has a configuration option called maxmemory-policy that determines how the system behaves when the instance memory is full.

By default this property is set to noeviction, which means the server raises an error when a client tries to store more data.

This is done so you realize what is happening. Once you find out that you can change this behavior, it’s time to determine how.

The policies come from Redis itself, and Valkey kept them. These are the ones Heroku lets you set:

It’s up to you to find the best case for your needs. For a plain cache, allkeys-lru is a good default. Once you have a candidate, apply the change using the Heroku CLI:

heroku redis:maxmemory YOUR_REDIS_INSTANCE_NAME --policy allkeys-lru -a your-app

If you skip -a, Heroku uses the current app from git remotes. The instance name is the add-on name from heroku redis:info (or heroku addons).

Tagged: Redis · All topics

Want me to talk about your product? You can sponsor this site.

~~~

Related posts about redis: