DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Performance and Scalability Analysis of Redis and Memcached
  • Beyond Keys and Values: Structuring Data in Redis
  • Build a Data Analytics Platform With Flask, SQL, and Redis
  • How To Manage Redis Cluster Topology With Command Line

Trending

  • The Agent Protocol Stack: MCP vs. A2A vs. AG-UI
  • Zone-Free Angular: Unlocking High-Performance Change Detection With Signals and Modern Reactivity
  • What Nobody Tells You About Multimodal Data Pipelines for AI Training
  • How to Test a PATCH API Request With REST-Assured Java
  1. DZone
  2. Data Engineering
  3. Data
  4. Redis vs Memcached: Which One to Pick

Redis vs Memcached: Which One to Pick

When people talk about the Performance Improvement of an application, the one integral factor that everyone considers is server-side caching. Identifying the...

By 
Anji K user avatar
Anji K
·
Sep. 30, 20 · Analysis
Likes (6)
Comment
Save
Tweet
Share
8.0K Views

Join the DZone community and get the full member experience.

Join For Free
Redis vs MemCached

When people talk about the performance improvement of an application, the one integral factor that everyone considers is server-side caching. Identifying the right cache provider that suits the requirement is an integral part of adopting the server-side caching.

Redis and Memcached are widely used, open-source cache providers across the world. Most of the Cloud providers support Redis and Memcached out of the box.

In this article, I would like to share similarities and differences between the Redis and Memcached and when do we need to go for Redis or Memcached.

Similarities between Redis vs Memcached
  • Key-value pair data stores
  • Supports Data Partitioning
  • Sub-millisecond latency
  • NoSQL family
  • Open-source
  • Supported by the Majority of programming languages and Cloud providers

DataTypes Supported

Memcached: Supports only simple key-value pair structure

Redis: Supports data types like strings, lists, sets, sorted sets, hashes, bit arrays, geospatial, and hyper logs.

Redis allows you to access or change parts of a data object without having to load the entire object to an applicational level, modify it, and then re-store the updated version.

Memory Management

Memcached: Strictly in memory and extended to save key-value details into drive using an extension extstore

Redis: Can store the details to disk when the physical memory is fully occupied. Redis has the mechanism to swap the values that are least recently used to disk and the latest values into the physical memory.

Data Size Limits

Memcached: Can only store the data of size up to 1 MB

Redis: can store the data of size up to 512 MB (string values)

Data Persistence

Memcached: Doesn't support data persistence

Redis: Supports data persistence using RDB snapshot and AOF Log persistence policies

Cluster Mode (Distributed caching)

Memcached: Memcached doesn't support the distributed mechanism out of the box. This can be achieved on the client-side using a consistent hashing strategy

Redis: Supports distributed cache (Clustering)

Multi-Threading

Memcached: Supports multithreading and hence can effectively use the multiple cores of the system

Redis: Doesn't support multi-threading

Scaling

Memcached: can ve vertically scalable. Horizontal scalability is achieved from the client-side only (Using consistent hash algorithm)

Redis: Can be horizontally scalable

Data replication

Memcached: Doesn't support data replication

Redis: Supports data replication out of the box. Redis Cluster introduces the master node and slave node to ensure data availability. Redis Cluster has two corresponding slave nodes for redundancy.

Supported Eviction Policies

Memcached:
  • Least Recently Used (LRU)
Redis:
  • No Eviction (Returns an error if the memory limit has been reached when trying to insert more data)
  • All keys LRU (Evicts the least recently used keys out of all keys)
  • Volatile LFU (Evicts the least frequently used keys out of all keys)
  • All keys random (Randomly evicts keys out of all keys)
  • Volatile random (Randomly evicts keys with an "expire" field set)
  • Volatile TTL (Evicts the shortest time-to-live and least recently used keys out of all keys with an "expire" field set.)
  • volatile LRU (Evicts the least recently used keys out of all keys with an "expire" field set)
  • volatile LFU (Evicts the least frequently used keys out of all keys with an "expire" field set)

Transaction Management

Memcached: Doesn't support transactions

Redis: Support transactions

Memcached is recommended when dealing with smaller and static data. When dealing with larger data sets, Memcached has to serialize and deserialize the data while saving and retrieving from the cache and require more space to store it. When dealing with smaller projects, it is better to go with the Memcached due to its multi-threading nature and vertical scalability. Clustering requires a considerable amount of effort to configure the infrastructure.

Redis supports various data types to handle various types of data. Its clustering and data persistence features make it a good choice for large applications. Additional features like Message queue and transactions allow Redis to perform beyond the cache-store.

In addition to the above-mentioned features, Redis supports the below features as well

  • Message queuing support (Pub/sub)
  • snapshots for data archiving/restoring purpose
  • Lua scripting

Conclusion: Redis and Memcached both can perform very well as a Cache store. Which one to pick varies from project to project.

It is wise to consider the pros and cons of the providers right from the inception phase to avoid changes and migrations during the project.

Hope you enjoyed the article. Please share your thoughts/ ideas in the comments box. Thank you for reading it.

References: https://medium.com/@Alibaba_Cloud/redis-vs-memcached-in-memory-data-storage-systems-3395279b0941
Redis (company) Memcached Data (computing)

Published at DZone with permission of Anji K. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Performance and Scalability Analysis of Redis and Memcached
  • Beyond Keys and Values: Structuring Data in Redis
  • Build a Data Analytics Platform With Flask, SQL, and Redis
  • How To Manage Redis Cluster Topology With Command Line

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook