Example #1
0
def sync_improves_metric(max_demand, sync_periods, timesteps, workload_name,
        ctrl_name, name=None, sa=0.3, ia=10, shape=0.5,  show_graph=False, staleness=0):
    """Evalute the value of synchronization for a LinkBalanerCtrl by showing
    its effect on performance metric. We expect that for a workload which
    imparts server link imbalance across multiple domains, syncing will help
    improve the rmse_server metric.
    
    sa: the sslbc fractional load-balancing scale factor (0,1]. Controls what
    fraction of the imbalance we re-balance at each handle_request

    ia: the mean parameter for the expnentially distributed inter-arrival times
    of the expo workflow (value of x leads to mean of 1/x). Gets passed to
    random.expovariate(ia)

    shape: the weibull distribution shape parameter for flow duration
    """

    if name == None:
        name = sys._getframe().f_code.co_name + "_" + ctrl_name + "_" + workload_name

    #for sync_period in [0] + [2**(x) for x in range(0, int(log(timesteps,2)))]:
    for sync_period in sync_periods:

        sync_period = float(sync_period)
        myname = '%(a)s_%(b)d_%(c)02d_%(d)01d' % {"a": name,
                                               "b": max_demand,
                                               "c": sync_period,
                                               "d": staleness}

        logger.info("starting %s", myname)

        if workload_name == 'expo':
            wave_period = timesteps/4
            old_style=False
            workload = expo_workload(switches=['sw1', 'sw2'],
                                     period=wave_period, interarrival_alpha=ia,
                                     duration_shape=shape, timesteps=timesteps)
        elif workload_name == 'wave':
            old_style=True
            wave_period = timesteps/4
            workload = dual_offset_workload(switches=['sw1', 'sw2'],
                                            period=wave_period, offset=wave_period/2.0,
                                            max_demand=max_demand, size=1,
                                            duration=2, timesteps=timesteps,
                                            workload_fcn=wave, y_shift=(1.0/3))
        else: 
            assert "No Valid Workload Specified"

        if ctrl_name == 'separate':
            ctrls = two_separate_state_ctrls(alpha=sa)
        elif ctrl_name == 'lbc':
            ctrls = two_ctrls()
        else:
            assert "No Valid Controller Specified"

        sim = LinkBalancerSim(two_switch_topo(), ctrls)
        sim.run_and_trace(myname, workload, old=old_style, sync_period=sync_period,
                          show_graph=show_graph, staleness=staleness,
                          ignore_remaining=True)
        logger.info("ending %s", myname)
Example #2
0
def compare_random_dist_to_centralized(period=64, max_demand=8, show_graph=False):
    """ """
    timesteps = period * 4
    for sync_period in [0] + [2**x for x in range(0, int(log(period,2)))]:
        myname = '%(fname)s_%(num)02d' % {"fname": sys._getframe().f_code.co_name, "num": sync_period}
        logger.info("starting %s", myname)
        workload = dual_offset_workload(switches=['sw1', 'sw2'],
                                        period=period, offset=period/2.0,
                                        max_demand=max_demand, size=1,
                                        duration=2, timesteps=timesteps,
                                        workload_fcn=wave)

        ctrls = two_random_ctrls()
        sim = LinkBalancerSim(two_switch_topo(), ctrls)
        sim.run_and_trace(myname, workload, old=True, sync_period=sync_period,
                          show_graph=show_graph)
        logger.info("ending %s", myname)
Example #3
0
def synced_dist_equals_central(period=64, max_demand=4, show_graph=False):
    """Ensure that a distributed controller simulation run with sync_period=0
    yields exactly the same result as the same toplology and workload with a
    single controller."""

    timesteps = period * 4
    for sync_period in [0] + [2**x for x in range(0, int(log(period,2)))]:
        myname = '%(fname)s_%(num)02d' % {"fname": sys._getframe().f_code.co_name, "num": sync_period}
        logger.info("starting %s", myname)
        workload = dual_offset_workload(switches=['sw1', 'sw2'],
                                        period=period, offset=0,
                                        max_demand=max_demand, size=1,
                                        duration=1, timesteps=timesteps,
                                        workload_fcn=wave)

        ctrls = two_ctrls()
        sim = LinkBalancerSim(two_switch_topo(), ctrls)
        sim.run_and_trace(myname+str(sync_period), workload, old=True, sync_period=sync_period,
                          show_graph=show_graph)
        logger.info("ending %s", myname)
Example #4
0
def demo_strictly_local_ctrls(max_demand=8, show_graph=False):
    """Demonstrate synchronization across domains makes no difference when
    LinkBalanerCtrl only handles requests within its own domain"""

    #TODO: demonstrate with more than 1 srv per controller domain
    period = 32
    timesteps = period * 4
    for sync_period in [0] + [2**x for x in range(0, int(log(period,2)))]:
        myname = '%(fname)s_%(num)02d' % {"fname": sys._getframe().f_code.co_name, "num": sync_period}
        logger.info("starting %s", myname)
        workload = dual_offset_workload(switches=['sw1', 'sw2'],
                                        period=period, offset=period/2.0,
                                        max_demand=max_demand, size=1,
                                        duration=1, timesteps=timesteps,
                                        workload_fcn=wave)

        ctrls = strictly_local_ctrls()
        sim = LinkBalancerSim(two_switch_topo(), ctrls)
        sim.run_and_trace(myname, workload, old=True, sync_period=sync_period,
                          show_graph=show_graph)
        logger.info("ending %s", myname)