Inside Memcached vs Redis: Architecture, Memory, and Persistence
An in‑depth comparison of Memcached and Redis reveals how both key‑value cache servers operate, covering their service models, event loops, memory allocation strategies, database implementations, persistence mechanisms, transaction support, and publish/subscribe features, highlighting the trade‑offs between simplicity and rich functionality.
Overview
Memcached and Redis are in‑memory key‑value cache servers that accelerate data access by storing frequently used data in RAM, reducing database queries and improving performance under high load.
Service Model
Both run as independent processes (daemonizable) and provide network services via TCP (and optionally UDP). When the client and server reside on the same machine, Unix domain sockets can be used for inter‑process communication.
Event Model
Both use epoll for event notification on Linux (Redis can fall back to select / poll, and on BSD it can use kqueue). Redis runs a single‑threaded event loop, while Memcached employs a master‑worker multi‑threaded model. Redis stores client connections in a red‑black tree or an array indexed by file descriptor for O(1) lookup; Memcached uses a hash table with chaining and a background thread for slab expansion.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITFLY8 Architecture Home
ITFLY8 Architecture Home - focused on architecture knowledge sharing and exchange, covering project management and product design. Includes large-scale distributed website architecture (high performance, high availability, caching, message queues...), design patterns, architecture patterns, big data, project management (SCRUM, PMP, Prince2), product design, and more.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
