Versioning your protocol with Akka remoting

Hi all. We use Akka Cluster (2.5.22) to build the discovery service for a wider distributed system. One of the requirements for that system is that it be able to perform rolling upgrades.

Are there any guides, general patterns, or open source examples of how people do rolling protocol changes with Akka remoting/cluster? Where possible this would include more complex examples than simply adding a field to a message: e.g. actual protocol changes where new versions of actors might send or expect a slightly different set of messages all together.

Our current thinking is to basically have versions of actors namespaced by package, (v1.FooActor, v2.FooActor), have actors handshake on a version and then use that to decide which Actors to forward to/respond from. We’d then deal with any semantic differences in the actual data produced at the boundary between our Actor system and the rest of the application.

We usually handle this type of compatibility in the serializer.

Ideally your messages can be backward and forward compatible so that during a rolling deploy messags can go between actors running the old and new versions. This is possible in most cases when using protobuf serialization.

For the more complicated case where a new serialized format is required due to significant changes:

  • First release the new serializer so that messages can be deserialized
  • Then release the change to serialize to the new format, old nodes will be able to deserialize the new messages as the serialize was released in the previous step

Thanks for your response! So you don’t version the Actors themselves, only the messages? I was imagining a parent actor forwarding to different children to perform different behaviours.

That is good advice about introducing intermediate versions which clusters must roll through though :slight_smile:

That’s right. I am sure there are some limits to how far you can go doing it at the serialization level and there are probably use cases where you want to understand versions at the application level rather than just at the serialization level.