Redis is an in-memory datastore that is potentially 10x faster than disk databases such as your normal RDBMS when performing operations such as updates. It is built on a of a key-value mapping system model.
What makes Redis Different From Your Normal RDBMS Like Mysql
Now you may be wondering, “what makes redis different from rdbms like mysql?”, “is redis better than Mysql?”, “when exactly do you use redis instead of an rdbms like mysql?”. I’ll try to break it down:
First of all, the striking difference between redis and an rdbms like mysql is: mysql follows the ACID principle and uses a disk storage mechanism, in the sense that all data is not held in memory while redis though it has options to write to disk uses in-memory and does not follow the ACID principle.
Is Redis better than Mysql
Short answer, No none is better than the other, they have various use cases where one will reasonably outperform the other but they are not competitors, meaning Redis does not completely replace Mysql and vice-versa.
When exactly do you use redis instead of an rdbms like mysql
When dealing with unstructured data, things like graphs, likes in social networks, data from iot sensors e.t.c at massive scale redis outshines mysql. So if you are working on a project where data consistency is not a top priority and there are a lot of unstructured data then redis would truly be the best to use.
Take for example you are working an banking software, in such cases data consistency is top priority and most of the data aggregated is structured, it makes more sense to use an rdbms like mysql, but say you are building a platform like facebook or twitter and you want to monitor data like number of shares, likes, tweets e.t.c that is not inherently a top priority for data consistency and is highly unstructured, redis makes more sense to be used in these case.
In most cases, in medium to large scale applications, you will definitely be using a combination of the two.
In the next post we will go even deeper into redis.
Got any questions? hit me a comment.