Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Redis faster than MySQL?

I just read that Redis is "persistent". Does that mean that it is stored in the hard disk? If yes, how can it be faster than MySQL, which is also hard disk based? Obviously, I am just a beginner, so don't be too harsh.

Connected to: Cheapest way to cache data in node.js?

like image 427
user3289157 Avatar asked Jul 28 '14 06:07

user3289157


1 Answers

Redis only works on key value pairs, which is much simpler but is far from covering the normal use cases of a relational database like MySQL.

The persistence of Redis is optional. Many use cases don't need durability (for example I use Redis to store user sessions outside of my server program so that I can restart it without the users noticing). In that case there's no write on disk.

Even when you configure it for persistence, the writing isn't made at each write in the store which means you could lose up to a few seconds of data in a case of a severe crash. But which also means much better performances.

Overall, you don't really compare Redis and MySQL :

  • if you want reliable relational storage, you use MySQL (or another DBMS)
  • if you can afford to lose a few seconds of data in case of crash and you only need to fast store and retrieve key-value pairs, then Redis might be interesting
like image 199
Denys Séguret Avatar answered Oct 06 '22 08:10

Denys Séguret