Search code examples
databasedistributed-computingignite

How does Ignite handle affinity when lots of items have the same affinity keys


In the example given for affinity keys (https://apacheignite.readme.io/docs/affinity-collocation), it is suggested that giving different Persons the same affinity key (i.e. the company ID) makes it so that all Persons associated with the same Company get stored on the same node. My question is about how this scales when there are a very large number of items with the same affinity key.

For example, say there is one company with a billion employees. If you set affinity key for all of those billion employees to the same company ID, does this force a single node to own all billion employees, even if they don't all fit in RAM? If this is true, what are some of the typical solutions to this type of scaling issue?

Thanks for your help! :)


Solution

  • The main idea behind colocation is to ensure that all the entries with the same key belong to the same Ignite node to avoid network roundtrips.
    So, yes, if you set the same affinity key for a billion employees all of them will end up on the same node.
    In such a case, you could configure Ignite native persistence.
    As well, a composite key could be introduced for the Company that will allow partitioning companies by some criteria, for example

    public class CompanyKey {
        ...
        private Long id;
        private Long partitioningCriteria;
    }