Chris Salzberg
Chris Salzberg
  • @shioyama

Staff Engineer @ Shopify from Montreal, living and working in Japan. I'm the author of Mobility, a pluggable translation framework for Ruby, and committer to many open-source projects including Rails.

Caching With MessagePack

An object cache is like magic: put an object into the box and it comes back later, exactly as it went in. The magic is seductive because it makes things so easy.

It only takes a bit of thought, however, to see the dangers of this trick. Class names can change; a method can return a different result. Objects exist in a universe, and that universe is constantly evolving.

Marshal, Ruby's default binary serialization library, does not handle changes like this gracefully. We discovered this recently when a code change collided with a cached class, leading to a fire in production.

To avoid incidents like this, we switched the cache serializer in our core Rails monolith from Marshal to MessagePack, an alternative, generic binary serializer. MessagePack has a more compact format than Marshal, with stricter typing and less magic.

In this talk, I'll crack open MessagePack to show how it works, how we migrated to it, and why you might want to do the same.

Presentation Material

Recorded video