squid压力测试工具Web Polygraph

来源:互联网 发布:对外经贸知乎 编辑:程序博客网 时间:2024/05/18 10:04


http://www.web-polygraph.org


// this is just one of the simplest workloads that can produce hits// never use this workload for benchmarkingContent 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 nowServer S = {kind = "S101"; contents = [ value1: 60%, value2: 40% ];direct_access = contents;addresses = srv_ips; // where to create these server agents};// a primitive robotRobot R = {kind = "R101";pop_model = { pop_distr = popUnif(); };recurrence = 40%; // req_rate = 1/sec;origins = S.addresses;      // where the origin servers areaddresses = 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 durationPhase 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 robotsuse(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

  • url rewrite. request http url like "http://ip:port/MP4_value1_pgclient/w19fa92dc.44827bae:00001438/t03/_00000001.mp4" and "http://ip:port/MP4_value2_pgclient/w19fa92dc.44827bae:00001438/t03/_00000001.mp4".

#rewrite about polygraphrewrite "^(/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) dosum = 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;        }


原创粉丝点击