RE: Did anyone write custom Affinity function?

2018-12-19 Thread Stanislav Lukyanov
You could write a custom affinity function, and some people do, but as far as I 
can see you don’t need it.
You just chose a poor affinity key.

You need to have MANY affinity keys, much more than there are partitions, and 
have MANY partitions, much more than nodes.
That will make sure that the default affinity function distribute data properly.
But more importantly that will make sure that your system will scale well.
If you have number of groups equal to the number of nodes than you can’t just 
increase the number of nodes to scale – you need 
to change your data model as well. To scale properly you need to have your data 
model work with different number of nodes.

FYI Ignite used to have a different affinity function that always distributed 
partitions evenly.
It had some issues and was eventually replaced and removed, although people do 
try to bring it back time to time.
See 
http://apache-ignite-developers.2346864.n4.nabble.com/Resurrect-FairAffinityFunction-td19987.html

Thanks,
Stan

From: ashishb008
Sent: 19 декабря 2018 г. 9:09
To: user@ignite.apache.org
Subject: Re: Did anyone write custom Affinity function?

Yeah, we were planning to increase group IDs.
Did anybody write custom Affinity function? If it is already written that
will be helpful to us. 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/



Re: Did anyone write custom Affinity function?

2018-12-18 Thread ashishb008
Yeah, we were planning to increase group IDs.
Did anybody write custom Affinity function? If it is already written that
will be helpful to us. 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Did anyone write custom Affinity function?

2018-12-18 Thread Mikael

Hi!

3 different affinity keys on 3 nodes is not enough, it's a hash code 
that is used so you may end up with 2 groups (or even all 3) on one 
node, if you need it to work that way you will need to create your own 
affinity function.


Any way you might be able to increase the number of group id's in some 
way ? if you for example had 30 group id's you would have a much better 
distribution of the entries.


Mikael

Den 2018-12-18 kl. 15:14, skrev ashishb008:

Hello,

As of now, we have 3 nodes. We use group ID as affinity key, and we have 3
group IDs (1, 2 and 3). And we limit cache partitions to group IDs. Overall
nodes=group IDs=cache partitions. So that each node have equal number of
partitions.

But it doesn't distribute cache partitions across the nodes. What it does,
put 2 partitions on one node, 1 partition on another node, and nothing on
remaining one.

Thanks





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/



Re: Did anyone write custom Affinity function?

2018-12-18 Thread ashishb008
Hello,

As of now, we have 3 nodes. We use group ID as affinity key, and we have 3
group IDs (1, 2 and 3). And we limit cache partitions to group IDs. Overall
nodes=group IDs=cache partitions. So that each node have equal number of
partitions.

But it doesn't distribute cache partitions across the nodes. What it does,
put 2 partitions on one node, 1 partition on another node, and nothing on
remaining one.

Thanks





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Did anyone write custom Affinity function?

2018-12-18 Thread Mikael

Hi!

How many nodes do you have and what are you using for the affinity key ? 
there is of course a small chance that the distribution is not even but 
in most cases it will work fine as long as it has enough different 
values to choose from, but it depends a little bit on what you use for 
affinity key, say you have 10 nodes and you use a "customer id" as 
affinity key and you only have 8 customers it will not work of course.


Mikael

Den 2018-12-18 kl. 06:24, skrev ashishb008:

I want all nodes in a cluster to have equal number of cache partitions. With
default Affinity function it is not happening, why default does not use all
nodes in a cluster? Will it be okay to write custom Affinity function? And
what will we lose doing so? Did anyone write custom Affinity function?



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/