acsicuib / YAFS

Yet Another Fog Simulator (YAFS)
MIT License
101 stars 73 forks source link

How to implement Load Balancing? #43

Closed i-saksham closed 3 years ago

i-saksham commented 3 years ago

So I've been meaning to implement one or two load balancing algorithms and wanted to know how to approach them. I've used the VRGame example as a base and made a similar scenario. I'm just a little confused as to where to begin. Is there a specific function where I should insert the algorithms or do I need to start elsewhere?

Any help would be greatly appreciated!

i-saksham commented 3 years ago

@wisaaco @jamesn1197 @DebRC

wisaaco commented 3 years ago

Hi @i-saksham , I recommend you this project. We use YAFS with a custom process to make decisions in a distributed allocation paradigm. It is a complex project but the code skeleton is well-structured: https://github.com/acsicuib/MARIO/tree/MarioII

i-saksham commented 3 years ago

Hey @wisaaco, thanks for the input. I had another question. I haven't been able to figure out how to alter the order in which the DES events are being generated. From the outputs in EGG example, it seems that the sensor messages are generated in the same pattern repeatedly. Is there a way to randomize how those events on the sensors are generated?

wisaaco commented 3 years ago

Yeah. There are a lot ways to do. In general terms, you can use several distribution functions like random, Bernoulli, and so on. but you can also include your custom "generators" (loading events from a CSV-file, or whatever).

i-saksham commented 3 years ago

I was able to figure, thanks a ton. Lastly, I just wanted to know how to calculate the response time for sensed events in the simulation. Also, what exactly is application loop delay?

wisaaco commented 3 years ago

The simulation generates two csv files. One contains several timestamps of each request. So, you can compute the response time of each request or do another type of analysis.

The next code get all the response time group by several apps/services:

res = pathcommon+"Results_%s_0.csv"%name
df = pd.read_csv(res,usecols=usecols)
groupsAppUserRequests = df[df["module.src"] == "None"].groupby(['app','DES.src',])['id'].apply(list)
appResponses = defaultdict(dict)
expResponses[code]=defaultdict(dict)

for (app, DESsrc) in groupsAppUserRequests.index:
       ids = groupsAppUserRequests[(app, DESsrc)]
       dtmp = df[df["id"].isin(ids)]
       dtmp["response"] = dtmp["time_out"] - dtmp["time_emit"]
       if len(dtmp["response"])>maxNR:
            maxNR=len(dtmp["response"])
       expResponses[code][app][DESsrc]=list(dtmp["response"].values)
# etc.