Live data from Hacker News

In praise of memcached

jchri.st

101–110 of 113 posts

Re: In praise of memcached

#101
The comment about memcached being ephemeral is orthogonal to whether people will use it as if it persistent. If the cache appears to get hit 99.9% of the time and is always there, sooner or later people will write code that relies on that behavior.

Maybe the client libraries can help by returning nulls 10% of time, in dev mode?

Re: In praise of memcached

#103

Burning memory for a pure memory/RAM service like memcached in today's environment is not going to work given the price of memory and especially for larger customers. Especially in cloud environments, it's going to be inordinately expensive so having hybrid solutions like Redis and their flash memory solution is probably going to be the compromise going forward.

[deleted]

Re: In praise of memcached

#104
I remember one "fun" feature in Memcached, is that each client did it's own hashing/sharding system... and when trying to share cached values across platforms/languages in order to further reduce resources, that was fun... writing a custom .Net/C# client to match the Java implementation. This was in the .Net 1/2 timeframe around 2002-2003 before NuGet.

That said, it's interesting when you learn in practice that sometimes an N+1 problem is actually faster as N+1 than trying to query across separate DBMS systems.

Re: In praise of memcached

#105
post #82
post #62

Earlier quoted context omitted.

"Communication itself isn't free, after all" Off topic, but that's my problem with microservices, devs seem to be totally unaware of this.

That's a decade old take. I don't think people are doing microservices and more.

More than two decades, folks were grumbling about this in the SOA days.

Re: In praise of memcached

#106

I think I've seen all of the Redis/Valkey issues the author mentioned in production. * Outages where Valkey had no memory policy, ate all the memory, and then caused write errors to its append-only file. Bonus points for another one where the disk itself was full, and AOF writes failed. * 500s where Redis was fully expected to be live, running, and populated with data for every user, and no fallback to a slower path.…

I tend to write an abstraction interface, if there isn't already one, where you request a key and pass an async function/lambda that will return the value from source in case of a cache miss.

    var value = cache.lookup(
      keyname, 
      () => db.query(...), 
      TimeSpan.FromMinutes(5) // or CacheOptions
    );
This way it can fallback/insert on a cache miss directly...

Re: In praise of memcached

#107

I think I've seen all of the Redis/Valkey issues the author mentioned in production. * Outages where Valkey had no memory policy, ate all the memory, and then caused write errors to its append-only file. Bonus points for another one where the disk itself was full, and AOF writes failed. * 500s where Redis was fully expected to be live, running, and populated with data for every user, and no fallback to a slower path.…

Once someone decides they want to use redis as something other than a cache, you sort of do have 2 cache technologies anyway. You can't use a redis instance that is configured for caching for any other purpose (caching instance must have eviction, non-caching instance must not have eviction). You need a second redis with a different configuration. Honestly designing your app to have a "memcache-friedly cache layout"…

Redis can also cache sets with correlated sub-data as part of the model/eviction pattern.. this can give you trends beyond simple k/v

Re: In praise of memcached

#108
There's nothing about memcache that avoids these problems.

Back in the mid-2000s I worked on a scaled system that used memcache, and developers fell victim to all the exact same problems that are cited with Redis in the article.

- Developers attempting to endrun every one of the laws of distributed systems by using memcache.

- We had cache addiction, so the fleets got sized on the assumption that memcache was up, and then memecache had a problem, and suddenly we were DDOSed.

- write amplification, where one host would nuke a high-TPS key and every other host would DDOS a dependency to repopulate the key.

- hot keys which led to hot hosts and because we cohosted memcached with the service daemons, it meant mystery CPU spikes.

- stickiness from stale DNS entries causing memcache calls to blackhole.

Every single one was avoidable by using memcache in a better way, but the temptation to abuse it was too strong.

Re: In praise of memcached

#109

I remember one "fun" feature in Memcached, is that each client did it's own hashing/sharding system... and when trying to share cached values across platforms/languages in order to further reduce resources, that was fun... writing a custom .Net/C# client to match the Java implementation. This was in the .Net 1/2 timeframe around 2002-2003 before NuGet. That said, it's interesting when you learn in practice that somet…

> it's interesting when you learn in practice that sometimes an N+1 problem is actually faster as N+1 than trying to query across separate DBMS systems.

This is specially visible in SQLite workflows.

The roundtrip for querying a local SQLite file is so fast that it's passable to execute N SELECTS inside a loop instead of a single SELECT with a JOIN, for example.

Re: In praise of memcached

#110

One other feature of memcache that is rarely mentioned is that all operations are O(1) by design, which is a conscious design choice from the authors: yes, it is limiting, but it also ensures no random stalls on simple operations, whereas Redis with its single-threaded core design can't guarantee that since you can run operations of arbitrary complexity (which surely as a developer make you feel very smart about it)…

[flagged]
Post reply on HN