Say No to SQL 🙅
Tags: database, redis, sql, devops
Published: 2024-05-06 04:51:28

## Attention Developers!

Are you facing these problems with the current application architecture?
- High Throughput to the SQL database.
- Bottleneck in the SQL database.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqi3texvck7ns3c31xv3.png)

An In-memory data store will be the solution to the problem. Redis is the most popular option available in the market for In-memory data storage, and cache. Redis has a wide ecosystem because major tech giants adopt it, it's an open-source project developed by Salvatore Sanfilippo. Redis stands for Remote Dictionary Server.

In layman's terms, consider Redis an index page in the textbook. 
Here key-value pairs are stored. Where value can be in different data structures like sorted sets, lists, stacks, strings, and integers.
The limitation of this In-Memory data store is, that it comes with a significant increase in costs. The solution is to use a memory hierarchy according to the application requirements. 

> FYI: Even your device uses a Memory Hierarchy to provide the best storage organization corresponding to its value.

## Memory Hierarchy


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/caiwara5yilzuph6eksg.png)

Memory Hierarchy is the design to organize computer memory components according to their response time. It includes the use of several memory components like Cache, RAM, ROM, and SSD/HDD.

## Why to use In-Memory data store?
Ques - Why should we use something like Redis, where we can simply store the value in a `Map` data structure with the key corresponding to it, and serve the concurrent requests with it?

- ### Scaling
Yes, It will work with Monolith architecture. However, it is required to vertically scale up the system by adding more resources like RAM and CPUs. But by using Redis we can horizontally scale up the infrastructure by adding more Redis servers to the cluster. 

- ### ACID Compliance
Redis supports partial ACID compliance because it's single-threaded which guarantees consistency and isolation. The use of system memory will heavily increase CPU usage and RAM consumption which slows the application process. Also, redis supports the expiration of keys, regarding time or use of the record. so it automatically deletes the record when no longer in use.

- ### Community Support
Redis is an open-source project with services like Pub-Sub, Data Streams, Vector Search, etc. Where each of the services is backed by the most optimized algorithms and data structures available to the market.

- ### Concurrent Request

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g0chm2eqj7cd2v08p7zn.png)
Redis uses single-threaded event-driven architecture, also the response time for Redis is 1000 times faster compared to SQL databases when 100 users read the database. Also by using event-driven architecture, it can handle high throughput with ease.

## Is Redis a replacement for SQL Databases?
- Consider Redis as a plugin for your database infrastructure, which makes your application blazingly fast.


----

That's it for this article, I hope you learn something useful. Share your thoughts on this article on socials.

Let's Connect - 
<a class="twitter-share-button" href="https://twitter.com/intent/tweet?text=Hey%20Folks%20recently%20read%20this%20article%20on%20Say%20No%20to%20SQL%20by%20%40kunalpy3%20on%20dev.to.%20Its%20been%20great%20help%20to%20understand%20the%20basic%20concepts%20of%20redis.%20Please%20check%20out%20the%20article.">Tweet Thanks</a>
https://linktr.ee/kunal.dev