RiaChoi Text Logo.
5 minutes Redis

Redis

Cache

5 minutes Redis

Learn about Redis and caching strategy in 5 minutes

Ria ChoiMay 13th, 2026

Introduction

What exactly is Redis, and why do so many large-scale systems rely on it?

In this article, you’ll learn the core concepts of Redis — including caching, concurrency, distributed locks, and real-time ranking systems — in under 5 minutes.

Instead of diving into difficult theory, we’ll focus on simple real-world examples and visual explanations to understand how Redis solves performance and scalability problems.

 

Index

  1. What is Redis
    1. Modern Backed Flow
  2. In Memory and Single Thread
    1. Race Condition when Memcached
    2. Single Thread Event
  3. Caching Strategy in Redis and Case Study
    1. Implementing Distributed Lock
    2. How Redis Handles Distributed Lock
  4. Glossary
  5. Conclusion

What is Redis 👊🏻

Blog image
You're in the dungeon library

Let’s imagine you have a list of books that need to be read that day.

Too bad your house is a dungeon, that you have to travel all the way down to the main library shelves placed in the underground archive.

 

For this problem, Redis comes to the rescue!

Redis works like your personal book cart; you can carry it around between the underground library and your desk, so you can read the book whenever you like.

 

🤔💭 Let’s Imagine!

You’re a major seller in the shoe market.
Suddenly, your website gets 10k visitors in a single second.
Since your system relies only on an RDBMS, the server eventually goes down.

RDBMS Relational Database Management System

 

Modern Backend Flow

That’s when Redis comes in.
First, the application checks Redis for cached data (Cache Aside / Look Aside).
If the requested data does not exist in Redis (Cache Miss), the application queries the database instead.
Finally, the result is stored in Redis for faster future reads.

how redis works
How redis works

In-Memory & Single Thread

You’ve probably heard that RAM (memory) is much faster than random disk I/O.

RAM speed = 120ns
Random Disk I/O = 50~150us

 

Race Condition when Memcached

Memcached An in-memory key-value cache designed for fast data retrieval.

Race Condition An issue where concurrent operations produce unexpected results due to timing conflicts.

 

Imagine your application receives a request for user A’s ranking score.
Since Memcached has very limited sorting capabilities, the process works like this:

  1. Retrieve the entire ranking dataset.
  2. Sort the data in the application server’s memory.
  3. Store the sorted result back in Memcached.
A: 100
B: 90
C: 80

Meanwhile, user B updated its ranking score from the application.

A: 100
B: 90
C: 110
❗ Race Condition

The server is still trying to sort the data and has stored the previous data back in the database.

=> The score from user C has been overwritten.

 

⭐ Redis Sorted Set

Redis Sorted Sets are commonly used for real-time ranking systems because they handle sorting much more efficiently and safely.

Blog image
Redis VS Others

 

Single Thread Event

Thread The smallest unit of execution that can run independently within a process.

Single-threaded A system or application that processes tasks one at a time using only one thread.

Multi-threaded A system or application that can execute multiple threads concurrently for better performance.

Threads Multiple execution paths running within the same process.

 

Redis is designed around a single-threaded event loop.
This helps minimize concurrency-related issues such as Race Conditions, Context Switching Overhead, and Lock Contention.

Context Switching Overhead Performance cost caused by the CPU switching between threads or processes.

Lock Contention Performance bottlenecks caused when multiple threads compete for the same lock or resource.

 

Single Threaded Operation
Current Score = 100
Thread A -> +10
Thread B -> +20
Anticipated result = 130
Multiple Threaded Operation
Thread A reads 100
Thread B reads 100

Thread A writes 110
Thread B writes 120

Result = 120
Redis is so fast that processing requests alone is often faster than having multiple threads wait for locks.

Lock A way to ensure that only one thread can use a shared resource at a time.

 

Caching Strategy in Redis and Case Study 📝

If you'd like to learn more about caching strategies, check out my previous blog post below.

>> Post Link

 

🤔💭 Let’s Imagine!

Imagine a limited-edition premium sneaker release where 100 users send purchase requests simultaneously.

If concurrency is not handled correctly, an overselling issue can occur.

That means the system could mistakenly process multiple successful purchases even though only one item is actually in stock.

premium shoe
Premium Shoe

 

Implementing Distributed Lock

To handle this concurrency problem, we’re going to use a distributed lock.
This approach is widely used by large-scale companies to manage concurrent requests safely.

handling inventory conflict
Handling Inventory Conflict

Two people are trying to edit the same data at the same time.

The system becomes confused about which update should be applied first, leading to incorrect inventory data.

 

How Redis Handles Distributed Locks

Redis works like a gatekeeper.
Only one request can enter the critical section at a time, preventing multiple servers from updating the same data simultaneously.

Per-Request Absolute Control
Per-Request Absolute Control

 

If you want to know more about distributed locks, you can check out my blog linked below!

>> Blog Link

 

Glossary ✨

  • RDBMS (Relational Database Management System) → A database system that stores and manages related data using tables, rows, and structured relationships.
  • I/O (Input/Output) → The communication process between a computer system and external devices such as disks, networks, or users.
  • Redis → An in-memory data store named “REmote DIctionary Server” that stores data as Key-Value pairs for extremely fast access.
  • Dictionary → A data structure where each value is stored and retrieved using a unique key.
  • Memcached → A high-performance open-source distributed memory caching system that stores API or database results in RAM using a Key-Value structure.
  • Race Condition → A concurrency problem where multiple operations modify shared data simultaneously, causing inconsistent results.
  • Lock Contention → A performance issue that occurs when multiple threads wait to acquire the same lock or shared resource.
  • Context Switching Overhead → The performance cost caused by the CPU switching between threads or processes.
  • CPU Thread Limitation → Since a CPU can execute only a limited number of threads simultaneously, having too many threads can cause more time to be spent switching threads than performing actual work.

 

🪐Conclusion

In this article, we explored how Redis handles caching, concurrency, and distributed locking to solve real-world scalability problems.

 

This learning journey was heavily inspired by and learned from Tutor Seok Jinhee at the Sparta Coding Club Boot Camp.

 

Share

Related contents

Lock Strategy in MSALock Strategy in MSA

May 15th, 2026