[go: up one dir, main page]

DEV Community

vikash-agrawal
vikash-agrawal

Posted on • Edited on

Distributed Memory Caching

There are 2 kinds of in memory data storage system available:

Redis

  • Redis is a single threaded system.
  • It can be scaled horizontally easily.
  • Size of the key and value can go upto 512 MB each.
  • Following 5 types of data types available:
    • String
    • Hash
    • List
    • Set
    • Sorted Set
  • Any kind of CRUD operations can be performed on a field level of the given data.
    • which means the application doesn't need to load the entire data.
  • There are multiple eviction policy available:
    • No Eviction: On reaching the memory limit, it throws the error.
    • All Keys LRU: Remove keys by least recently used.
    • Volatile LRU: Remove keys, that have an expiration time set, by the least recently used first.
    • All Keys Random: Remove keys randomly.
    • Volatile Random: Remove keys, that have an expiration time set, randomly
    • TTL: Remove keys, that have expired wrt time.
  • There are 2 kind of back up supported:
    • RDB Snapshot: This snapshot happens periodically.
    • AOF: Append only file is perform for every write operation. It can slow down the write operation but ensures the data availability.

Memcached

  • Memcached is a multi threaded system.
  • It can be scaled vertically easily.
  • Size of the key can be upto 250B and value can be upto 1 MB.
  • Horizontal scaling is possible through client side complex algorithm.
  • It's just on String Data Type.
  • Not possible to perform any operations on a field level of the given data.
    • which means the application needs to load the entire data.
  • It works on LRU eviction policy only. • It's a distributed memory cached object storage. • It has 4 components:
o Client software: fetch the list of available servers.
o Server software: A logic to store and retrieve the value for the passed key.
o Expiry: Mechanism to remove the older contents based on the time expiry.
o Client based hashing algorithm: to fetch the corresponding server.
Enter fullscreen mode Exit fullscreen mode

• The cached data is stored in the RAM so when RAM runs out of memory, it does the clean up.
• There is no fault tolerance means it doesn't share the data with other servers.

Top comments (0)