You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nahor <na...@gmail.com> on 2008/01/09 03:37:45 UTC

Preferred load-balanced worker

Hi,

Is there a way to specify at runtime what worker the load-balancer 
should use first?

For some request, we can't use cookies so we pass the session id via the 
URL or via the query string. We then force the worker using RewriteRule 
and the JK_WORKER_NAME env var.
But then the request doesn't pass through the load-balancer anymore. So 
even if we stop that worker in the load-balancer, it will still receive 
the request instead of being redirected to another worker.

So is there a "JK_LB_PREFERRED_WORKER" kind of variable or equivalent 
that the load-balancer would use instead of the cookie?


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Preferred load-balanced worker

Posted by Nahor <na...@gmail.com>.
Rainer Jung wrote:
> Hi,
> 
> Nahor wrote:
>> Hi,
>>
>> Is there a way to specify at runtime what worker the load-balancer 
>> should use first?
>>
>> For some request, we can't use cookies so we pass the session id via 
>> the URL or via the query string. We then force the worker using 
>> RewriteRule and the JK_WORKER_NAME env var.
>> But then the request doesn't pass through the load-balancer anymore. 
>> So even if we stop that worker in the load-balancer, it will still 
>> receive the request instead of being redirected to another worker.
>>
>> So is there a "JK_LB_PREFERRED_WORKER" kind of variable or equivalent 
>> that the load-balancer would use instead of the cookie?
> 
> Not directly, you could make use of the cookie and url encoding routing 
> facilities of an lb though.
> 
> - Make sure the JSESSIONID gets deleted before and the new request 
> doesn't contain a wrong ;jsessionid URL encoding
> - Either use mod_headers to set a fake JSESSIONID Cookie header to the 
> request

I can't set a fake cookie because we want to be able to set the cookie 
in the response if it was missing in the request (for instance, when 
switching from HTTPS (and secure cookies) to HTTP).


> - Or use mod_rewrite and append a fake ;jsessionid=... URL encoding at 
> the end of the URL (but before the query string).

Thanks, I didn't think about rewriting the request.


> Let us know if this works :)

It does! Thanks! :)


	Nahor


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Preferred load-balanced worker

Posted by Rainer Jung <ra...@kippdata.de>.
Hi,

Nahor wrote:
> Hi,
> 
> Is there a way to specify at runtime what worker the load-balancer 
> should use first?
> 
> For some request, we can't use cookies so we pass the session id via the 
> URL or via the query string. We then force the worker using RewriteRule 
> and the JK_WORKER_NAME env var.
> But then the request doesn't pass through the load-balancer anymore. So 
> even if we stop that worker in the load-balancer, it will still receive 
> the request instead of being redirected to another worker.
> 
> So is there a "JK_LB_PREFERRED_WORKER" kind of variable or equivalent 
> that the load-balancer would use instead of the cookie?

Not directly, you could make use of the cookie and url encoding routing 
facilities of an lb though.

- Make sure the JSESSIONID gets deleted before and the new request 
doesn't contain a wrong ;jsessionid URL encoding
- Either use mod_headers to set a fake JSESSIONID Cookie header to the 
request
- Or use mod_rewrite and append a fake ;jsessionid=... URL encoding at 
the end of the URL (but before the query string).

The value of the Cookie resp. jsessionid would be X.MYROUTE, where 
MYROUTE is the name of the lb sub worker you want to gert chosen by the lb.

Session with id X will not exist on the target MYROUTE, so a new session 
will be created for the request.

Let us know if this works :)

Regards,

Rainer

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org