Redis persist all data in memory to disk? If Redis is restarted, it loads that data from disk to memory?

92 views
Skip to first unread message

reginaldo rideaki

unread,
Jan 4, 2018, 7:36:54 PM1/4/18
to Redis DB

I´m using Redis and I would like to know:

1) What settings (persist config) are required for Redis to persist all the data in memory to disk?

2) If Redis is restarted, it loads that data from disk to memory again? There is a config to do this?

Thanks a lot.

Jan-Erik Rediger

unread,
Jan 5, 2018, 3:55:40 AM1/5/18
to redi...@googlegroups.com
The persistence docu[1] should explain everythin.
[1]: https://redis.io/topics/persistence

You can use RDB or AOF (or both).
It will always include the whole dataset in memory.

If an AOF exist, Redis will load it on start.
If an RDB exist (and no AOF), Redis will load it on start.
Otherwise it will start empty.
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
> To post to this group, send email to redi...@googlegroups.com.
> Visit this group at https://groups.google.com/group/redis-db.
> For more options, visit https://groups.google.com/d/optout.

hva...@gmail.com

unread,
Jan 5, 2018, 4:00:35 AM1/5/18
to Redis DB
The documentation page that discusses Redis persistence is https://redis.io/topics/persistence
It's not the easiest page to find on the site, but it is listed in the logical place (the page you reach when you click "Documentation" in the list of topics at the top of https://redis.io/)

There are two forms of persisting data to disk:  A "snapshot" (RDB) file, and an append-only file (AOF).
(actually there are two more forms:  no persistence at all, which can be appropriate for mere caches, and attaching another Redis as a slave and configuring that other Redis to save on disk)

The information you're asking about is spread out a little on the persistence page, so here's the summary pulled together:

From the first two bullet points at the top of the page:
  • The RDB persistence performs point-in-time snapshots of your dataset at specified intervals.
  • the AOF persistence logs every write operation received by the server, that will be played again at server startup, reconstructing the original dataset.
The replay/reload of data from the file on disk is mentioned in the context of the Append-Only File (AOF).  It should also be mentioned for the RDB snapshot file, because Redis will reload from the snapshot file in the same way.  For confirmation of this, see the description of the SHUTDOWN command (https://redis.io/commands/shutdown).

Now scroll down the persistence page to the "Snapshotting" header (https://redis.io/topics/persistence#snapshotting) for descriptions of the configuration file parameters that control the snapshot and aof actions.  In between on that page is some discussion of the benefits and drawbacks of the two forms of persistence.

Please be aware that snapshots of a large Redis dataset can make a disk drive very busy.  There is a huge difference in speed between RAM and disk (see this post for a comparison), and the speed difference can saturate the I/O capacity of the disk.  If the disk serves the rest of the server, like the root filesystem or swap space, the saturation can have greater effects than you expect.  If your Redis dataset is large, then it's often a good idea to dedicate a disk to the Redis persistence file(s) or make sure the shared disk has a great deal of I/O capacity.
Reply all
Reply to author
Forward
0 new messages