zoukankan      html  css  js  c++  java
  • 平衡边界作业算法并发仿真测试基于三层架构的Web系统的基准性能

    传送门 ☞ Android兵器谱 ☞ 转载请注明 ☞ http://blog.csdn.net/leverage_1229

    一、实验参数列表


    二、MATLAB脚本(appr_mva_bounds.m)

    clear;
    
    % input
    N1 = input('Number of customers of class 1 N1 = ');   % number of customers of class 1
    N2 = input('Number of customers of class 2 N2 = ');   %  number of customers of class 2
    M = input('number of applicaion tiers M = ');         % number of applicaion tiers
     
    for k = 2:(M+1)
        S1(k) = input('Average service time S1 = ');  % average service time per tier of class 1
        V1(k) = input('Visit number V1 = ');          % visit number per tier of class 1
    end
    Z1 = input('Think time Z1 = ');         % average think time of class 1
     
    for k = 2:(M+1)
        S2(k) = input('Average service time S2 = ');  % average service time per tier of class 2
        V2(k) = input('Visit number V2 = ');          % visit number per tier of class 2
    end
    Z2 = input('Think time Z2 = ');         % average think time of class 2
    
    % initialization
    S1(1) = Z1;
    V1(1) = 1;
    for m = 1:(M+1)
        D1(m) = V1(m) * S1(m);              % service demand per tier of class 1
    end
    
    S2(1) = Z2;
    V2(1) = 1;
    for m = 1:(M+1)
        D2(m) = V2(m) * S2(m);              % service demand per tier of class 2
    end
    
    vN2 = [1 5:5:N2];
    
    for n = 1:length(vN2)                   % up to a maximum number of customers
        N2 = vN2(n);
    
    % APPROXIMATE MVA ALGORITHM
    % initialization
        for m = 2:(M+1)
            Q1(m) = N1/M;
            Q2(m) = N2/M;
        end
        error = [1 1 1 1 1 1];
    
        R1(1) = D1(1);
        R2(1) = D2(1);
    
        while max(error) > 0.01
            for m = 2:(M+1)
                A1(m) = (N1-1)/N1*Q1(m) + Q2(m);        % average number of customers per tier of class 1
                A2(m) = (N2-1)/N2*Q2(m) + Q1(m);        % average number of customers per tier of class 2
            end
       
            for m = 2:(M+1)
                R1(m) = D1(m) * (1 + A1(m));            % average delay per tier of class 1
                R2(m) = D2(m) * (1 + A2(m));            % average delay per tier of class 2 
            end
        
            X1 = N1 / (sum(R1(:)));         % throughput of class 1
            X2 = N2 / (sum(R2(:)));         % throughput of class 2
        
            for m = 2:(M+1)
                Q1old(m) = Q1(m);           % old length of queue 1
                Q2old(m) = Q2(m);           % old length of queue 2
                Q1(m) = X1 * R1(m);         % new length of queue 1
                Q2(m) = X2 * R2(m);         % new length of queue 2
            end
        
            for m = 2:(M+1)
                error(m-1) = abs((Q1(m) - Q1old(m)) / Q1old(m));
                error(m-1+M) = abs((Q2(m) - Q2old(m)) / Q2old(m));
            end
        end
    
        
        for m = 2:(M+1)
            U1n(n,m) = X1 * S1(m) * V1(m);  % tier utilization of class 1
            U2n(n,m) = X2 * S2(m) * V2(m);  % tier utilization of class 2
        end
     
        X1n(n) = X1;                        % throughput of class 1
        X2n(n) = X2;                        % throughput of class 2
        
        RT1n(n) = sum(R1(2:(M+1)));         % response time of class 1
        RT2n(n) = sum(R2(2:(M+1)));         % response time of class 2
    end
    
    
    % BALANCED JOB BOUNDS
    D1max = max(D1(2:(M+1)));               % maximum service demand per queue of class 1             
    D2max = max(D2(2:(M+1)));               % maximum service demand per queue of class 2              
    D1sum = sum(D1(2:(M+1)));               % sum of total service demands of class 1
    D2sum = sum(D2(2:(M+1)));               % sum of total service demands of class 2
    D1avg = D1sum/M;                        % average service demand per queue of class 1
    D2avg = D2sum/M;                        % average service demand per queue of class 2
    for n = 1:length(vN2)
        N = vN2(n) + N1;
        R2min(n) = max(N * D2max - Z2, D2sum + ((N-1)*D2avg*D2sum/(D2sum+Z2))); % lower bound of response time
        R2max(n) = D2sum + ((N-1)*D2max*(N-1)*D2sum/(((N-1)*D2sum)+Z2));        % upper bound of response time
    
        X2min(n) = vN2(n) / (Z2 + R2max(n));            % lower bound of throughput
        X2max(n) = vN2(n) / (Z2 + R2min(n));            % upper bound of throughput
    
         for m = 2:(M+1)
             U2minm(n,m) = X2min(n) * D2(m);            % lower bound of utilization per tier
             U2maxm(n,m) = X2max(n) * D2(m);            % upper bound of utilization per tier
         end
    end
    
    t = vN2;
    
    
    % response time 
    figure(1), plot(t, RT2n,'r', t, R2min, 'g', t, R2max, 'b'), xlabel('Simultaneous browser connections'), ylabel('Response time(s)'); 
    
    % throughput
    figure(2), plot(t, X2n,'r', t,X2min,'g', t, X2max, 'b'), xlabel('Simultaneous browser connections'), ylabel('Throughput(1/s)');
    三、平衡作业边界预测响应时间和吞吐率

     




  • 相关阅读:
    存储过程中调用webservice
    设计模式学习笔记——桥接模式(Bridge Patten)
    设计模式学习笔记——修饰模式(Decorator Pattern)
    设计模式学习笔记——单件模式(Singleton Pattern)
    设计模式学习笔记——建造者模式(Builder Pattern)
    设计模式学习笔记——工厂方法(Factory Method)
    设计模式学习笔记——简单工厂(Simple Factory)
    设计模式学习笔记——适配器模式(Adapter Patten)
    设计模式学习笔记——抽象工厂(Abstract Factory)
    存储过程使用shell脚本执行sql文件
  • 原文地址:https://www.cnblogs.com/innosight/p/3271226.html
Copyright © 2011-2022 走看看