Reputation: 665
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?
Upvotes: 18
Views: 16423
Reputation: 6524
The accepted answer only answer pros and cons, not answer Is Redis faster than MySQL?
The answer:
Yes, Redis is faster than MySQL
How can it be faster:
without cache, it depend on hardrive bandwidth (not query)
MySQL, use disk: HDD 100 MB/s, SSD 500 MB/s, NVME 500-3000 MB/s
Redis, other noSQL, use Memory/RAM: DDR3 15,000 MB/s, DDR4 25,600 MB/s
so if using MySQL with HDD 100 MB/s VS Redis DDR4 25,600 MB/s = 256X faster*
*note: not real performance, only theoretically
which is also hard disk based?
both using hard disk but Redis only use HDD for backup/restore.
Upvotes: 7
Reputation: 382102
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 :
Upvotes: 21
Reputation: 675
Redis is an in-memory but persistent on disk database
It stores data in memory first then constantly copys the data to disk.
Upvotes: 0