Redis is an in-memory data store. It keeps its data in RAM rather than on disk, which is the entire reason it answers in microseconds where a traditional database takes milliseconds — a difference of roughly a thousand times for a simple lookup.
That one design decision explains everything else about it: what it is exceptional at, what it is dangerous for, and how much it costs to run. This guide covers all three, plus the security default that has turned a great many Redis installations into someone else's cryptocurrency miner.
What Redis Actually Is
At its simplest Redis is a key-value store: you give it a name, it gives you back what you saved under that name. But it also understands structured types — lists, sets, sorted sets, hashes, streams — which is what separates it from a plain cache and makes it useful for things like leaderboards, queues and rate limiters.
It is single-threaded for command execution, which sounds like a limitation and mostly is not. Because every operation completes in microseconds, one thread handles enormous throughput, and the design removes an entire class of concurrency bugs. It also means one slow command blocks everything behind it, which is worth remembering before you run an operation across every key.
Why It Is Fast, and What You Trade Away
Disk is slow compared with memory — that gap is the whole story. By keeping the working set in RAM, Redis skips the slowest part of what a normal database does.
The trade is that RAM is volatile and expensive. Volatile means data disappears when the process stops, unless you configure persistence. Expensive means you cannot store much of it: a server with 8 GB of RAM stores 8 GB of data, where the same money buys hundreds of gigabytes of disk.
Redis does offer persistence — periodic snapshots, or an append-only log of every write. Both help, and neither makes Redis a safe system of record. Snapshots lose everything since the last one, and even the append-only log can lose the last second of writes in the default configuration. That is entirely acceptable for a cache and entirely unacceptable for orders or payments.
What Redis Is Genuinely Good For
| Use | What it does | Why Redis suits it |
|---|---|---|
| Page and query caching | Stores rendered pages or query results | The whole point is avoiding a slow lookup — losing the cache just means recomputing |
| Sessions | Keeps logged-in user state | Read on every request; shared cleanly across multiple servers |
| Rate limiting | Counts requests per user or IP | Atomic counters with automatic expiry, built in |
| Queues | Hands background jobs to workers | List operations make a simple, fast queue with no extra software |
| Leaderboards | Keeps ranked scores | Sorted sets do exactly this natively, no query needed |
| Real-time counters | Views, likes, stock levels | Incrementing in memory avoids hammering the database on every hit |
| Pub/sub messaging | Broadcasts events to subscribers | Simple to run when you do not need a full message broker |
Redis Is Not Your Main Database
This needs saying plainly because people do try. Redis can persist to disk, which makes it look like a viable primary store, and there are cases where it is used that way deliberately by people who understand exactly what they are accepting.
For everyone else it is the wrong choice for three reasons. Your entire dataset must fit in RAM, which puts a hard and expensive ceiling on growth. Durability is best-effort rather than guaranteed, so a crash can lose recent writes. And there is no rich query language — you can fetch by key, but you cannot ask "every order from last month over ฿5,000" without building and maintaining that index yourself.
The normal architecture is boring and correct: PostgreSQL or MySQL holds the truth, Redis holds a fast copy of the parts you read constantly. If Redis vanishes entirely, the site gets slower and keeps working. That is the property you are designing for.
Redis vs Memcached
Memcached is the other well-known in-memory cache, and the comparison comes up whenever someone is choosing one.
| Aspect | Redis | Memcached |
|---|---|---|
| Data types | Strings, lists, sets, sorted sets, hashes, streams | Strings only |
| Persistence | Optional snapshots or append-only log | None — purely in memory |
| Replication | Built in | Not built in |
| Threading | Single-threaded commands | Multi-threaded |
| Memory efficiency | Good | Slightly better for plain key-value |
| Best fit | Almost everything, especially anything structured | Very large, very simple string caches |
Will Adding Redis Actually Make Your Site Faster?
Sometimes dramatically, sometimes not at all, and it is worth knowing which before you install anything.
Redis helps when the same expensive work is repeated. A homepage that runs twelve database queries for every visitor, an API that recomputes the same aggregate constantly, a session store hit on every single request — these get faster immediately and noticeably.
Redis does not help when the work is genuinely different each time, when your database is already fast enough, or when the real bottleneck is somewhere else entirely. Adding a cache to a site whose slowness comes from unoptimised images or blocking JavaScript changes nothing, and you have added a service to maintain for no benefit.
The honest sequence is: measure first, find where the time actually goes, and add Redis if the answer is "repeated database work". Installing a cache and hoping is how people end up with a more complicated stack and the same load time.
How Much RAM to Budget
Redis needs memory for the data itself plus overhead, and it must share the machine with everything else running there.
| Usage pattern | Approximate data in Redis | Plan to start on | Price per month (annual) |
|---|---|---|---|
| Sessions for a small site | Tens of MB | VPS-01 (3 GB) | ฿200 |
| Page cache for a busy blog | 100-500 MB | VPS-02 (4 GB) | ฿280 |
| Cache plus queues for a shop | 1-2 GB | VPS-03 (8 GB) | ฿480 |
| Heavy caching, multiple apps | 4-8 GB | VPS-06 (16 GB) | ฿1,280 |
The Security Mistake That Costs People Their Servers
Redis historically shipped with no password and, in older versions, listening on all network interfaces. That combination — an open port with no authentication — is one of the most reliably exploited misconfigurations on the internet.
What happens is not subtle. Automated scanners find open Redis ports within hours. An attacker with write access to Redis can often write files to disk, add an SSH key, and own the machine outright. Cryptocurrency miners installed this way are a standard outcome, and the first sign is usually a CPU that never drops below 100%.
The protection is short and non-negotiable: bind Redis to 127.0.0.1 so it is unreachable from outside, set a long password with requirepass, keep protected-mode enabled, and never open port 6379 in the firewall. If an application on another server genuinely needs access, tunnel it over SSH or a private network rather than exposing the port.
It is also worth renaming or disabling the dangerous commands — FLUSHALL, CONFIG and KEYS — in production. The first two let an intruder wipe or reconfigure everything, and the third can freeze a busy instance for seconds at a time even when a well-meaning developer runs it.
Need RAM to run Redis alongside your application?
Cloud VPS up to 24 GB RAM with full root access and NVMe storage — from ฿150/month.
Frequently Asked Questions
Is Redis a database or a cache?
Technically it can be either; practically almost everyone uses it as a cache and session store alongside a real database. It has persistence options, but the durability guarantees are weaker than PostgreSQL or MySQL, so it should not hold data you cannot afford to lose.
What happens when Redis runs out of memory?
It depends on your eviction policy. With one set, Redis discards old keys to make room — normal and healthy for a cache. Without one, writes start failing or the kernel kills the process. Always configure maxmemory and a policy such as allkeys-lru.
Do I need a separate server for Redis?
Not at first. Running it on the same VPS as your application is entirely normal and avoids network latency, provided you have the RAM for both. Separate it when Redis grows large enough to compete with your application for memory, or when several servers need to share it.
Does WordPress benefit from Redis?
Yes, noticeably, through an object cache plugin. WordPress makes many repeated database queries per page, and caching them in Redis removes most of that work. It is one of the more reliable speed improvements available to a busy WordPress site.
Redis or Memcached for a new project?
Redis, in almost every case. It does everything Memcached does plus data structures, persistence and replication. Memcached retains a small edge in raw memory efficiency for enormous plain caches, which is a narrower situation than it sounds.
Is data lost when Redis restarts?
Yes, unless persistence is enabled — and even then you may lose the most recent writes. That is fine for a cache, which simply rebuilds itself from the database. It is exactly why Redis should not be the only place anything important is stored.
GUIDES
Related articles
Keep reading on similar topics
What Is a VPS? What Can You Do With One, Explained Simply
A complete guide to VPS — what a VPS server is, how it works, how Cloud VPS differs from a regular VPS, what you can do with one, how it compares to shared hosting and dedicated servers, who should use one, and how to get started in 2026.
Read moreWhat Is n8n? Workflow Automation You Can Actually Own
n8n is an automation tool in the same family as Zapier and Make, with one difference that changes everything: you can run it on your own server. This guide covers what it does, the vocabulary you need, and the honest trade-off between the hosted version and self-hosting.
Read moreVPS vs Web Hosting: What Is the Difference and Which to Choose in 2026?
A simple breakdown of the difference between web hosting and a VPS — which suits small sites, which suits growing sites — with a comparison table of resources/control/price and the signs it is time to upgrade from hosting to a VPS.
Read more