In Praise of Memcached

(jchri.st)

62 points | by j03b 2 hours ago

7 comments

  • tempest_ 38 minutes ago
    I stopped using memcached a decade a go in favour of Redis and now use valkey.

    Never felt the need to go back to memcached except when a legacy dependency needed it.

    • jimbokun 17 minutes ago
      OK.

      What do you think of the argument made in the article?

  • jszymborski 39 minutes ago
    An article praising memcached and no mention of the feral bunny mascots.
    • abound 33 minutes ago
      > And look at those cute little mascots at the top!
  • kijin 1 hour ago
    Redis works great as a cache, but there are a few things you need to do in order to use it reliably as a cache.

    1) Wrap your client library so that it's impossible to store anything without an expiry date. You don't want 6-months-old data suddenly coming up in your app!

    2) Either turn off persistence, or use a separate database for the cache. In other words, don't mix volatile data with stuff you actually care about.

    3) Set up a reasonable maxmemory value with an appropriate maxmemory-policy, so that Redis doesn't eat up all your RAM.

    4) Resist the urge to use complex data structures. If you try to update a single field on an expired hash, you will end up with an incomplete object.

    If you don't want all that hassle, then yes, Memcached probably works better out of the box.

    • dvt 49 minutes ago
      > 1) Wrap your client library so that it's impossible to store anything without an expiry date. You don't want 6-months-old data suddenly coming up in your app!

      No need for this client-side complexity, as you should be using `allkeys-lru`. FWIW, should likely be doing this anyway, as (generally speaking) all data stored in Redis is usually regarded as volatile because of what Redis actually is.

  • dvt 1 hour ago
    Memcached is meant to be a lightweight memory cache, which makes sense, but contrary to the article's claim that "Redis is brought into a stack as a cache, and it is run with the assumption that people treat it that way"—I have very very rarely experienced this. Redis is brought into a stack because (most importantly!) it's fast and (almost as importantly!) because it's simple. I don't think this article is written by AI, but (and I'm trying to be charitable here), it's just like.. dumb.

    > Dealing with memcached downtime is incredibly easy, because client libraries generally ignore connection exceptions. For instance, a simple get will just return the default value (or none) if the server is down.

    This is a terrible idea in the context of things that might use Redis. If you use Redis with some kind of complex state (say, a document if you're working on a Notion clone, for instance), wtf even is a "default value"? In fact, I actually also want to know when the thing is down.

    > Clustering memcached is wonderful, because memcached actually has no clustering built-in.

    Yeah bro, this is yet another one of the reasons people use Redis: it handles consensus and clustering for you. What even is this article? It's a master class in straw-manning architectural decisions: most people use hammers as hammers, but screwdrivers make great hammers too, especially if you also need to screw stuff in! I mean.. technically true?

    • groundzeros2015 42 minutes ago
      > it handles consensus and clustering for you

      Considering how complex and error prone this is, I don’t want it in my stack.

    • foobarian 47 minutes ago
      The memcache slab pools are a leaky abstraction that you may end up having to manage operationally, and it's another way Redis is simpler.
    • jszymborski 41 minutes ago
      > wtf even is a "default value"?

      The article mentions the default value is a null, which would be the cue to run whatever computationally expensive op or query the db or hit the disk etc... that you would normally run if you had no cache to begin with.

      > but screwdrivers make great hammers too

      I don't know what your screwdrivers look like but that sounds like a rough time.

  • masa-kozu 1 hour ago
    [flagged]
    • CBLT 1 hour ago
      I'm not really sure memcached optimizes for operational simplicity. The only time I've run it at scale, it would have low cpu utilization then unexpectedly hit lock contention and fall over without warning.
  • abofh 1 hour ago
    Oh God I'm tired of ai written thought pieces
    • hoppoli 27 minutes ago
      I see this comment frequently in this site and it doesn't provide any value. If this isn't part of the hackernews rules, I hope it becomes one soon.
    • newfocogi 1 hour ago
      I don’t think LLMs would write this:

      “Anyways, 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.”

      • abofh 40 minutes ago
        So many it's not X it's Y. It might have been polished, but it was claude
      • newfocogi 1 hour ago
        Or this:

        “None 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.”

        • chipotle_coyote 44 minutes ago
          It's become de rigueur on HN to accuse any article one thinks is trite, obvious, or simply disagreeable of being AI-written. ("That comment has three items in a list! No human would ever put three items in a list! Checkmate, bot!")
    • poly2it 1 hour ago
      I don't see how this is AI-written?
    • throw310822 52 minutes ago
      Somebody call Deckard.