|
Algorithm 1 Resource Adaptive Proxy (RAP) |
/* Define global variables*/
BestNode ▹ Most powerful resource remote worker
EndpointsMap ▹ List of endpoints of each endpoint
NextEndpoints ▹ Endpoints used in the load-balancing
ResLists ▹ Resource list including CPU, RAM, and latency
-
1:
functionResourceAdaptiveProxy
-
2:
/* Create separate endpoint list based on name of node*/
-
3:
-
4:
if then
-
5:
for endpoints, node in GetAppInfo(app).Item[] do
-
6:
-
7:
end for
-
8:
-
9:
end if
-
10:
/* Calculate resources and return the best remote node*/
-
11:
-
12:
for node in GetAppInfo(app).Item[] do
-
13:
-
14:
-
15:
//Calculate score by summing normalized resource.
-
16:
if then
-
17:
if && then
-
18:
-
19:
if then
-
20:
-
21:
-
22:
end if
-
23:
end if
-
24:
end if
-
25:
end for
-
26:
end function
-
27:
functionLoadbalancer
-
28:
/*Incoming requests are forwarded to NextEndpoint.*/
-
29:
if then
-
30:
-
31:
if
&&
then
-
32:
-
33:
else
-
34:
-
35:
end if
-
36:
//Forward Incoming Request to NextEndpoint
-
37:
end if
-
38:
end function
|