Databases 33 min read

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.

ITFLY8 Architecture Home
ITFLY8 Architecture Home
ITFLY8 Architecture Home
Inside Memcached vs Redis: Architecture, Memory, and Persistence

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.

Event model comparison
Event model comparison
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CacheredisPersistenceevent loop
ITFLY8 Architecture Home
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.