So i am working on load balancing on cloud in which i will have multiple tasks or cloudlets and they will run on different VMs available. I have created cloudlets as follows:
cloudlets = {}
cloudlets_no = 400
a = ""
for x in range(cloudlets_no):
a = "cloudlet_id_{}".format(x)
cloudlets[a] = 1000 + (random.randint(0,100))
sorted_keys = []
sorted_cloudlets = sorted(cloudlets, key=cloudlets.__getitem__)
for k in sorted_cloudlets:
sorted_keys.append(k)
print "{} : {}".format(k, cloudlets[k])
Now to execute these task on VMs(initially a single VM) i did,
start = time.time()
for x in sorted_keys:
rem = cloudlets[x]
while rem != 0:
rem -= 1
end = time.time()
Now the thing is i want to create multiple VMs and i want to run them simultaneously that's why i need to run multiple loops at once. is there a way i can achieve this or any other possible workaround.
Any help is appreciated.