I would like to understand why is redis called an in memory database when it provides persistence similar to databases like MySQL or Postgres:


  • 2
    You're over-thinking this. Redis is an in-memory database. Redis persistence is saving the data being held in-memory to a persistent data store. That's all. Oct 16, 2017 at 5:37

2 Answers 2


Redis is an in-memory database because it keeps the whole data set in memory, and answers all queries from memory. Because RAM is faster than disks, this means Redis always has very fast reads. The drawback is that the maximum size of the data set is limited by the available RAM.

Redis has various options to save the data to permanent storage. This permanent representation can then be used to rebuild the in-memory state of a Redis instance. However, this representation is not indexed and cannot be used to answer queries directly from disk.

This is in stark contrast to databases like Postgres. They always keep the whole data set including indices on disk in a format that allows random access. Queries can be answered directly from the on-disk data. The database may load caches or indices into memory as an optimization, but that is not fundamentally necessary: the database can handle more data than fits into RAM.

A larger difference between Redis and SQL databases is how they deal with writes, i.e. what durability guarantees they provide. There are a lot of tunable parameters here, so it's not correct to say “an SQL database is always more durable than a Redis database”. However, Redis usually commits data to permanent storage on a periodic basis, whereas Postgres will usually commit before each transaction is marked as complete. This means Postgres is slower because it commits more frequently, but Redis usually has a time window where data loss may occur even when the client was told that their update was handled successfully. This data loss may or may not be an acceptable tradeoff in a given use case.

What kind of data set always fits into RAM, is a good match for a key–value datamodel, and doesn't need durability? A cache for some other data source. Redis is very good at being fast. SQL databases like Postgres are better at dealing with large data sets and providing ACID guarantees.


In other words, REDIS only uses the disk to warm up it's in-memory cache, in case the REDIS server goes down for whatever reason. You do not actually have to turn on persistence in REDIS. It is an option. If you turn it off and the server dies, your cache is cold and has to be warmed up dynamically, which can take time and have performance repercussions for the applications that are meant to benefit from the cache.

As you can imagine, since REDIS persistence is not meant to happen on every update, there is always the chance that certain deltas have occurred that did not get persisted, just prior to a server crash. When that server comes back, it will warm up its cache with the last snapshot (or AOF) but ultimately, the deltas are lost.

So it is important to keep this in mind -- that data loss can happen in this context.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.