Hi Andrzej, your understanding is correct. If you use aggregateRootId for resolving shards, every shard in your system will have only one entry (actor) because extracted entry and shard identifiers would match for every message. I do not see it as a problem. In fact in this configuration rebalancing process would affect only one aggregateRootId per moved shard.
As for using only a part of UUID there is one catch particular to the way UUIDs are generated. There are several different versions of UUID and it is not guaranteed that if a UUID in its entirety is unique, a part of it is unique too. So I would suggest hashing it and then taking first N needed symbols from the hash itself. On Mon, Oct 6, 2014 at 3:00 PM, Andrzej Dębski <[email protected]> wrote: > Hello > > I wanted to integrate akka-cluster-sharding with my akka-persistence > application. I read the documentation and browsed through the code in > activator but one thing is still a bit of a mystery to me. > > Currently in my application each PersistentActor is identified by UUID > value. All messages that those actors receive inherit custom trait > DomainCommand > which has method aggregateRootId: UUID. Based on this and on > documentation my IdExtractor looks like this: > > val domainCommandIdExtractor: ShardRegion.IdExtractor = { > case command: DomainCommand => (command.aggregateRootId.toString, > command) > } > > Now what about ShardResolver. According to the documentation it says that: > > Try to produce a uniform distribution, i.e. same amount of entries in each >> shard. As a rule of thumb, the number of shards should be a factor ten >> greater than the planned maximum number of cluster nodes. > > > And in the example there is (id % 12).toString. > > I am wondering if it would be wrong to just return string representation > of UUID - that way I will have unique number of entries per shard because > ShardResolver > should return unique strings per PersistentActor. > > If I understand the documentation correctly it would result in 1 actor per > shard grouping (and if number of shards > number of nodes I will have > multiple shards on one node) - the drawback (I think) is that using this > scheme the large number of shards may cause problems during > rebalancing/adding new actor when the number of shards is large. > > If the scheme of just returning UUID value is not very good idea (be it > because of the reason I mentioned or the other one) should I use some > number of first characters from UUID so it will result in grouping of many > actors per shard? This way I will have 16, 256, ... possible return values > from ShardResolver > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- Martynas Mickevičius Typesafe <http://typesafe.com/> – Reactive <http://www.reactivemanifesto.org/> Apps on the JVM -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
