Max Min Algorithm in Grid Computing with code in C

Here you will find the easiest explanation for max min algorithm in grid computing.

Let us first know why this algorithm is needed?

This is a static task scheduling algorithm used for load balancing.

Why we call it Max-Min when actually we are finding the minimum first then maximum?

This is because the semantics of saying Max-min means that the task with maximum execution time (heavier process ) is allocated to the machine with minimum completion time (best machine).

Let us take an example before moving to the code

Here Task 1 will execute in 140ms in VM1 and in 100 ms in VM2. Task 2 will execute for 20ms in VM1 and in 100ms in VM2 . Task 3 will run for 60 ms in VM1 and for 70 ms in VM2.

What is a Task ?

Let’s take an example. Suppose you have developed a social media app called fakebook. Now user one wants to change her DP , another user wants to create her account and the third user wants to like a picture.

All these are the tasks and involve manipulation in the database. The entity responsible for that change is the backend server. For effective use of the server you have made virtual partitions of the server making some virtual machines good for light computation and some virtual machines for heavy computation.

Algorithm to solve the problem

  1. Find minimum time for each task , in the above image minimum time for each task is (100 ms ,T1 ,VM2), (20 ms, T2, VM1) ,(60 ms, T3, VM1)
  2. Now find the set with maximum time and that is (100 ms, T1, VM2)
  3. Execute T1 in VM2 for 100ms
  4. Since 100ms has been elapsed we need to update our data. New data is:

5. Here we impute T1 as INT_MAX(2³¹) to let our code know that this task is over and it denotes infinite. Now repeat step 1

6. Find minimum time for each task , in the above image minimum time for each task is (20 ms ,T2 ,VM1), (60 ms, T3, VM1)

7. Now find the set with maximum time and that is (60 ms, T2, VM1)

8. Execute T3 in VM1 for 60ms

9. Since 60ms has been elapsed we need to update our data. New data is:

10. Find minimum time for each task , in the above image minimum time for each task is (80 ms ,T2 ,VM1)

11. Exit Since all task has been scheduled.

Makespan produced by any algorithm for a schedule can be calculated as follows:

Here makespan = max(100,60,80) = 100 ms

Finally the Code

Final Words

Max-min algorithm allocates larger task Ti to the resource Rj where large tasks have highest priority rather than smaller tasks. Therefore in Max-min we can execute many short tasks concurrently while executing the larger one.

Hi, I am a final year undergraduate from KIIT Bhubaneshwar pursuing my B.Tech in Computer Science and Engineering