2

I am planning to use django-cachalot with memcached backend for caching of queries in my project.

I have this setup on a Elastic Beanstalk, which can scale up or scale down, by adding or removing EC2 instances. Currently when memcached starts on an instance, I add the IP of this instance to the database.

The pylibmc memcached client that I create, reads the database occasionally, for server IPs and creates a new client if server IPs have changed or new IPs have been added.

How do I dynamically add servers to django's memcached cache backend? or how do I set the memcached client django is using manually?

Optimus
  • 2,716
  • 4
  • 29
  • 49

1 Answers1

0

This is probably a lot of effort for very little gain. Bear in mind that django distributes the objects that you cache between the different memcached servers that you have defined. Thus when one is taken out of consideration by autoscaling all the items in it will be lost.

By default django does not support dynamically adding new memcached servers to the list. To make it work you will have to create a custom cache backend by modifying the default memcached backend

e4c5
  • 52,766
  • 11
  • 101
  • 134
  • That's exactly what I am doing. i.e. creating a custom cache backend. I have kept `num_replicas=4` so `memcached` creates copies of the cache and we loose minimum cache while auto-scaling – Optimus Oct 30 '15 at 11:29