
Quite often we are being asked this question:
If I have multiple cores on a box, should I start as many GridGain instances as there are cores, or will one GridGain instance take full advantage of all the cores?
GridGain is a grid computing platform, and users want to squeeze out every possible CPU cycle to make their apps perform better on the grid.
Firstly, let me say that if your application is multi-threaded, then it is already taking advantage of multiple cores. In Java, threads will use all the available cores by default. So, if you are using GridGain to grid-enable your application, your application will take advantage of multiple cores just because GridGain is multi-threaded on its own.
However here are some potential benefits you may gain by starting up to N or N-1 GridGain instances on the same box, with N being the number of cores available.
1. Single threaded execution tends to perform slightly better just because there is less of thread context switching that JVM needs to worry about.
2. By starting multiple instances of GridGain, you can often allocate more heap memory to your grid nodes. Each JVM will be able to provide the system maximum, assuming that your machine can support that. This will perform better than multiple threads competing for the same Heap memory. Also, if you use multiple GridGain instances on the same box, your GC pauses on each JVM will be shorter compared to one JVM managing all the heap.
So, the answer to the above question is -
it depends. Some applications may benefit from the above factors, others will not. Generally it's better to start off with one GridGain instance, run 2 grid tasks, then start another GridGain instance on the same box and see if the same 2 tasks will execute faster.
Add a comment