By "durable" I mean, the server can crash at any time, and as long as the disk remains in tact, no data is lost (see ACID). Seems like that's what journaling mode is for, but if you enable journaling, doesn't that defeat the purpose of operating on in-memory data? Read operations might not be affected by journaling, but it seems like journaling would kill your write performance.
Asked
Active
Viewed 1.3k times
47
-
5You can't have it both ways. Either some data is in limbo, or you have to wait for all data to be written to the disk. – C. Ross Mar 15 '10 at 20:08
-
5That's exactly why I'm asking this question. – allyourcode Mar 18 '10 at 06:45
1 Answers
64
Redis is not usually deployed as a "durable" datastore (in the sense of the "D" in ACID.), even with journaling. Most use cases intentionally sacrifice a little durability in return for speed.
However, the "append only file" storage mode can optionally be configured to operate in a durable manner, at the cost of performance. It will have to pay for an fsync() on every modification. To configure this, set these two options in your .conf file:
appendonly yes
appendfsync always
From the docs: How durable is the append only file?
Check redis.conf, you can configure how many times Redis will fsync() data on disk. There are three options:
- Fsync() every time a new command is appended to the append log file. Very very slow, very safe.
- Fsync() one time every second. Fast enough, and you can lose 1 second of data if there is a disaster.
- Never fsync(), just put your data in the hands of the Operating System. The faster and unsafer method.
(Note that the default for appendfsync in the configuration file shipping with Redis post-2.0.0 is everysec
, and not always
.)

Eric Smith
- 2,739
- 2
- 30
- 29

Frank Farmer
- 38,246
- 12
- 71
- 89
-
3Good to know. Can you provide a link to support what you're saying? – allyourcode Mar 25 '10 at 19:35
-
1@FrankFarmer I edited the answer some, because it had outdated information about the configuration default and also "buried the headline" a bit by leading with "No." Feel free to improve my improvements. :-) – HostileFork says dont trust SE Feb 27 '15 at 18:04
-
1@HostileFork given the substantial changes you made, I think you'd be better off submitting your own answer. It's been long enough that a new perspective is certainly welcome – Frank Farmer Feb 28 '15 at 00:39
-
@FrankFarmer It would take a long time for it to get to the top of the page! Point was this comes up as the top entry, and this is the top search for durability on Redis on Google. So if you're happy with the edits, I'm happy... – HostileFork says dont trust SE Feb 28 '15 at 03:21
-
1The link is dead, new link: [Redis Persistence – Redis - How durable is the append only file?](https://redis.io/topics/persistence#how-durable-is-the-append-only-file). – Jason Law May 07 '20 at 01:28