<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Load balancing vusers without a load balancer</title>
	<atom:link href="http://www.jds.net.au/tech-tips/load-balancing-with-vugen/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jds.net.au/tech-tips/load-balancing-with-vugen/</link>
	<description>Expert consulting services with HP Software</description>
	<lastBuildDate>Tue, 08 Jun 2010 15:08:25 +1000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: vdaburon</title>
		<link>http://www.jds.net.au/tech-tips/load-balancing-with-vugen/#comment-2544</link>
		<dc:creator>vdaburon</dc:creator>
		<pubDate>Thu, 16 Apr 2009 15:13:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.jds.net.au/?p=797#comment-2544</guid>
		<description>A alternative solution uses the vuser id modulo the number of hosts.

&lt;pre lang=&quot;C&quot; line=&quot;1&quot;&gt;
	static int NB_HOST = 3; // 3 differents hosts

	/* load balancing computes with vuser id modulo number of hosts */
	int id, scid;
	char *vuser_group;
	int valIdMod;
	static int isInitRand = 0;

	if (isInitRand == 0) {
		//srand is called before rand 
		srand(time(NULL)); 
		isInitRand = 1;
	}

	lr_whoami(&amp;id, &amp;vuser_group, &amp;scid);
	lr_message( &quot;Group: %s, vuser id: %d, scenario id %d&quot;,  vuser_group, id, scid);

	/*************** BEGIN COMMENT ***********/
	// id = 5555; // force the id to a specifique host
	/*************** END commenter ***********/

	valIdMod = id % NB_HOST;

	if (valIdMod == 0) {
		lr_save_string( &quot;http://&quot;,&quot;P_PROTOCOLE&quot; );
		lr_save_string(&quot;serverA&quot;,&quot;P_SERVEUR&quot; ); 
		lr_save_string( &quot;7013&quot;,&quot;P_PORT&quot; );
	}

	if (valIdMod == 1) {
		lr_save_string( &quot;http://&quot;,&quot;P_PROTOCOLE&quot; );
		lr_save_string(&quot;serverB&quot;,&quot;P_SERVEUR&quot; ); 
		lr_save_string( &quot;8080&quot;,&quot;P_PORT&quot; );
	}

	if (valIdMod == 2) {
		lr_save_string( &quot;http://&quot;,&quot;P_PROTOCOLE&quot; );
		lr_save_string(&quot;serverC&quot;,&quot;P_SERVEUR&quot; ); 
		lr_save_string( &quot;7015&quot;,&quot;P_PORT&quot; );
	}

	// force to a specific host
	if (id == 5555) {
		lr_save_string( &quot;http://&quot;,&quot;P_PROTOCOLE&quot; );
		lr_save_string(&quot;serverB&quot;,&quot;P_SERVEUR&quot; ); 
		lr_save_string( &quot;8080&quot;,&quot;P_PORT&quot; );

	}
	lr_log_message(&quot;P_SERVEUR = %s&quot;, lr_eval_string(&quot;{P_SERVEUR}&quot;));
	lr_log_message(&quot;P_PORT = %s&quot;, lr_eval_string(&quot;{P_PORT}&quot;));

	web_url(&quot;Login&quot;, 
		&quot;URL={P_PROTOCOLE}://{P_SERVEUR}:{P_PORT}/login.do&quot;, 
		&quot;TargetFrame=&quot;, 
		&quot;Resource=0&quot;, 
		&quot;RecContentType=text/html&quot;, 
		&quot;Referer=&quot;, 
		&quot;Snapshot=t1.inf&quot;, 
		&quot;Mode=HTML&quot;, 
		LAST);
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>A alternative solution uses the vuser id modulo the number of hosts.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">	<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> NB_HOST <span style="color: #339933;">=</span> <span style="color: #0000dd;">3</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 3 differents hosts</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/* load balancing computes with vuser id modulo number of hosts */</span>
	<span style="color: #993333;">int</span> id<span style="color: #339933;">,</span> scid<span style="color: #339933;">;</span>
	<span style="color: #993333;">char</span> <span style="color: #339933;">*</span>vuser_group<span style="color: #339933;">;</span>
	<span style="color: #993333;">int</span> valIdMod<span style="color: #339933;">;</span>
	<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> isInitRand <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>isInitRand <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//srand is called before rand </span>
		srand<span style="color: #009900;">&#40;</span>time<span style="color: #009900;">&#40;</span>NULL<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		isInitRand <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	lr_whoami<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>id<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>vuser_group<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>scid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	lr_message<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;Group: %s, vuser id: %d, scenario id %d&quot;</span><span style="color: #339933;">,</span>  vuser_group<span style="color: #339933;">,</span> id<span style="color: #339933;">,</span> scid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*************** BEGIN COMMENT ***********/</span>
	<span style="color: #666666; font-style: italic;">// id = 5555; // force the id to a specifique host</span>
	<span style="color: #808080; font-style: italic;">/*************** END commenter ***********/</span>
&nbsp;
	valIdMod <span style="color: #339933;">=</span> id <span style="color: #339933;">%</span> NB_HOST<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>valIdMod <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		lr_save_string<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;http://&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;P_PROTOCOLE&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		lr_save_string<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;serverA&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;P_SERVEUR&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		lr_save_string<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;7013&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;P_PORT&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>valIdMod <span style="color: #339933;">==</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		lr_save_string<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;http://&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;P_PROTOCOLE&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		lr_save_string<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;serverB&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;P_SERVEUR&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		lr_save_string<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;8080&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;P_PORT&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>valIdMod <span style="color: #339933;">==</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		lr_save_string<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;http://&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;P_PROTOCOLE&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		lr_save_string<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;serverC&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;P_SERVEUR&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		lr_save_string<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;7015&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;P_PORT&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// force to a specific host</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>id <span style="color: #339933;">==</span> <span style="color: #0000dd;">5555</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		lr_save_string<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;http://&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;P_PROTOCOLE&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		lr_save_string<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;serverB&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;P_SERVEUR&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		lr_save_string<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;8080&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;P_PORT&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
	lr_log_message<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;P_SERVEUR = %s&quot;</span><span style="color: #339933;">,</span> lr_eval_string<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;{P_SERVEUR}&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	lr_log_message<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;P_PORT = %s&quot;</span><span style="color: #339933;">,</span> lr_eval_string<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;{P_PORT}&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	web_url<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Login&quot;</span><span style="color: #339933;">,</span> 
		<span style="color: #ff0000;">&quot;URL={P_PROTOCOLE}://{P_SERVEUR}:{P_PORT}/login.do&quot;</span><span style="color: #339933;">,</span> 
		<span style="color: #ff0000;">&quot;TargetFrame=&quot;</span><span style="color: #339933;">,</span> 
		<span style="color: #ff0000;">&quot;Resource=0&quot;</span><span style="color: #339933;">,</span> 
		<span style="color: #ff0000;">&quot;RecContentType=text/html&quot;</span><span style="color: #339933;">,</span> 
		<span style="color: #ff0000;">&quot;Referer=&quot;</span><span style="color: #339933;">,</span> 
		<span style="color: #ff0000;">&quot;Snapshot=t1.inf&quot;</span><span style="color: #339933;">,</span> 
		<span style="color: #ff0000;">&quot;Mode=HTML&quot;</span><span style="color: #339933;">,</span> 
		LAST<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart Moncrieff</title>
		<link>http://www.jds.net.au/tech-tips/load-balancing-with-vugen/#comment-1072</link>
		<dc:creator>Stuart Moncrieff</dc:creator>
		<pubDate>Tue, 13 Jan 2009 06:48:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.jds.net.au/?p=797#comment-1072</guid>
		<description>Kim from &lt;a href=&quot;http://ptfrontline.wordpress.com/&quot; rel=&quot;nofollow&quot;&gt;Performance Testing @ the Frontline&lt;/a&gt; has written a similar article with an &lt;a href=&quot;http://ptfrontline.wordpress.com/2008/09/18/in-script-simulation-of-a-load-balancer-with-loadrunner/&quot; rel=&quot;nofollow&quot;&gt;alternative way of solving this load balancing problem&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Kim from <a href="http://ptfrontline.wordpress.com/" rel="nofollow">Performance Testing @ the Frontline</a> has written a similar article with an <a href="http://ptfrontline.wordpress.com/2008/09/18/in-script-simulation-of-a-load-balancer-with-loadrunner/" rel="nofollow">alternative way of solving this load balancing problem</a>.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
