4

Redis is the default implementation for Java's Spring session storage. But Redis is an in-memory value-key storage and sooner or later it will run out of memory. And once it does, it will do one of the following:

  • Throws an error for commands requesting new memory
  • Frees memory according to policy set in the configuration (maxmemory-policy).

I see that there has been some feature called Virtual Memory in Redis but it's been discontinued and since version 2.4, it's not available.

Is Redis capable of using hard disk as the backup storage when it runs out of memory or it's really a bad choice for session storage? Or maybe Redis relies on OS to use swap as the last resort?

I'm using Redis 3 and Spring session 1.1.1

Mehran
  • 15,593
  • 27
  • 122
  • 221
  • [... we want to simply provide the best in-memory database (but persistent on disk as usual) ever, without considering at least for now the support for databases bigger than RAM. Our future efforts are focused into providing scripting, cluster, and better persistence.](http://redis.io/topics/virtual-memory) it seems if you are likely to overflow from memory redis isn't the solution for you – beresfordt Mar 25 '16 at 22:16

1 Answers1

7

Yes and no.

Redis won't fall over when you exceed RAM but it's really not recommended.

An interesting related article by the Redis author: http://antirez.com/news/52

That doesn't mean that Redis is a bad choice for session storage, it just means that you need to plan/size your architecture/RAM appropriately based on your capacity requirements.

Joseph Simpson
  • 4,054
  • 1
  • 24
  • 28