{"slug": "in-praise-of-memcached", "title": "In praise of memcached", "summary": "A sysadmin argues that memcached is often a better caching solution than Redis because its simpler architecture enforces treating it as a volatile cache, avoiding the common pitfall of using Redis as a persistent database. The author praises memcached's easy downtime handling, client-side clustering, and lack of persistence, making it ideal for stateless workloads.", "body_md": "If you happen to find yourself in a sysadmin position, or a position where you\njust so happen to maintain [someone’s\ninfrastructure](https://github.com/python-discord/infra), chances are that at\nsome point in time the topic “we need a cache” comes up.\n\nYou think for a moment and reach out for Redis, because you’re used to it, it’s fully featured, and it works! You remember it being a good, solid cache, and you wonder which new features recent releases have brought, and head to its homepage:\n\nYour agents aren’t failing. Their context is.\n\nInquiring agents want to know:How can I use Redis Iris as a real-time context engine for AI apps?\n\n[1]\n\nRight, so probably something with AI 2. This is sort of understandable, because\nRedis is a company that wants to make money.\n\nAnyways, Redis homepage aside, you deploy it, and off you go - your trusty cache. You hand the connection string to the people who asked for it, and off you go.\n\n## Few months later\n\nAfter a while, it turns out that `cache.set(\"key\", \"value\")`\n\nis a really simple\nabstraction, and definitely easier than `INSERT INTO table VALUES ('key', 'value')`\n\n. People start treating the *REmote DIctionary Server* as something\nthat’s *always* there, something that *persists* data, something that is *a\ndatabase*.\n\nYou don’t know this. Your ops colleagues don’t know this. Therefore, your\nalerting doesn’t know this either, because you assume that people treat the\n*cache* as something volatile.\n\nYou find out that this has been going on when you happen to do something to Redis. Maybe you upgrade it, maybe you move it to another node, maybe your cat hits the eject button on your RAID0 server’s HDD tray.\n\nThe issue isn’t that Redis doesn’t have persistence, the issue is that usually,\nRedis is brought into a stack as a *cache*, and it is run with the assumption\nthat people treat it that way.\n\nUsually, by the time you realize this, it is already too late, and Redis is too intertwined in the app to really leave its place. Instead, you have the eternal pleasure of maintaining it and monitoring it like a pet.\n\n## Enter memcached\n\nFirst off - what’s a memcached? Easy, ask [its website](https://memcached.org/):\n\nWhat is Memcached?Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.\n\n[3]\n\nWow, first sentence on the page, even with code examples. And look at those cute little mascots at the top!\n\nMemcached is also a cache, similar to Redis. Chances are that you’re using a\nframework like Django, [which supports pluggable\ncaching](https://docs.djangoproject.com/en/6.0/topics/cache/) and allows you to\nswitch between different caching backends.\n\nBut **why should you use memcached** when it has much less features than Redis?\nHere are my reasons for why these days, I will always prefer memcached over\nRedis:\n\n-\nDealing with\n\n**memcached downtime** is incredibly easy, because client libraries generally ignore connection exceptions. For instance, a simple`get`\n\nwill just return the default value (or none) if the server is down. -\n**Clustering** memcached is wonderful, because memcached actually has no clustering built-in. To “cluster” it, you configure the client library with multiple URLs, and the client will select the target instance based on hashing the key. If a client-side call detects an instance as down,[4](#fn:4)[it removes the node from the hasher](https://pymemcache.readthedocs.io/en/latest/getting_started.html#using-a-memcached-cluster). After a certain time, the client will automatically attempt to reconnect and use the dead node. -\nmemcached “solves” the whole persistence issue, because it does not persist to disk. It is therefore a perfect fit to just being scheduled as a stateless workload wherever you desire it.\n\nNone of these things are impossible with Redis, it’s just that memcached’s architecture in general more leans towards these directions, which makes it much, much more straightforward from an operations point of view.\n\nBut because of memcached being such a relatively simple application (plus the fact that you can run dozens instances of it with ~64 MB cache size and close to no overhead), if I need a cache these days, I usually reach out to memcached.\n\nThat said, a lot of “database too slow” problems actually begin their life as “query too slow” or “missing indices”, so be a kind person and help your developers with optimizing their queries.\n\nAlso, if you’re curious about some of the decisions behind memcached, the\n[blog](https://memcached.org/blog) contains interesting posts, with one\npublished just in May: [“How Long Does That Response Take… For\nReal?”](https://memcached.org/blog/how-long-for-real/).\n\n-\n[https://redis.io/](https://redis.io/), accessed 2026-06-02[↩︎](#fnref:1) -\nThat said,\n\n[https://redis.io](https://redis.io)is probably not the best entrypoint for engineers, that website seems geared to people making purchasing decisions.[↩︎](#fnref:2) -\n[https://memcached.org](https://memcached.org), accessed 2026-06-02[↩︎](#fnref:3) -\nBonus points for using a service discovery mechanism to automatically generate this setting.\n\n[↩︎](#fnref:4)", "url": "https://wpnews.pro/news/in-praise-of-memcached", "canonical_source": "https://jchri.st/blog/in-praise-of-memcached/", "published_at": "2026-06-23 01:15:05+00:00", "updated_at": "2026-06-24 00:53:29.580298+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["memcached", "Redis", "Django", "Python Discord"], "alternates": {"html": "https://wpnews.pro/news/in-praise-of-memcached", "markdown": "https://wpnews.pro/news/in-praise-of-memcached.md", "text": "https://wpnews.pro/news/in-praise-of-memcached.txt", "jsonld": "https://wpnews.pro/news/in-praise-of-memcached.jsonld"}}