Load balancing is the process of distributing load among a set of processors in a smart way for exploiting the parallelism and minimize the response time. There are two main approaches to distributed load balancing: work sharing, in which processors try to equalize the load among them, and work stealing, in which idle processor request extra work.
The load balancing uses the migration to move objects from a node to an other : ProActive.migrateTo(object,node,false). (see Chapter 16, Active Object Migration for more details).
The load balancing need metrics to evaluate each node and so to take a decision. You can define your own Metrics (CPU Load, number of active objects, communication between active objects ...).
You must implement two classes : MetricFactory and Metric (package org.objectweb.proactive.loadbalancing.metrics).
You have to implements the method public Metric getNewMetric( ) which returns a new Metric.
There are two concepts : the rank and the load. The rank is used to compare two nodes without considering the load (ex: CPU mHz). The load can evoluate in time
Three methods have to be implemented :
public void takeDecision(LoadBalancer lb) : this method has to call lb.startBalancing( ) (overload) or lb.stealWork( ) (underload)
public double getRanking() : this method returns the rank of the node.
public double getLoad() : this method returns the load of the node.
There is two ways for using load balancing : manually in the application code or as a technical service.(see Chapter 26, Technical Service for more details).
In order to ease the use of the load balancing, we provide static
methods on the LoadBalancing
class. First of all, you
need to initialize the load balancing with the
MetricFactory as described in the previous paragraph. You can specify a
list of nodes at the initialization or later.
Node[] nodes; Node node; //... initialisation of nodes LoadBalancing.activateOn(nodes, new MyMetricFactory()); // or LoadBalancing.activate(new MyMetricFactory()); // to add a node LoadBalancing.addNode(node);
In your deployment descriptor, you have to define the load balancing technical service as following :
<technical-service id="LoadBalancingService" class= "org.objectweb.proactive.loadbalancing.LoadBalancingTS"> <arg name="MetricFactory" value="myPackage.myMetricFactory" /> </technical-service>This service has to be applied on a Virtual Node :
<virtualNode name="Workers" property="multiple" technicalServiceId="LoadBalancingService"/>
Sometimes, active objects can't migrate : non-serializable attributes ...; in that case, you have to specify that these objects have to be ignored by the load balancing mechanism.
So, these objects have to implement the interface org.objectweb.proactive.loadbalancing.NotLoadBalanceableObject
© 2001-2007 INRIA Sophia Antipolis All Rights Reserved