Krishna iResearch Intelligent Cloud Platform - VIRtual Generic Os - VIRGO - Linux kernel extensions for cloud
 All Classes
VirgoPRGLoadBalancer_probab_calc.py
1 #/***************************************************************************************
2 #VIRGO - a linux module extension with CPU and Memory pooling with cloud capabilities
3 #
4 #Copyright (C) 2009-2013 Ka.Shrinivaasan
5 #
6 #This program is free software: you can redistribute it and/or modify
7 #it under the terms of the GNU General Public License as published by
8 #the Free Software Foundation, either version 3 of the License, or
9 #(at your option) any later version.
10 #
11 #This program is distributed in the hope that it will be useful,
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 #GNU General Public License for more details.
15 #
16 #You should have received a copy of the GNU General Public License
17 #along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #
19 #mail to: ka.shrinivaasan@gmail.com
20 #*****************************************************************************************/
21 
22 
23 #Linux Psuedorandom number generator based load balancer(experimental):
24 #----------------------------------------------------------------------
25 #Each virgo_clone() client has a PRG which is queried (/dev/random or /dev/urandom) to get the id of the host to send the next virgo_clone() function to be executed
26 #Expected number of requests per node is derived as:
27 #expected number of requests per node = summation(each_value_for_the_random_variable_for_number_of_requests * probability_for_each_value)
28 #=expected number of requests per node = (math.pow(N, k+2) - math.pow(N,3) + math.pow(N,2) - 1) / (math.pow(N, k+3) - 2*math.pow(N,k+2) + math.pow(N,k+1))
29 #where N is number of processors and k is the number of requests
30 
31 import math
32 
33 N=3
34 k=2
35 i=2
36 
37 while i < 2000:
38  expectedreqpernode = (math.pow(N, k+2) - k*math.pow(N,2) + k*math.pow(N,1) - 1) / (math.pow(N, k+3) - 2*math.pow(N,k+2) + math.pow(N,k+1))
39  print "NumOfProcessors = ",N,",NumOfRequests = ",k," ======== expectedreqpernode :", expectedreqpernode
40  i=i+1
41  k = i
42  #N = i