What is Redis?
Redis is a widely used technology, but it can be difficult to find clear, accessible resources that explain how it works. This article provides an introduction to Redis, including what it is, how it works, and when to use it.
Redis is a widely used technology, but it can be difficult to find clear, accessible resources that explain how it works. This article provides an introduction to Redis, including what it is, how it works, and when to use it.

Aleksandar Pavlov
Aleksandar is a full-stack engineer with over 8 years of experience in the industry. Over the years, Aleksandar worked with many international startups to helped them release their products on the market faster. He has a skill for writing insightful (and catchy) posts about technology and loves engaging in discussions on a range of thought-provoking topics. When he’s not writing code, you’ll find him playing video games or swimming at the local pool.
Redis is a widely used technology, but it can be difficult to find clear, accessible resources that explain how it works. This article provides an introduction to Redis, including what it is, how it works, and when to use it.
Redis
- Definition of Redis
- Where and When to use Redis
- Advanced Redis
Definition of Redis
Redis is a fast, open-source, in-memory key-value data structure store.
What this means is that Redis allows you to store key-value pairs on your RAM. Since accessing RAM is significantly faster than accessing a disk or SSD, Redis is extremely fast at reading and writing data.
RAM is already used for most operations, but when it comes to cache or database interactions, we use disks by default. Imagine accessing a database to read 10,000 records. If the data is stored on disk it will take an average of 30 seconds, while it takes around 0.0002 seconds to read from RAM.
It’s a fast read/write system but since it’s stored in RAM, it’s volatile.
To prevent data loss, Redis includes a built-in persistence mechanism that writes the in-memory state to disk dump files at configured intervals. The dump files are loaded at start up, making the data available again once the system is running.
Redis also supports different high-availability configurations using Sentinel and primary-replica (master-slave) architectures to maintain constant up-time. These concepts are discussed later in this article.
Where and When to Use Redis
Redis is an acronym for REmote DIctionary Server. It’s a tool that lets you store a database in RAM.
Full Page Caching: Redis is commonly used for caching purposes because it’s extremely fast. Caching is one of the strongest use cases for Redis because of the variety of data types supported by its dictionary structure.
Redis can be used to cache full pages that receive high traffic and contain primarily static content. Pages that change frequently or rely on dynamically generated content are poor candidates for full-page caching, regardless of whether Redis or Memcached is used. But for largely static content or pages refreshed at predictable intervals, caching can improve response times significantly.
Session Cache: Redis can also be used for session storage. Unlike Memcached, which does not provide persistence, Redis supports persistent storage. This makes Redis a reliable option for managing sessions and improves the user experience.
Persistence is especially important for avoiding session data loss during critical user interactions like payment processing, adding items to a shopping cart, or performing authenticated actions.
You can read about more Redis use case examples here.
Advanced
Let’s look at some of the more technical aspects of Redis.
Redis runs as a process, much like MySQL, PHP, Apache, and other services. Because Redis stores data primarily in memory, it uses a significant amount of RAM.
In low-memory situations the operating system may terminate the Redis process, leading to downtime and potential data loss. To prevent this from happening, Redis supports a built-in primary-replica (master-slave) architecture.
This architecture allows additional Redis processes to replicate data from the primary instance. Replica servers receive the same commands and periodically copy the Master dump file to maintain consistency with the primary server. These secondary processes are commonly called replicas or slaves, while the main process is called the primary or master mode.
If the main process fails, Redis Sentinel can promote a replica to act as the new primary and continue processing requests while the original server is being rebooted. Once the original server is available again, the main process is reinstated and the temporary primary rejoins the cluster as a replica, resynchronizing its data.
How do we know when the primary process goes down and how is a replica selected to become the new primary?
This is where Redis Sentinel comes in. Sentinel is responsible for monitoring Redis instances to make sure they’re working. Its responsibilities include:
- Detecting when the primary instance is down
- Selecting a replica to become the new primary
- Monitoring when the primary recovers and integrating the dump file into the replica setup
A general setup usually uses one master, two slaves, and three sentinels.
What’s next?
Redis has a nice community and a substantial amount of well-written documentation. You’ll find plenty of support on their official website.
How you get started with Redis depends on the technology you are using. Different languages interact with Redis differently, but Redis documentation covers a wide range of implementation scenarios. You can find a complete list of Redis clients here and submit your own.
