Scaling Memcache at Facebook (2021)
micahlerner.com
micahlerner.com
- memcache had little to no observability, it made debugging cache issues a nightmare. Redis on the other hand is a dream to work with on that front, from the cli that is well thought out to the fact you can copy the db file to your machine and go at it, it's just a much better developer experience.
- Data structures, Redis' lists, hashes and sets meant we could represent a lot of a stuff as is in cache with no need for costly serializing. It also meant the data layer code was simpler than the memcached equivalent.
- Built in pub/sub, we used it for tons of stuff and the fact it came built in was big as prior to that we had to provision specific stacks to get the same functionality (and it wasn't has nice to use.
memcache has its use but for the little advantages it gave (perf wise) Redis just buried it in developer experience.
Or it could be any of the features that Redis has which memcached does not that contributed to this outcome.
- Redis documentation is very good, likely leading to more adoption
- Most applications are not performance limited, but developer resource limited, making performance considerations secondary
I vaguely remember their front page used to have Facebook as their sponsor. Considering that is no longer the case or I remembered it wrong. Does Facebook still uses Memcache?
[1] https://github.com/memcached/memcached/wiki/ReleaseNotes1621
But I would also guess that FB would have to explain lots of their middleware concepts in order to explain how data in the database maps to memcache keys defined in middleware.
Personally, I think the hard part is ensuring the entire company/system accesses data through the correct abstractions (eg. the newest data model code) and does not bypass the data model code (eg. by hitting the database directly).
There’s also support for read after write consistency within a single cluster by adding a canary to the memcache key warning to read from the master replica after the write succeeds, that’s a really cool feature for a multi region eventually consistent system