注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

A small step

Judgement Must

 
 
 

日志

 
 
关于我

不要因为急着赶路,让自己的步伐杂乱。远方是既定的目标,但路上才是最重要的经历!

网易考拉推荐

polygraph 测试squid  

2016-04-28 11:01:08|  分类: 小工具 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

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;
        }
  评论这张
 
阅读(29)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018