Monday, February 05, 2007

Finding the best node in OpenSSI cluster

When programming with OpenSSI's API (cluster.h & /lib/, there are times when you want to find out the best available node. There are two ways to find the best node.

1. Easy way - Use CLUSTERNODE_BEST macro

- Defined in cluster.h file.
- Returns physical memory address that points to the node number with the lowest load level, hence printf ("%d", CLUSTERNODE_BEST) will print some strange number.
- The speed at which this value gets updated is slow.
- Can't exclude nodes --> a node will be picked from all available nodes.

2. Alternate method - write your own function!

How do we know load levels of nodes?
- *_/proc/cluster/nodeN/load{_}* file contains node N's load level, hence we will compare all values and find the lowest node number.
- This is also useful if you want to find the best node from a specified group of nodes.
(e.g. Pick the best node from all nodes except for master node (Node 1))

I prefer to use #2 because it gives me more control. It is probably more costly to use, though.


chuixuejs said...

Hello! Mozilla Firefox web browser has updated,Please visit my blog,Free download Quickly

Frank said...

Note that load average isn't really the best way to determine the "best" target. You really also want to take into account CPU and I/O utilization as well as the amount of free memory. A node with a low load average could still be pegging the CPU and/or be doing lots of I/O or swapping, and so would probably not be the best choice.