1. Quick Overview
| Criterion | Redis | Memcached |
|---|---|---|
| Type | In‑memory datastore with rich data types | Simple in‑memory key–value store |
| Threading model | Single‑threaded | Multi‑threaded |
| Data types | Strings, Lists, Sets, Hashes, Sorted Sets, … | Only key–value (binary‑safe) |
| Persistence | Yes (RDB/AOF), configurable | No (RAM only) |
| Replication/Cluster | Built‑in replica, clustering, sharding | Only manual sharding |
| Pub/Sub, Lua | Yes | No |
2. Performance
- Memcached
- Multi‑threaded, leverages multiple CPU cores for extremely high throughput on simple GET/SET.
- Typical latency: around 0.1–0.5 ms on standard workloads.
- Redis
- Single‑threaded but highly optimized; pipelining and I/O multiplexing can reach >100 000 ops/sec on commodity hardware.
- Supports pipelining to reduce round trips and Lua scripting to batch operations atomically.
Head‑to‑head, for pure GET/SET workloads Memcached may edge out Redis by a few percent in throughput; however, when using pipelining, batching, or advanced data structures, Redis often outperforms.
3. Advantages & Disadvantages
Redis
Advantages
- Rich data types: lists, sets, hashes, sorted sets, streams, etc., ideal for caching, leaderboards, queues, and more.
- Persistence: RDB snapshots and AOF logs allow durable storage and recovery.
- High‑availability: supports replicas, Sentinel for auto‑failover, and clustering for sharding.
- Pub/Sub & Streams: native support for messaging and event streaming.
- Lua scripting & transactions: atomic multi‑command operations, fewer network round‑trips.
Disadvantages
- Single‑threaded: a single instance uses one CPU core, limiting per‑instance parallelism.
- Memory overhead: rich data structures consume more RAM compared to Memcached.
- Operational complexity: more features require careful configuration and monitoring.
Memcached
Advantages
- Simplicity & lightweight: key–value only, minimal footprint, easy to deploy.
- Multi‑threaded: naturally leverages all available CPU cores for high throughput.
- Memory‑efficient: very low per‑item overhead, perfect for pure caching.
- Mature ecosystem: many client libraries, plugins, and modules.
Disadvantages
- No persistence: cache is lost on restart.
- Limited data model: only key–value, no advanced structures.
- No built‑in HA: sharding and failover must be managed externally.
4. Basic Deployment Steps
Deploying Memcached
Install
sudo apt-get update
sudo apt-get install memcachedConfigure (/etc/memcached.conf)
-m: memory in MB-p: port (default 11211)-u: run user-t: number of threads
Start & monitor
systemctl enable memcached
systemctl start memcachedCheck stats via memcached-tool or telnet stats.
Sharding: phân chia key qua client hoặc proxy (Twemproxy,…).
Deploying Redis
Install
sudo apt-get update
sudo apt-get install redis-serverConfigure (/etc/redis/redis.conf)
maxmemory&maxmemory‑policy- Enable persistence:
save(RDB),appendonly yes(AOF) - Replication:
replicaof host port - Clustering options if needed
Start & monitor
systemctl enable redis-server
systemctl start redis-serverUse redis-cli info to inspect stats, replication, and memory usage.
- Scaling
- Replica: add Redis replicas for read scaling.
- Sentinel: configure for auto‑failover HA.
- Cluster mode: automatic sharding across multiple nodes.
5. When to Choose Which
| Use Case | Choose Redis | Choose Memcached |
|---|---|---|
| Simple key–value caching only | ❌ | ✔ |
| Extreme throughput across many cores | ❌ | ✔ |
| Need complex data types (queues, sorted sets) | ✔ | ❌ |
| Need persistence & recovery on restart | ✔ | ❌ |
| Need built‑in pub/sub or messaging | ✔ | ❌ |
| Require auto‑failover and high availability | ✔ (Sentinel/Cluster) | ❌ (external management) |
| Want minimal configuration & footprint | ❌ | ✔ |
Conclusion
- Use Memcached when your application demands a simple, ultra‑fast in‑memory cache with minimal operational overhead and no need for persistence or complex data types.
- Use Redis when you require rich data structures, durability, replication/HA, pub/sub, or scripting capabilities, or when you plan to scale out via clustering.


Bài Viết Liên Quan
Check if your VPS has been hacked for unusual resource usage.
CSF, A Powerful and Easy to Control Firewall for Linux Servers
The Silent Shield for Servers in an Age of Cyber Attacks
WordPress VPS Crashes After Using JetBrains AI + GitHub Copilot — How a Quick Fix Saved RAM and Wiped Out Malware
WordPress 6.9.1: A Key Maintenance Release Strengthening the Foundation of the World’s Most Popular Web Publishing Platform
WooCommerce and Major Security Warnings: Hard Lessons for the WordPress E-Commerce Ecosystem
Bài Viết Cùng thể loại
LiteSpeed Memcached a cache with many advantages
Full Introduction to W3 Total Cache
Introduction to WP Super Cache
Introduction to LiteSpeed Cache – Pros and Cons
Introducing WP Rocket a good cache for wordpress
Memcached and Redis cache which one should I use?