Session Ready
Exercise

Load balancing

You will now test the effect of load balancing in a situation with uneven task processing times. We create such situation by applying the sleep function on the workers side to a heterogeneous set of run times.

In your workspace there is a vector tasktime containing simulated processing times of 30 tasks (generated using runif()). There is also a cluster object cl with two nodes.

Your job is to apply the function Sys.sleep() to tasktime in parallel using clusterApply() and clusterApplyLB() and benchmark them. The parallel and microbenchmark packages are loaded. We also provided functions for plotting cluster usage plots called plot_cluster_apply() and plot_cluster_applyLB(). Both functions use functionality from the snow package.

Instructions
100 XP
  • Benchmark the functions clusterApply() and clusterApplyLB(). Both functions apply the Sys.sleep() function to the vector tasktime using the cl cluster.
  • Create cluster usage plots using plot_cluster_apply() and plot_cluster_applyLB() while passing the same arguments (in the same order) as to clusterApply() and clusterApplyLB() in the step above.