squid压力测试工具Web Polygraph


http://www.web-polygraph.org


// this is just one of the simplest workloads that can produce hits
// never use this workload for benchmarking

Content value1= {
        kind = "HTTP_value1"; // just a label
        mime = { type =  undef(); prefixes = ["MP4_value1_pgclient/"]; extensions = [ ".mp4" ]; };
	size = exp(5MB);
        cachable = 100%;
};

Content value2= {
        kind = "HTTP_value2"; // just a label
        mime = { type =  undef(); prefixes = ["MP4_value2_pgclient/"]; extensions = [ ".mp4" ]; };
	size = exp(5MB);
        cachable = 100%;
};

//ips
//addr[] srv_ips =['127.0.0.1:8002'];
//addr[] rbt_ips =['127.0.0.1' ** 10];
addr[] srv_ips =['172.134.1-10.1-145:8002', '172.170.1-10.1-145:8002'];
addr[] rbt_ips =['172.133.10-19.1-110'];

// a primitive server cleverly labeled "S101"
// normally, you would specify more properties,
// but we will mostly rely on defaults for now
Server S = {
	kind = "S101"; 	
	contents = [ value1: 60%, value2: 40% ];
	direct_access = contents;
	addresses = srv_ips; // where to create these server agents
};

// a primitive robot
Robot R = {
	kind = "R101";
	pop_model = { pop_distr = popUnif(); };
	recurrence = 40%; // 
	req_rate = 1/sec;

	origins = S.addresses;      // where the origin servers are
	addresses = rbt_ips; // where these robot agents will be created
};

/* working set capacity */
working_set_cap(48933);

/* phases (note that load is kept at constant level) */
time ExpDur = 4000hour; // experiment duration
Phase phases1 = {
        name = "phases1";
        goal.duration = 10% * ExpDur;
};

Phase phases2 = {
        name = "phases2";
        goal.duration = ExpDur - phases1.goal.duration; // the rest of the run
};
schedule(
	phases1, phases2
);

// commit to using these servers and robots
use(S, R);


./polygraph-client --cfg_dirs ../share/polygraph/workloads/include/ --config ./simple.pg --verb_lvl 10 
--log a.log --proxy 127.0.0.1:3128

 - nginx


 
 

#rewrite about polygraph
rewrite "^(/MP4_value1_pgclient)"   /video-test/value1_stream.mp4;
rewrite "^(/MP4_value2_pgclient)"   /video-test/value2_stream.mp4;
 
 


 
 
  • cacheable: Represents 30% of the line "if sum% 10 <3 then" cacheable.
	location ~ \.(flv|mp4|3gp) {
	  	set  $v1 "null";
	  	set  $v2 "null";
	  	set  $v3 "null";

		if ($request_uri ~* ^\/[0-9a-zA-Z_]*_pgclient\/([0-9a-zA-Z:\.]*)\/([0-9a-zA-Z]*)\/([_0-9a-zA-Z]*)\.(flv|mp4|3gp)$ ) {
			set $v1 $1;
                	set $v2 $2;
                	set $v3 $3;

		header_filter_by_lua '
			sum=0;
                	string_key = ngx.var.v1 .. ngx.var.v2 .. ngx.var.v3;
			for i=1, string.len(string_key) do
				sum = sum + string.byte(string_key, i);
			end
                	ngx.header["X-test_value"] = ngx.var.v1 .. ngx.var.v2 .. ngx.var.v3 .. "--" .. sum .. ":" .. sum%10;

                	if sum % 10 < 3 then
                        	ngx.header["Cache-Control"] = "private";
                	else
                        	ngx.header["Cache-Control"] = "public";
			end
		';
		}

        }

 
 
  • add header:
        location ~ \.mp4 {
               mp4;
               expires 120s;
               add_header Cache-Control public;
        }


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值