Server

What Is Redis? Why It Is Fast and What You Trade for It

Updated 2026-08-29~8 min read

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.

💡 The mental model that works: Redis is not a faster database. It is a different tool that happens to store data, designed for things you need immediately and can afford to lose.

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.

💡 Rule of thumb: if losing the data would be an incident, Redis is not where it lives. If losing it means recomputing something, Redis is perfect.

What Redis Is Genuinely Good For

UseWhat it doesWhy Redis suits it
Page and query cachingStores rendered pages or query resultsThe whole point is avoiding a slow lookup — losing the cache just means recomputing
SessionsKeeps logged-in user stateRead on every request; shared cleanly across multiple servers
Rate limitingCounts requests per user or IPAtomic counters with automatic expiry, built in
QueuesHands background jobs to workersList operations make a simple, fast queue with no extra software
LeaderboardsKeeps ranked scoresSorted sets do exactly this natively, no query needed
Real-time countersViews, likes, stock levelsIncrementing in memory avoids hammering the database on every hit
Pub/sub messagingBroadcasts events to subscribersSimple 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.

AspectRedisMemcached
Data typesStrings, lists, sets, sorted sets, hashes, streamsStrings only
PersistenceOptional snapshots or append-only logNone — purely in memory
ReplicationBuilt inNot built in
ThreadingSingle-threaded commandsMulti-threaded
Memory efficiencyGoodSlightly better for plain key-value
Best fitAlmost everything, especially anything structuredVery large, very simple string caches
💡 In practice Redis is the default choice now. Memcached remains marginally more memory-efficient for enormous simple caches, but Redis does that job well too and does a dozen other jobs Memcached cannot do at all.

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 patternApproximate data in RedisPlan to start onPrice per month (annual)
Sessions for a small siteTens of MBVPS-01 (3 GB)฿200
Page cache for a busy blog100-500 MBVPS-02 (4 GB)฿280
Cache plus queues for a shop1-2 GBVPS-03 (8 GB)฿480
Heavy caching, multiple apps4-8 GBVPS-06 (16 GB)฿1,280
💡 Always set maxmemory and an eviction policy. Without them Redis will happily consume every byte available and get killed by the kernel, taking your cache and possibly your database with it.

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.

💡 If you take one thing from this article: an internet-facing Redis without a password is not a risk, it is a certainty. Bind to localhost and set a password before you store a single key.

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.