Skip to content

The Heroku Redis Maxmemory Policy

Heroku offers a great Redis addon, which provides 25MB of memory for free.

This amount of storage can be easily filled with just a few thousands items, depending on what you’re storing.

Heroku has a configuration option called maxmemory-policy that determines how the system will behave when the Redis database memory is filled.

By default this property is set to noeviction, which means Redis will raise an error when trying to store more data.

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

The various behaviors are provided by Redis itself, and they are:

It’s up to you to find the best case for your needs. Once you do have a candidate, you can apply the change using the Heroku CLI, for example:

heroku redis:maxmemory YOUR_REDIS_INSTANCE_NAME --policy volatile-lru

I wrote 21 books to help you become a better developer:

  • HTML Handbook
  • Next.js Pages Router Handbook
  • Alpine.js Handbook
  • HTMX Handbook
  • TypeScript Handbook
  • React Handbook
  • SQL Handbook
  • Git Cheat Sheet
  • Laravel Handbook
  • Express Handbook
  • Swift Handbook
  • Go Handbook
  • PHP Handbook
  • Python Handbook
  • Linux Commands Handbook
  • C Handbook
  • JavaScript Handbook
  • Svelte Handbook
  • CSS Handbook
  • Node.js Handbook
  • Vue Handbook
...download them all now!

Related posts that talk about :