Search code examples
ignite

high throughput way of "increment" numerical value operation


I have a distributed cache of float (not int). My process will frequently increment these floats and access them occasionally.

If it's local, atomic float data structure (or float adder if there is one) with an increment method would probably be the best way to go. Non-blocking and async would be ideal, since the sequence of increment does not matter as long as each increment is conducted eventually.

What's the best way of incrementing numerical value to achieve high throughput?

My current method is:

  1. batch several increment operations for different key
  2. using invokeAll method in IgniteCache, passing in a CacheEntryProcessor which contains the increment value for each key.
  3. CacheAtomicityMode configuration is set to ATOMIC

Is this the best way to go?

Is there any configuration that I should pay attention to for performance boost, e.g. use binary format or on-heap memory or avoid unnecessary serialization?


Solution

  • I think you are definitely on the right track.

    Binary format will be used by default, so you do not need any special configuration for it. I do not think you should worry about serialization of floats, so I would not configure an on-heap cache, unless you run into performance issues.

    I also would suggest to take a look at internal implementation of IgniteAtomicSequence as it may give you more useful ideas.

    Lastly, I would suggest to implement it as Ignite service, which will allow you to provide a custom API tailored for this functionality.