Does a Memcached client hold unused keys in memory?

103 views Asked by At

I have multiple services which need Memcached (e.g. "book service", "customer service"). I have two options:

  1. Set up one AWS Elasticache cluster and share it, using a prefix scheme for the keys "book-service-key1", "customer-service-key1" etc.
  2. Set up one cluster per service.

If all services use the same cluster (option 1), will "book service" hold all the Memcached data used by "customer service" in memory, even if it has never used any of these keys?

My question stated in other words: If I start a memcached client and join it to a cluster, will it replicate and hold all the data, or only data which it accesses?

1

There are 1 answers

0
pratikvasa On BEST ANSWER

Memcache Client will not hold any data so there should not be an issue of one service holding data from an other service.

Also creating multiple clusters for each service will add to an overhead of maintaining multiple clusters. Also utilisation will be very poor in such a scenario where you would need to keep a buffer for extra objects to be stored.

If you can manage key naming properly where you can avoid conflicts it would be great to have a single cluster of at least 2-3 machines.

One more thing to consider is have smaller instances rather than 2 or 3 huge instances. So that failure of one memcache instance can be absorbed by the DB easily.