0

I have a use case where a million individual actors will be created across the cluster.
The tasks will be received from outside cluster and i have to identify and send the task to assigned single actor for that task.

How can i create actor from outside of the cluster if i use Cluster sharding and how to send message to that particular actor from outside of the cluster nodes

If i use Cluster sharding i have to create seperate shard for a actor.Which means

Million shards have to created for million actors.

How to identify the shard and actor in cluster?

Levi Ramsey
  • 18,884
  • 1
  • 16
  • 30
Arun
  • 67
  • 11
  • Does this answer your question? [How to handle million individual actors with AKKA Cluster setup?](https://stackoverflow.com/questions/72057627/how-to-handle-million-individual-actors-with-akka-cluster-setup) – David Ogren May 06 '22 at 02:25

1 Answers1

3

If i use Cluster sharding i have to create seperate shard for a actor.

A shard is just a local grouping of actors that are all hosted in the same process - it's an arbitrary way of grouping entity actors together in Akka.NET. Typically we use consistent hashing (HashCodeMessageExtractor) to assign entity actors to a shard based on the entity actor's unique id, which you extract from the content of the messages sent to it via the ShardRegion and the IMessageExtractor (most commonly, a HashCodeMessageExtractor).

This is a great tool for being able to distribute millions of actors horizontally across a large cluster - I just published a sample the other day where I was running 200 Akka.NET nodes with 2000 total shards (10 per node) with the ability to host 10s of millions of actors: https://github.com/petabridge/AkkaDotNet.LargeNetworkTests - you might find that helpful!

Aaronontheweb
  • 8,224
  • 6
  • 32
  • 61
  • When a message arrives can we send it to particular Actor in a shard? How it will happen automatically for every message? – Arun May 06 '22 at 03:16
  • The `IMessageExtractor` will extract a unique identity from all messages sent to the `ShardRegion` - all messages belonging to the same unique identity are sent to the same actor. – Aaronontheweb May 06 '22 at 12:01
  • How to get that shardRegion actor reference from a node outside the cluster? – Arun Jun 08 '22 at 07:51
  • You'd need to have the nodes outside the cluster message actors that are inside it, and the actors inside the cluster can communicate with the `ShardRegion` via the `ShardRegion IActorRef` itself or via a `ShardRegionProxy`. – Aaronontheweb Jun 08 '22 at 14:00