Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Rolling update steps for Classic -> Typed Sharding #110

Open
wants to merge 9 commits into
base: 2.6
Choose a base branch
from

Conversation

patriknw
Copy link
Member

@patriknw patriknw commented Jun 19, 2019

DO NOT MERGE

This example illustrates how a rolling update from Classic to Typed Sharding can be performed.
Full cluster shutdown is of course easier but if zero downtime is needed it is possible with these steps.

See the commit diffs to see what needs to be done in this 3 phase rolling update.

roll 1 - Scala: 359e08d, Java: 47bf16a

  • update to Akka 2.6.x first
  • and add dependeny akka-cluster-sharding-typed although the actors remain untyped in first rollout
  • define akka.cluster.sharding.number-of-shards config
    • same value as you have used previously for number of shards
    • same value as you will use for Typed
    • otherwise Typed node will not be able to join in roll 2
  • add akka.cluster.sharding.typed.ShardingEnvelope to message extractor
  • sender and ask
    • add replyTo ActorRef to the messages that are using sender for the reply
    • change from akka.pattern.ask to akka.pattern.extended.ask to populate
      the replyTo field in the messages
    • use the replyTo field instead of sender() unless it is null

roll 2 - Scala: 0ceac95, Java: b415647

  • convert actors to Typed
  • use custom ShardingMessageExtractor in ClusterSharding.init
  • use same akka.cluster.sharding.number-of-shards config as was in roll 1

roll 3 - Scala: b27976b, Java: dc25a53

  • custom ShardingMessageExtractor can be removed

Refs akka/akka#26718

@patriknw
Copy link
Member Author

Another thing I will try is to have response messages that originally were sent to sender().

@patriknw patriknw force-pushed the wip-rolling-update-typed-patriknw branch from 5294705 to 483f612 Compare June 20, 2019 10:45
@patriknw
Copy link
Member Author

I have also tried messages with replies, and also ask. That also works in both directions if doing the preparations in the untyped version as in roll 1 commit. Note that it's using the akka.pattern.extended.ask which supports the replyTo in the message pattern. In the destination actor one can check if the replyTo field is populated or not and then reply to that or the sender().

@patriknw patriknw force-pushed the wip-rolling-update-typed-patriknw branch from 483f612 to 5d847f7 Compare July 12, 2019 08:26
@patriknw patriknw changed the base branch from wip-cleanup-sharding-patriknw to 2.6 July 12, 2019 08:27
@patriknw patriknw changed the title Rolling update steps for Untyped -> Typed Sharding Rolling update steps for Classic -> Typed Sharding Jul 12, 2019
* use ask for deviceId >= 40
* update to Akka 2.6.x first
* and add dependeny `akka-cluster-sharding-typed` although the actors remain untyped in first rollout
* define akka.cluster.sharding.number-of-shards config
  * same value as you have used previously for number of shards
  * same value as you will use for Typed
  * otherwise Typed node will not be able to join in roll 2
* add akka.cluster.sharding.typed.ShardingEnvelope to message extractor
* sender and ask
  * add replyTo ActorRef to the messages that are using sender for the reply
  * change from `akka.pattern.ask` to `akka.pattern.extended.ask` to populate
    the replyTo field in the messages
  * use the replyTo field instead of sender() unless it is null
* convert actors to Typed
* use custom ShardingMessageExtractor in ClusterSharding.init
* use same akka.cluster.sharding.number-of-shards config as was in roll 1
* custom ShardingMessageExtractor can be removed
* update to Akka 2.6.x first
* and add dependeny `akka-cluster-sharding-typed` although the actors remain untyped in first rollout
* define akka.cluster.sharding.number-of-shards config
  * same value as you have used previously for number of shards
  * same value as you will use for Typed
  * otherwise Typed node will not be able to join in roll 2
* add akka.cluster.sharding.typed.ShardingEnvelope to message extractor
* sender and ask
  * add replyTo ActorRef to the messages that are using sender for the reply
  * change from `akka.pattern.Patterns.ask` to `akka.pattern.Patterns.askWithReply` to populate
    the replyTo field in the messages
  * use the replyTo field instead of getSender() unless it is null
* convert actors to Typed
* use custom ShardingMessageExtractor in ClusterSharding.init
* use same akka.cluster.sharding.number-of-shards config as was in roll 1
* custom ShardingMessageExtractor can be removed
@patriknw patriknw force-pushed the wip-rolling-update-typed-patriknw branch from 5d847f7 to dc25a53 Compare November 6, 2019 13:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants