Skip to content

huy/server_simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Server simulation

Overview

This is simple Monte Carlo simulation of the behaviour of multi servers
behind round robin loadbalancer.

In the model, requests are divided into different types according to a type of resource they access
.There is limited output capacity for each type of resource, which is distributed equaly to all servers.

Requests come to the loadbalancer randomly at specific rate. The loadbalancer elect one of server to
forward the request regardless of type of resource required to complete the request.

A request take a time to complete during this short period it occupies the resource. If all resources of
a server are occupied then next incomming request to this server has to wait until one of its resources become available.

The objective is to calculate total wait time of requests as well as % of requests that has to wait for resource’ availability.

Generator of requests

The simulation uses a generator to generate requests randomly, feeds generated request to the model that
simulate work of loadbalancer and servers in order to calculate wait time and other statistics.

The generator will generate a request as tuple of (request_type,inter_arrival_time,service_time)
satisfying the following constraints

  • requests arrive at the system with length of inter-arrival time as random number
    distributed according Exponential Distribution
  • service time of each request is a random number distributed
    according Normal Distribution

Parameters

Example of parameter’s file

number_of_servers: 6
number_of_requests_per_sec: 30
number_of_requests: 50000
method: roundrobin
    types_of_requests:
      dma:
        output_capacity: 20
        proportion: 0.05
        avg_service_time_secs: 4.5
        deviation_service_time_secs: 1.5
      other:
        output_capacity: 60
        proportion: 0.95
        avg_service_time_secs: 1.15
        deviation_service_time_secs: 0.25

The following parameters from the file will be used to drive generator of requests

request_type_distribution

An array of probability for each type of requests, sum must yield 1.0.

e.g. [0.05,0.95] decribes two types of requests having probability of 5% and 95%.

request_type_mean_time

An array of mean time (expected value i.e. most of requests takes this time to complete)
for each type of requests, must have same length as request_type_distribution.

e.g. [4.5,1.15] describes the average service time of first type of requests is 4.5 second
and of second type is 1.15 s.

deviation_service_time

An array of variation time for each type of requests decribing a degree the service time spreads from mean time.

e.g. [1.5,0.25] the service time of first type of requests will vary by 1.5 secs, for the second type will be 250 ms

arrival_rate

Expected number of requests per second.

e.g. 30 means 30 requests per second

Requirements

  • python version >= 2.4
  • numpy and scipy python libaries

Run it

Test

python -m tests.sim_tests

Program

python sim/simulator.py tests/sample1.yaml --number_of_servers=4 --number_of_requests=20000 --number_of_requests_per_sec=20 --method=busyness

where

  • sample1.yml is file of parameters for simulation
  • —number_of_servers is optional, that will overwrite the one in parameter’s file
  • —number_of_requests is optional, that will overwrite the one in parameter’s file
  • —number_of_requests_per_sec is optional, that will overwrite the one in parameter’s file
  • —method is load balancer methods, which can be ‘roundrobin’ or ‘busyness’, is optional and will overwrite the one in parameter’s file

About

simulation of server work load

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages