There’s a backend service that holds 2 instances on AWS. Service is communicating messages via actors. So, actors are created when the websocket request comes to the backend service. An actor can be created on instance1 or instance2. It’s randomly balanced by the environment. When I need to find an actor and send a message in a specific scenario, actors misbehave since the service is having multiple instances. Let’s say the expected actor need to find has been created on instance1. But my message is going to instance2. Due to that, the actor does not get the message. When I send it again, sometimes the actor gets the message. This issue is not happening when the service is having only 1 instance. Anyone can help me here? How to correctly handle this? Do I need to use Akka Cluster? how to pass messages between correct instances? Should it be done on devops side?
Akka Cluster (and particularly Cluster Sharding if, as seems to be the case, the actors have a meaningful identity) solves this.
So I will have to implement the Akka cluster here?
No you don’t strictly have to use clustering. I think the real problem here is that you aren’t providing enough detail for people to understand what you are doing. And I think you are struggling understanding some of the basic concepts.
But, if you are struggling with discovering things over a distributed network, then Cluster has multiple components that will make your life easier. Both from discovery, to reliability, to maintaining uniqueness, Akka Cluster (and its related components like sharding) will help you.