Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Redis persist data?

Tags:

redis

I understand that Redis serves all data from memory, but does it persist as well across server reboot so that when the server reboots it reads into memory all the data from disk. Or is it always a blank store which is only to store data while apps are running with no persistence?

like image 352
Zuriar Avatar asked Aug 15 '14 14:08

Zuriar


People also ask

Does Redis store data?

Redis' read and write operations are very fast because it stores data in memory. Data can also be stored on the disk or written back to the memory. Since Redis stores its data in memory, it is most commonly used as a cache. Some large organizations that use Redis are Twitter, GitHub, Instagram, Pinterest, and Snapchat.

Can Redis lost data?

Redis will lose data if a master shard is lost when the workload is high enough that the “partial sync” stops.


1 Answers

I suggest you read about this on http://redis.io/topics/persistence . Basically you lose the guaranteed persistence when you increase performance by using only in-memory storing. Imagine a scenario where you INSERT into memory, but before it gets persisted to disk lose power. There will be data loss.

Redis supports so-called "snapshots". This means that it will do a complete copy of whats in memory at some points in time (e.g. every full hour). When you lose power between two snapshots, you will lose the data from the time between the last snapshot and the crash (doesn't have to be a power outage..). Redis trades data safety versus performance, like most NoSQL-DBs do.

Most NoSQL-databases follow a concept of replication among multiple nodes to minimize this risk. Redis is considered more a speedy cache instead of a database that guarantees data consistency. Therefore its use cases typically differ from those of real databases: You can, for example, store sessions, performance counters or whatever in it with unmatched performance and no real loss in case of a crash. But processing orders/purchase histories and so on is considered a job for traditional databases.

like image 105
Manuel Arwed Schmidt Avatar answered Sep 23 '22 06:09

Manuel Arwed Schmidt