Skip to content

Instantly share code, notes, and snippets.

@mannuscript
Last active September 21, 2017 16:11
Show Gist options
  • Save mannuscript/16b500bf9bc3bce1cf0fcf40f877b579 to your computer and use it in GitHub Desktop.
Save mannuscript/16b500bf9bc3bce1cf0fcf40f877b579 to your computer and use it in GitHub Desktop.
Given load (in erlang) and blocking probability, this script calculates the number of servers required.
#include<iostream>
using namespace std;
int getServersCount(float prob, float load)
{
long double B = 1.0;
int m = 1;
while(true) {
B = 1 + B*m/load;
if(B >= 1/prob)
return m;
m++;
}
}
int main(void)
{
float prob = .02, load=3000;
cout<<"Enter the value of probability and load respectively: ";
cin>>prob>>load;
cout<<"Number of servers required are: "<<getServersCount(prob, load)<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment