[CalendarServer-users] Multiple Memcached servers

Rob Archibald rob at robarchibald.com
Mon Feb 20 10:08:49 PST 2017

Ok, makes sense, but that’s a bummer, especially since the memcache library in python already supports multi-server memcached (http://stackoverflow.com/questions/4038094/using-multiple-memcache-servers-in-a-pool). 


Not sure yet, but I’ll probably just use https://github.com/twitter/twemproxy which is a reverse proxy to actual memcached servers. It’s written by Twitter and works well from what I’ve read. I tried using https://github.com/zobo/mrproxy which proxies memcached protocol to Redis since I already had Redis servers but had issues getting that working for some reason. I’ll report back when I get one or the other working in case others are interested.



Rob Archibald


From: dre at apple.com [mailto:dre at apple.com] 
Sent: Monday, February 20, 2017 9:46 AM
To: Rob Archibald
Cc: calendarserver-users at lists.macosforge.org
Subject: Re: [CalendarServer-users] Multiple Memcached servers




CalendarServer doesn't have the ability to directly access more than one memcache server per pool, and although you can bind "HandleCacheTypes" to specific pools, that doesn't let you distribute data within a cachetype.


To properly spread the load across multiple memcache servers, there needs to be a strategy for mapping the keys to one of the memcache services, which is already a feature of couchbase, and is known to work with CalendarServer. In this setup, couchbase reverse proxies to other cousebase nodes for a non local key, a behavior implemented both in their server and / or a local process that has no data store and is just a proxy.



On Feb 18, 2017, at 7:18 PM, Rob Archibald <rob at robarchibald.com> wrote:

One of the benefits of Memcached is that it allows you to spread caching load across multiple servers. From looking at the config file for Calendar Server, it looked initially to me that it would support multiple Memcached servers, but now I guess I’m not so sure.  This is how php handles multi-server configuration:



    "", //web1

    "", //web2

   "", //web3



I did a quick search of the code and I think I’ve found the connection method for memcache. I found this in txdav/who/cache.py so let me know if I’ve gone to the wrong place. It looks like it is only able to handle one server (hightlighted below). Am I missing some secret method to allow for multi-server memcached? 


def _getMemcacheClient(self, refresh=False):


        Get the memcache client instance to use for caching.


        @param refresh: whether or not to create a new memcache client

        @type refresh: L{bool}


        @return: the client to use

        @rtype: L{memcacheclient.Client}


        if refresh or not hasattr(self, "memcacheClient"):


            if config.Memcached.Pools.Default.MemcacheSocket:

                client_addr = "unix:{}".format(config.Memcached.Pools.Default.MemcacheSocket)


                client_addr = "{}:{}".format(




            self.memcacheClient = ClientFactory.getClient([client_addr], debug=0, pickleProtocol=2)

        return self.memcacheClient


calendarserver-users mailing list
calendarserver-users at lists.macosforge.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-users/attachments/20170220/5f9d9b8b/attachment-0001.html>

More information about the calendarserver-users mailing list