Redis Unleashed: Exploring the Power of Data Storage

Fatma Erkan
3 min readAug 6, 2024

--

Redis is an open-source, in-memory key-value data structure store, which can be used as a database (NoSQL), cache, or message broker. Redis name from REmote DIctionary Server, and developed in 2006. Read/write operations are fast in it because it stores the data in memory. The data is also can be stored on the disk and written back to the memory.

Redis is a distributed system that, unlike in-memory caching, stores the caches of all instances of an application in a single remote memory, ensuring data consistency. Additionally, it can perform read and write operations very quickly. It is mostly used as caching. However, it is Session Store because it keeps clients’ session information. It provides a Publish-Subscribe Pattern. Redis provides scenarios for Queues, allowing for the scaling of sequentially processed messages within an application. It provides scenarios for Counters, enabling them to be used as counters due to its ability to scale.

Pipelining

Redis pipelining is a technique to allow to grouping of multiple Redis commands and sending them to the server in a single batch. Instead of waiting response for each request, the server queues the commands and returns the response in a single call. The advantage of the pipelining is to improve performance due to reduce round trip times. This is important when executing the large number of requests.

Persistence

Persistence means that write data to a durable disk as an SSD. Although Redis primarily serves as a system for caching data, it also supports persistent data storage. While discussing persistent data strictly within RAM isn’t common, Redis offers various methods for saving data to disk. Different persistence options exist:

  1. RDB (Redis Database): Snapshotting involves taking dataset snapshots at specific time intervals and saving them to disk. Perfect for backup. Usable for disaster recovery. Faster when restarting the system with big datasets.
  2. AOF (Append Only File): Every write operation received by the server is logged. This process enables the recreation of the original dataset when the server is restarted. This log is an append-only log, there is no problem if a power outage.
  3. No Persistence: It can be completely disabled and is sometimes done during caching.
  4. RDB + AOF: This refers to a scenario where both RDB and AOF methods are used together.

Advantages

  • Performing operations with data stored in the cache results in increased performance due to the speed of accessing cached data.
  • It’s open source.
  • Supported by many programming languages.
  • Provides different data types
  • Work sync.
  • It can save data on the hard disk in addition to the cache.

Disadvantages

  • The amount of data that can be stored in the cache depends on the RAM capacity.
  • It doesn’t support complex queries with analytical qualities.

Use Cases

  • Caching
  • Session Storage
  • Queues
  • Pub/Sub
  • Counter

Data Types

Redis includes different kinds of data types. The general feature of these data types is that they can be kept in key-value format, up to 512 MB.

Replication

It supports only master-slave replication. When any master Redis server updates its data, all N slave servers connected to the master server also update. A slave can act as a master for other slaves. This way, a graph structure can be created. When copying, the necessary RAM space should be considered.

To avoid failure, Redis offers replication. This means data from the master instance is replicating to multiple replicas. Replicas (slaves) are read-only by default, so all the write operations are done in the master. The replication operation is asynchronous, so slaves synced with the master. If any failover in the master, one of the slave can be promoted as master to result high availability.

--

--