/*
 * WebAxe-1 workload for testing Web Accelerators (reverse proxies)
 *
 */

// Warning: These specs are under construction

#include "contents.pg"
#include "phases.pg"

// Request rate is determined by the number of robots and is computed
// later; setting request rate here has no effect
rate PeakRate = undef();

// Fill rate (must be between 10% and 100% of peak request rate PeakRate)
rate FillRate = undef() * PeakRate;

// the two standard working set sizes are 100MB and 1GB
size WSS = 100MB;

// Cache size affects the duration of the "fill" phase below
// Use the sum of RAM and cache disks physical capacity
size CacheSize = 10GB;

// describe WebAxe-1 server
Server S = { 
	kind = "WebAxe-1-srv";

	contents      = [ cntImage: 65%, cntHTML: 15%, cntDownload: 0.5%, cntOther ];
	direct_access = [ cntHTML, cntDownload, cntOther ];

	xact_think = norm(0.3sec, 0.1sec);
	pconn_use_lmt = zipf(16);
	idle_pconn_tout = 15sec;
	http_versions = [ "1.0" ];  // newer agents use HTTP/1.1 by default
};

// where the simulated servers and robots will be located
// these ips will need adjustments based on your local environment,
// working set size, and request rate!
addr[] srv_ips = ['127.0.0.1:8080' ];
addr[] rbt_ips = ['127.0.0.1' ];

// describe WebAxe-1 robot
Robot R = {
	kind = "WebAxe-1-rbt";
	origins = srv_ips;

	recurrence      =   95%;
	embed_recur     =  100%;
	pop_model = { pop_distr = popUnif(); };

	req_rate = 0.4/sec;
	pconn_use_lmt = zipf(64);
	open_conn_lmt = 4;              // open connections limit

	//launch_win = 2.5min;            // avoid burst of requests at start
	http_versions = [ "1.0" ];  // newer agents use HTTP/1.1 by default
};

// compute actual request rate
PeakRate = count(rbt_ips)*R.req_rate;


/* phases */

Phase phWarm = { 
	name = "warm"; 
	goal.duration = 5min;
	load_factor_beg = 0.1; 
	load_factor_end = FillRate/PeakRate;
	log_stats = false; 
};

Phase phFill = { 
	name = "fill";
	goal.fill_size = 2*CacheSize;
	recur_factor_beg = 5%/95%;
};

Phase phLink = { 
	name = "link";
	goal.duration = 5min;
	load_factor_end = 1.0;
	recur_factor_end = 1.0;
};

Phase phTop1 = { name = "top1"; goal.duration = 60min; };
Phase phDec  = { name = "dec";  goal.duration = 5min; load_factor_end = 0.1; };
Phase phIdle = { name = "idle"; goal.duration = 10min; };
Phase phInc  = { name = "inc";  goal.duration = 5min; load_factor_end = 1.0; };
Phase phTop2 = { name = "top2";	goal.duration = 60min; };

// build schedule using some well-known phases and phases defined above
schedule(phWarm, phFill, phLink,
	phTop1, phDec, phIdle, phInc, phTop2, 
	phCool);

// convert WSS in terms of "volume" to WSS in terms of units of "time"
working_set_length(WSS/(10KB*FillRate)/5%/80%);

// assign agents (servers and robots) to their hosts
S.addresses = srv_ips;
R.addresses = rbt_ips;

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

// do not forget to configure network level delay and packet loss!
// client side: 100msec delay and 0.1% packet loss in both directions
// server side: no delays or packet losses.
