Dashboard > GridGain User Guide > Table Of Contents > Developers Guide > Load Balancing SPI > GridRoundRobinLoadBalancingSpi
GridRoundRobinLoadBalancingSpi
Added by morpheus, last edited by morpheus on Feb 05, 2008  (view change)
Labels: 
(None)


Click on Javadoc link to open Javadoc documentation.

Package

org.gridgain.grid.spi.loadbalancing.roundrobin Javadoc

Available starting with GridGain

Description

GridRoundRobinLoadBalancingSpi Javadoc iterates through nodes in round-robin fashion and pick the next sequential node. Two modes of operation are supported: per-task and global (see GridRoundRobinLoadBalancingSpi.setPerTask(boolean) Javadoc configuration parameter).

When configured in per-task mode, implementation will pick a random starting node at the beginning of every task execution and then sequentially iterate through all nodes in topology starting from the picked node. This is the default configuration and should fit most of the use cases as it provides a fairly well-distributed split and also ensures that jobs within a single task are spread out across nodes to the maximum. For cases when split size is equal to the number of nodes, this mode guarantees that all nodes will participate in the split.

When configured in global mode, a single sequential queue of nodes is maintained for all tasks and the next node in the queue is picked every time. In this mode (unlike in per-task mode) it is possible that even if split size may be equal to the number of nodes, some jobs within the same task will be assigned to the same node if multiple tasks are executing concurrently.

Configuration

The following configuration parameters can be used to configure GridRoundRobinLoadBalancingSpi Javadoc :

Setter Method Description Optional Default
setPerTask(boolean) Javadoc Configuration parameter indicating whether a new round robin order should be created for every task. If true then load balancer is guaranteed to iterate through nodes sequentially for every task - so as long as number of jobs is less than or equal to the number of nodes, jobs are guaranteed to be assigned to unique nodes. If false then one round-robin order will be maintained for all tasks, so when tasks execute concurrently, it is possible for more than one job within task to be assigned to the same node. Yes Default is true

Examples

As any GridGain SPI, GridRoundRobinLoadBalancingSpi Javadoc SPI can be configured either directly from code or from Spring configuration file. Here is an example of GridRoundRobinLoadBalancingSpi configuration from code:

GridFifoQueueCollisionSpi colSpi = new GridFifoQueueCollisionSpi();GridRandomLoadBalancingSpi = new GridRandomLoadBalancingSpi();
 
// Configure SPI to use global round-robin mode.
spi.setPerTask(false);

GridConfigurationAdapter cfg = new GridConfigurationAdapter();

// Override default load balancing SPI.
cfg.setLoadBalancingSpi(spi);

// Start grid.
GridFactory.start(cfg);

or from Spring configuration file

<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
    ...
    <property name="loadBalancingSpi">
        <bean class="org.gridgain.grid.spi.loadbalancing.roundrobin.GridRoundRobinLoadBalancingSpi">
            <!-- Set to global round-robin mode. -->
            <property name="perTask" value="false"/>
        </bean>
    </property>
    ...
</bean>


For more information about using Spring framework for configuration click here.

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006) - Bug/feature request - Contact Administrators