Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Redis a memory only store like memcached or does it write the data to the disk

Tags:

redis

Is Redis memory only store like memcached or does it write the data to the disk? If it does write to the disk, how often is the disk written to?

like image 553
kapso Avatar asked Jun 14 '12 21:06

kapso


People also ask

Does Redis store data in-memory?

All Redis data resides in memory, which enables low latency and high throughput data access. Unlike traditional databases, In-memory data stores don't require a trip to disk, reducing engine latency to microseconds.

Does Redis write to disk?

Within Redis, there are two different ways of persisting data to disk. One is a method called snapshotting that takes the data as it exists at one moment in time and writes it to disk. The other method is called AOF, or append—only file, and it works by copying incoming write commands to disk as they happen.

Is Redis in-memory or distributed?

Redis is an in-memory data store that is most often used as a distributed cache. It offers a variety of efficient data structures designed to allow brutally fast access to your data.

What is difference between Redis and Memcached?

Although they are both easy to use and offer high performance, there are important differences to consider when choosing an engine. Memcached is designed for simplicity while Redis offers a rich set of features that make it effective for a wide range of use cases.


2 Answers

Redis persistence is described in detail here:

http://redis.io/topics/persistence

By default, redis performs snapshotting:

By default Redis saves snapshots of the dataset on disk, in a binary file called dump.rdb. You can configure Redis to have it save the dataset every N seconds if there are at least M changes in the dataset, or you can manually call the SAVE or BGSAVE commands. For example, this configuration will make Redis automatically dump the dataset to disk every 60 seconds if at least 1000 keys changed: save 60 1000

Another good reference is this link to the author's blog where he tries to explain how redis persistance works:

http://antirez.com/post/redis-persistence-demystified.html

like image 64
Kevin Bedell Avatar answered Oct 06 '22 16:10

Kevin Bedell


Redis holds all data in memory. If the size of an application's data is too large for that, then Redis is not an appropriate solution.

However, Redis also offers two ways to make the data persistent:

1) Snapshots at predefined intervals, which may also depend on the number of changes. Any changes between these intervals will be lost at a power failure or crash.

2) Writing a kind of change log at every data change. You can fine-tune how often this is physically written to the disk, but if you chose to always write immediately (which will cost you some performance), then there will be no data loss caused by the in-memory nature of Redis.

like image 29
Matthias Gelbmann Avatar answered Oct 06 '22 14:10

Matthias Gelbmann