Re: id=51247 Enhance mod_proxy and _balancer with worker status flag to only accept sticky session routes

2011-08-08 Thread Jim Jagielski
This is on my TODO… Thx for the reminder!

On Aug 5, 2011, at 7:49 PM, Keith Mashinter wrote:

 Thanks for the reminder.  I was about to send one myself to see if there was 
 a chosen path.
  
 \|/- Keith Mashinter 
 kmash...@yahoo.com
 From: Daniel Ruggeri drugg...@primary.net
 To: dev@httpd.apache.org
 Sent: Friday, August 5, 2011 6:55:04 PM
 Subject: Re: id=51247 Enhance mod_proxy and _balancer with worker status flag 
 to only accept sticky session routes
 
 On 5/25/2011 7:49 AM, Keith Mashinter wrote:
  I've reviewed the other
  patch https://issues.apache.org/bugzilla/show_bug.cgi?id=48841 and I
  had a similar idea, wondering if the route-only intent would happen if
  I tried to set lbfactor=0 but it only allowed values 1-100 and I
  worried about the complexity of changing the lbmethod formulae so
  using a separate status code seemed cleaner.  It's a bit of a magic
  value, but an intuitive one I think.  On the user surface lbfactor=0
  requires less change than my ROUTE_ONLY to the configuration and
  balancer-manager but it needs some documentation to clarify the intent.
 
  I also attached a patch to
  https://issues.apache.org/bugzilla/show_bug.cgi?id=51247 for the
  trunk, but since I'm having trouble with the overall compile it's in
  theory.  Please forgive compile issues, but I wanted to at least
  share the thought and will update when I can verify a compile and test
  run.
 
 Jim/Bill/others who have mentioned this;
   Just wanted to drop a friendly reminder that I'm waiting on direction
 between these two options. I can quickly roll a trunk or 2.2 patch for
 either of these if there is consensus for either mechanism.
 
 Both will allow for taking a server offline after bleeding traffic away
 by means of sending only existing sessions to said server. The
 difference is in approach:
 48841Allowing zero as lbfactor tweaks the math a bit for the lbmethods
 51247Adds a Route-Only radio box to balancer manager and a constant
 in the code to recognize the change
 
 -- 
 --
 Daniel Ruggeri
 
 



Re: id=51247 Enhance mod_proxy and _balancer with worker status flag to only accept sticky session routes

2011-08-05 Thread Daniel Ruggeri
On 5/25/2011 7:49 AM, Keith Mashinter wrote:
 I've reviewed the other
 patch https://issues.apache.org/bugzilla/show_bug.cgi?id=48841 and I
 had a similar idea, wondering if the route-only intent would happen if
 I tried to set lbfactor=0 but it only allowed values 1-100 and I
 worried about the complexity of changing the lbmethod formulae so
 using a separate status code seemed cleaner.  It's a bit of a magic
 value, but an intuitive one I think.  On the user surface lbfactor=0
 requires less change than my ROUTE_ONLY to the configuration and
 balancer-manager but it needs some documentation to clarify the intent.

 I also attached a patch to
 https://issues.apache.org/bugzilla/show_bug.cgi?id=51247 for the
 trunk, but since I'm having trouble with the overall compile it's in
 theory.  Please forgive compile issues, but I wanted to at least
 share the thought and will update when I can verify a compile and test
 run.

Jim/Bill/others who have mentioned this;
   Just wanted to drop a friendly reminder that I'm waiting on direction
between these two options. I can quickly roll a trunk or 2.2 patch for
either of these if there is consensus for either mechanism.

Both will allow for taking a server offline after bleeding traffic away
by means of sending only existing sessions to said server. The
difference is in approach:
48841Allowing zero as lbfactor tweaks the math a bit for the lbmethods
51247Adds a Route-Only radio box to balancer manager and a constant
in the code to recognize the change

-- 
--
Daniel Ruggeri


Re: id=51247 Enhance mod_proxy and _balancer with worker status flag to only accept sticky session routes

2011-08-05 Thread Keith Mashinter
Thanks for the reminder.  I was about to send one myself to see if there was a 
chosen path.

 
\|/- Keith Mashinter 
kmash...@yahoo.com



From: Daniel Ruggeri drugg...@primary.net
To: dev@httpd.apache.org
Sent: Friday, August 5, 2011 6:55:04 PM
Subject: Re: id=51247 Enhance mod_proxy and _balancer with worker status flag 
to only accept sticky session routes

On 5/25/2011 7:49 AM, Keith Mashinter wrote:
 I've reviewed the other
 patch https://issues.apache.org/bugzilla/show_bug.cgi?id=48841 and I
 had a similar idea, wondering if the route-only intent would happen if
 I tried to set lbfactor=0 but it only allowed values 1-100 and I
 worried about the complexity of changing the lbmethod formulae so
 using a separate status code seemed cleaner.  It's a bit of a magic
 value, but an intuitive one I think.  On the user surface lbfactor=0
 requires less change than my ROUTE_ONLY to the configuration and
 balancer-manager but it needs some documentation to clarify the intent.

 I also attached a patch to
 https://issues.apache.org/bugzilla/show_bug.cgi?id=51247 for the
 trunk, but since I'm having trouble with the overall compile it's in
 theory.  Please forgive compile issues, but I wanted to at least
 share the thought and will update when I can verify a compile and test
 run.

Jim/Bill/others who have mentioned this;
   Just wanted to drop a friendly reminder that I'm waiting on direction
between these two options. I can quickly roll a trunk or 2.2 patch for
either of these if there is consensus for either mechanism.

Both will allow for taking a server offline after bleeding traffic away
by means of sending only existing sessions to said server. The
difference is in approach:
48841    Allowing zero as lbfactor tweaks the math a bit for the lbmethods
51247    Adds a Route-Only radio box to balancer manager and a constant
in the code to recognize the change

-- 
--
Daniel Ruggeri

Re: id=51247 Enhance mod_proxy and _balancer with worker status flag to only accept sticky session routes

2011-05-25 Thread Mladen Turk

On 05/25/2011 02:27 AM, Daniel Ruggeri wrote:

I attached the patch to a bug opened by Cameron Stokes
https://issues.apache.org/bugzilla/show_bug.cgi?id=48841



Just a quick note on the first thing I saw:

+//worker-lbfactor = atoi(val);
+worker-lbfactor = strtol(val, NULL, 10);
+if (errno == EINVAL || worker-lbfactor  0 || worker-lbfactor  100)

You should add
errno = 0;
before strtol call if you inspect the errno afterwards.
BTW, what's wrong with the atoi call? We ain't gonna have 64-bit lbfactors,
and the acceptable range is 0 ... 100
Also, don't use C++ comments.


Regards
--
^TM


Re: id=51247 Enhance mod_proxy and _balancer with worker status flag to only accept sticky session routes

2011-05-25 Thread Jim Jagielski

On May 24, 2011, at 8:27 PM, Daniel Ruggeri wrote:

 
 Jim, if you wouldn't mind reviewing both and suggesting one to be cleaned up 
 for a patch generated against trunk. I'm happy to volunteer the effort to 
 adjust my patch or at least take care of that bug that's out there still.
 

Will do...

BTW: The drain flag in trunk was set-aside kinda for this
capability... 



Re: id=51247 Enhance mod_proxy and _balancer with worker status flag to only accept sticky session routes

2011-05-25 Thread Keith Mashinter
I've reviewed the other 
patch https://issues.apache.org/bugzilla/show_bug.cgi?id=48841 and I had a 
similar idea, wondering if the route-only intent would happen if I tried to set 
lbfactor=0 but it only allowed values 1-100 and I worried about the complexity 
of changing the lbmethod formulae so using a separate status code seemed 
cleaner.  It's a bit of a magic value, but an intuitive one I think.  On the 
user surface lbfactor=0 requires less change than my ROUTE_ONLY to the 
configuration and balancer-manager but it needs some documentation to clarify 
the intent.

I also attached a patch to 
https://issues.apache.org/bugzilla/show_bug.cgi?id=51247 for the trunk, but 
since I'm having trouble with the overall compile it's in theory.  Please 
forgive compile issues, but I wanted to at least share the thought and will 
update when I can verify a compile and test run.

In the end, either solution can work, and my hope is that multiple attempts at 
the same goal make a stronger case to bring the functionality to the 2.2.x 
stream for people to enjoy sooner rather than later.

Oh, and thanks for all who contribute to this common good.  I finally had an 
opportunity to contribute back to Apache httpd after using it for many years.  
If it contributes to either idea of lbfactor=0 or ROUTE_ONLY making it to the 
trunk and 2.2.x then it's certainly worth it.  If there isn't documentation 
changes for the lbfactor=0 I could take a stab at that if it's the chosen 
solution.

 
\|/- Keith Mashinter 
kmash...@yahoo.com



From: Daniel Ruggeri drugg...@primary.net
To: dev@httpd.apache.org
Sent: Tuesday, May 24, 2011 8:27:23 PM
Subject: Re: id=51247 Enhance mod_proxy and _balancer with worker status flag 
to only accept sticky session routes

On 5/24/2011 9:18 AM, Jim Jagielski wrote:
 I like the concept... will review.

 PS: Most patches should be against trunk. We fold into trunk,
      test and only then propose for backport for 2.2.x


 On May 23, 2011, at 3:10 PM, Keith Mashinter wrote:

 I've added a patch to the proxy/balancer to allow for route-only workers are 
 only enabled for sticky session routes, allowing for an even more graceful 
 fade-out of a server than making its lbfactor=1 compared to lbfactor=100 for 
 others.

 Please reply/vote if you also think it's useful.

 https://issues.apache.org/bugzilla/show_bug.cgi?id=51247
 This enhancement, actually SVN Patched against 2.2.19, provides a worker 
 status
 flag to set a proxy worker as only accepting requests with sticky session
 routes, e.g. only accept requests with a .route such as Cookie
 JSESSIONID=xxx.tc2.
  ...



I think there are two patches available to do the same thing - sorry for 
not following up on this sooner. I brought this up in conversation with 
Bill on this list back in October and haven't dug into it since.

I attached the patch to a bug opened by Cameron Stokes
https://issues.apache.org/bugzilla/show_bug.cgi?id=48841

I agree that this functionality would be nice to have but am agnostic as 
to which method accomplishes this :) They both seem to take different 
routes to get to the same goal.

Jim, if you wouldn't mind reviewing both and suggesting one to be 
cleaned up for a patch generated against trunk. I'm happy to volunteer 
the effort to adjust my patch or at least take care of that bug that's 
out there still.

-- 
--
Daniel Ruggeri

Re: id=51247 Enhance mod_proxy and _balancer with worker status flag to only accept sticky session routes

2011-05-25 Thread Daniel Ruggeri

On 5/25/2011 5:41 AM, Mladen Turk wrote:

On 05/25/2011 02:27 AM, Daniel Ruggeri wrote:

I attached the patch to a bug opened by Cameron Stokes
https://issues.apache.org/bugzilla/show_bug.cgi?id=48841



Just a quick note on the first thing I saw:

+ //worker-lbfactor = atoi(val);
+ worker-lbfactor = strtol(val, NULL, 10);
+ if (errno == EINVAL || worker-lbfactor  0 || worker-lbfactor  100)

You should add
errno = 0;
before strtol call if you inspect the errno afterwards.
BTW, what's wrong with the atoi call? We ain't gonna have 64-bit lbfactors,
and the acceptable range is 0 ... 100
Also, don't use C++ comments.


Regards


Sorry about the comment, that was supposed to be removed.

I mentioned the following in the notes when I brought up the topic of 
the patch on the list some months back. I believe my intent was to allow 
setting lbfactor to zero at start time if desired and to prevent a 
'parse error' from causing an invalid value to be treated as zero instead.


Patch notes from Oct on list (sorry this never made it into the bug 
report - can add if desired):
   I used a constant called PROXY_WORKER_NOLBFACTOR in mod_proxy.h and 
changed the atoi call during configuration to strtol since the atoi call 
returns 0 both during error situations and when the proper value to 
return is 0. Also, the existing checks had to be refactored a little 
since (at least on the SUN c compiler) an  uninitialized integer is the 
same as `0'. Aside from that, only the bybusiness algorithm had to be 
modified to avoid a divide by zero error.


--
--
Daniel Ruggeri


Re: id=51247 Enhance mod_proxy and _balancer with worker status flag to only accept sticky session routes

2011-05-24 Thread Jim Jagielski
I like the concept... will review.

PS: Most patches should be against trunk. We fold into trunk,
test and only then propose for backport for 2.2.x


On May 23, 2011, at 3:10 PM, Keith Mashinter wrote:

 I've added a patch to the proxy/balancer to allow for route-only workers are 
 only enabled for sticky session routes, allowing for an even more graceful 
 fade-out of a server than making its lbfactor=1 compared to lbfactor=100 for 
 others.  
 
 Please reply/vote if you also think it's useful.
 
 https://issues.apache.org/bugzilla/show_bug.cgi?id=51247
 This enhancement, actually SVN Patched against 2.2.19, provides a worker 
 status
 flag to set a proxy worker as only accepting requests with sticky session
 routes, e.g. only accept requests with a .route such as Cookie
 JSESSIONID=xxx.tc2.
 
 This allows for a graceful fade-out of servers when their sessions are 
 removed;
 they continue to receive requests for their sticky session routes but are
 passed over for requests with no specified route, just as if they were
 disabled.  In other words, route-only workers are only enabled for sticky
 session routes.
 
 Intended use (Tomcat JSESSIONID noted here but could be PHPSESSIONID, Ruby
 _session_id, or anything with cookie or request-parameter based session ids):
 1. An Apache rev-proxy running for multiple Tomcats.
 2. To fade-out a Tomcat for maintenance, set route-only enabled in
  the
 
 balancer-manager or reload the configuration with the worker status +R.
 (This depends on Tomcat web-apps delete session cookies, see further below.)
 3. Check on the balancer-manager or its Tomcat worker even a few minutes /
 hours, and when it seems to have completed old sessions you can mark it fully
 disabled.
 4. Once done maintenance, you can then set route-only disabled (status -R) and
 fully enable the worker again.
 
 To delete a JSESSIONID Cookie from a Servlet, you need to specify the same
 Domain and Path as the original Cookie and setMaxAge=0 as in the typical
 example below but you should check on your own Domain and Path when a Cookie 
 is
 created, e.g. watch the Cookie headers in Firefox Firebug.
 
 // To delete a Cookie setMaxAge(0) and also any original domain and path 
 if
 specified.
 Cookie ck = new
  Cookie(JSESSIONID, null);
 
 //ck.setDomain();
 ck.setPath(request.getContextPath());
 ck.setMaxAge(0);
 response.addCookie(ck);
  
 \|/- Keith Mashinter 
 kmash...@yahoo.com



Re: id=51247 Enhance mod_proxy and _balancer with worker status flag to only accept sticky session routes

2011-05-24 Thread Keith Mashinter
Thanks, understood, I'll attach a patch to Bugzilla for the trunk as well in 
the next day or two.


\|/- Keith Mashinter 
kmash...@yahoo.com



From: Jim Jagielski j...@jagunet.com
To: dev@httpd.apache.org; Keith Mashinter kmash...@yahoo.com
Sent: Tuesday, May 24, 2011 10:18:04 AM
Subject: Re: id=51247 Enhance mod_proxy and _balancer with worker status flag 
to only accept sticky session routes

I like the concept... will review.

PS: Most patches should be against trunk. We fold into trunk,
    test and only then propose for backport for 2.2.x


On May 23, 2011, at 3:10 PM, Keith Mashinter wrote:

 I've added a patch to the proxy/balancer to allow for route-only workers are 
 only enabled for sticky session routes, allowing for an even more graceful 
 fade-out of a server than making its lbfactor=1 compared to lbfactor=100 for 
 others.  
 
 Please reply/vote if you also think it's useful.
 
 https://issues.apache.org/bugzilla/show_bug.cgi?id=51247
 This enhancement, actually SVN Patched against 2.2.19, provides a worker 
 status
 flag to set a proxy worker as only accepting requests with sticky session
 routes, e.g. only accept requests with a .route such as Cookie
 JSESSIONID=xxx.tc2.
 
 This allows for a graceful fade-out of servers when their sessions are 
 removed;
 they continue to receive requests for their sticky session routes but are
 passed over for requests with no specified route, just as if they were
 disabled.  In other words, route-only workers are only enabled for sticky
 session routes.
 
 Intended use (Tomcat JSESSIONID noted here but could be PHPSESSIONID, Ruby
 _session_id, or anything with cookie or request-parameter based session ids):
 1. An Apache rev-proxy running for multiple Tomcats.
 2. To fade-out a Tomcat for maintenance, set route-only enabled in
  the
 
 balancer-manager or reload the configuration with the worker status +R.
 (This depends on Tomcat web-apps delete session cookies, see further below.)
 3. Check on the balancer-manager or its Tomcat worker even a few minutes /
 hours, and when it seems to have completed old sessions you can mark it fully
 disabled.
 4. Once done maintenance, you can then set route-only disabled (status -R) and
 fully enable the worker again.
 
 To delete a JSESSIONID Cookie from a Servlet, you need to specify the same
 Domain and Path as the original Cookie and setMaxAge=0 as in the typical
 example below but you should check on your own Domain and Path when a Cookie 
 is
 created, e.g. watch the Cookie headers in Firefox Firebug.
 
     // To delete a Cookie setMaxAge(0) and also any original domain and path 
if
 specified.
     Cookie ck = new
  Cookie(JSESSIONID, null);
 
     //ck.setDomain();
     ck.setPath(request.getContextPath());
     ck.setMaxAge(0);
     response.addCookie(ck);
  
 \|/- Keith Mashinter 
 kmash...@yahoo.com

Re: id=51247 Enhance mod_proxy and _balancer with worker status flag to only accept sticky session routes

2011-05-24 Thread Andrew Oliver
Let me know if you need help testing.  I likely can round up some
volunteers as this is something frequently asked about for my clients.

-Andy

On Tue, May 24, 2011 at 10:37 AM, Keith Mashinter kmash...@yahoo.com wrote:
 Thanks, understood, I'll attach a patch to Bugzilla for the trunk as well in
 the next day or two.

 \|/- Keith Mashinter
 kmash...@yahoo.com
 
 From: Jim Jagielski j...@jagunet.com
 To: dev@httpd.apache.org; Keith Mashinter kmash...@yahoo.com
 Sent: Tuesday, May 24, 2011 10:18:04 AM
 Subject: Re: id=51247 Enhance mod_proxy and _balancer with worker status
 flag to only accept sticky session routes

 I like the concept... will review.

 PS: Most patches should be against trunk. We fold into trunk,
     test and only then propose for backport for 2.2.x


 On May 23, 2011, at 3:10 PM, Keith Mashinter wrote:

 I've added a patch to the proxy/balancer to allow for route-only workers
 are only enabled for sticky session routes, allowing for an even more
 graceful fade-out of a server than making its lbfactor=1 compared to
 lbfactor=100 for others.

 Please reply/vote if you also think it's useful.

 https://issues.apache.org/bugzilla/show_bug.cgi?id=51247
 This enhancement, actually SVN Patched against 2.2.19, provides a worker
 status
 flag to set a proxy worker as only accepting requests with sticky session
 routes, e.g. only accept requests with a .route such as Cookie
 JSESSIONID=xxx.tc2.

 This allows for a graceful fade-out of servers when their sessions are
 removed;
 they continue to receive requests for their sticky session routes but are
 passed over for requests with no specified route, just as if they were
 disabled.  In other words, route-only workers are only enabled for sticky
 session routes.

 Intended use (Tomcat JSESSIONID noted here but could be PHPSESSIONID, Ruby
 _session_id, or anything with cookie or request-parameter based session
 ids):
 1. An Apache rev-proxy running for multiple Tomcats.
 2. To fade-out a Tomcat for maintenance, set route-only enabled in
  the

 balancer-manager or reload the configuration with the worker status +R.
 (This depends on Tomcat web-apps delete session cookies, see further
 below.)
 3. Check on the balancer-manager or its Tomcat worker even a few minutes /
 hours, and when it seems to have completed old sessions you can mark it
 fully
 disabled.
 4. Once done maintenance, you can then set route-only disabled (status -R)
 and
 fully enable the worker again.

 To delete a JSESSIONID Cookie from a Servlet, you need to specify the same
 Domain and Path as the original Cookie and setMaxAge=0 as in the typical
 example below but you should check on your own Domain and Path when a
 Cookie is
 created, e.g. watch the Cookie headers in Firefox Firebug.

    // To delete a Cookie setMaxAge(0) and also any original domain and
 path if
 specified.
    Cookie ck = new
  Cookie(JSESSIONID, null);

    //ck.setDomain();
    ck.setPath(request.getContextPath());
    ck.setMaxAge(0);
    response.addCookie(ck);

 \|/- Keith Mashinter
 kmash...@yahoo.com






Re: id=51247 Enhance mod_proxy and _balancer with worker status flag to only accept sticky session routes

2011-05-24 Thread Daniel Ruggeri

On 5/24/2011 9:18 AM, Jim Jagielski wrote:

I like the concept... will review.

PS: Most patches should be against trunk. We fold into trunk,
 test and only then propose for backport for 2.2.x


On May 23, 2011, at 3:10 PM, Keith Mashinter wrote:


I've added a patch to the proxy/balancer to allow for route-only workers are 
only enabled for sticky session routes, allowing for an even more graceful 
fade-out of a server than making its lbfactor=1 compared to lbfactor=100 for 
others.

Please reply/vote if you also think it's useful.

https://issues.apache.org/bugzilla/show_bug.cgi?id=51247
This enhancement, actually SVN Patched against 2.2.19, provides a worker status
flag to set a proxy worker as only accepting requests with sticky session
routes, e.g. only accept requests with a .route such as Cookie
JSESSIONID=xxx.tc2.
 ...





I think there are two patches available to do the same thing - sorry for 
not following up on this sooner. I brought this up in conversation with 
Bill on this list back in October and haven't dug into it since.


I attached the patch to a bug opened by Cameron Stokes
https://issues.apache.org/bugzilla/show_bug.cgi?id=48841

I agree that this functionality would be nice to have but am agnostic as 
to which method accomplishes this :) They both seem to take different 
routes to get to the same goal.


Jim, if you wouldn't mind reviewing both and suggesting one to be 
cleaned up for a patch generated against trunk. I'm happy to volunteer 
the effort to adjust my patch or at least take care of that bug that's 
out there still.


--
--
Daniel Ruggeri
Only in httpd-2.2.15-patched: httpd2.2.15.EnableZeroLbfactor.patch
Only in httpd-2.2.15-patched/modules/proxy: httpd2.2.15.EnableZeroLbfactor.patch
diff -ru httpd-2.2.15/modules/proxy/mod_proxy.c 
httpd-2.2.15-patched/modules/proxy/mod_proxy.c
--- httpd-2.2.15/modules/proxy/mod_proxy.c  2009-01-31 14:58:07.0 
-0600
+++ httpd-2.2.15-patched/modules/proxy/mod_proxy.c  2010-04-05 
15:42:53.0 -0500
@@ -77,9 +77,13 @@
 /* Normalized load factor. Used with BalancerMamber,
  * it is a number between 1 and 100.
  */
-worker-lbfactor = atoi(val);
-if (worker-lbfactor  1 || worker-lbfactor  100)
-return LoadFactor must be number between 1..100;
+//worker-lbfactor = atoi(val);
+worker-lbfactor = strtol(val, NULL, 10);
+if (errno == EINVAL || worker-lbfactor  0 || worker-lbfactor  100)
+return LoadFactor must be number between 0..100 (0 disables this 
worker);
+
+if(worker-lbfactor == 0)
+worker-lbfactor=PROXY_WORKER_NOLBFACTOR;
 }
 else if (!strcasecmp(key, retry)) {
 /* If set it will give the retry timeout for the worker
diff -ru httpd-2.2.15/modules/proxy/mod_proxy.h 
httpd-2.2.15-patched/modules/proxy/mod_proxy.h
--- httpd-2.2.15/modules/proxy/mod_proxy.h  2010-02-15 13:54:41.0 
-0600
+++ httpd-2.2.15-patched/modules/proxy/mod_proxy.h  2010-04-05 
15:43:26.0 -0500
@@ -791,5 +791,8 @@
 
 extern int PROXY_DECLARE_DATA proxy_lb_workers;
 
+/* For setting lbfactor to zero */
+#define PROXY_WORKER_NOLBFACTOR101
+
 #endif /*MOD_PROXY_H*/
 /** @} */
diff -ru httpd-2.2.15/modules/proxy/mod_proxy_balancer.c 
httpd-2.2.15-patched/modules/proxy/mod_proxy_balancer.c
--- httpd-2.2.15/modules/proxy/mod_proxy_balancer.c 2009-04-25 
04:43:38.0 -0500
+++ httpd-2.2.15-patched/modules/proxy/mod_proxy_balancer.c 2010-04-05 
15:46:42.0 -0500
@@ -106,8 +106,11 @@
 ap_proxy_initialize_worker(workers, s);
 if (!worker_is_initialized) {
 /* Set to the original configuration */
-workers-s-lbstatus = workers-s-lbfactor =
-(workers-lbfactor ? workers-lbfactor : 1);
+workers-lbfactor = (workers-lbfactor ? workers-lbfactor : 1);
+if(workers-lbfactor == PROXY_WORKER_NOLBFACTOR)
+workers-lbfactor=0;
+
+workers-s-lbstatus = workers-s-lbfactor = workers-lbfactor;
 workers-s-lbset = workers-lbset;
 }
 ++workers;
@@ -743,7 +746,7 @@
 const char *val;
 if ((val = apr_table_get(params, lf))) {
 int ival = atoi(val);
-if (ival = 1  ival = 100) {
+if (ival = 0  ival = 100) {
 wsel-s-lbfactor = ival;
 if (bsel)
 recalc_factors(bsel);
@@ -1112,11 +1115,13 @@
  * not in error state or not disabled.
  */
 if (PROXY_WORKER_IS_USABLE(worker)) {
-mytraffic = (worker-s-transferred/worker-s-lbfactor) +
-(worker-s-read/worker-s-lbfactor);
-if (!mycandidate || mytraffic  curmin) {
-mycandidate = worker;
-curmin = mytraffic;
+if (worker-s-lbfactor != 0){
+  

id=51247 Enhance mod_proxy and _balancer with worker status flag to only accept sticky session routes

2011-05-23 Thread Keith Mashinter
I've added a patch to the proxy/balancer to allow for route-only workers are 
only enabled for sticky session routes, allowing for an even more graceful 
fade-out of a server than making its lbfactor=1 compared to lbfactor=100 for 
others.  


Please reply/vote if you also think it's useful.


https://issues.apache.org/bugzilla/show_bug.cgi?id=51247
This enhancement, actually SVN Patched against 2.2.19, provides a worker status
flag to set a proxy worker as only accepting requests with sticky session
routes, e.g. only accept requests with a .route such as Cookie
JSESSIONID=xxx.tc2.

This allows for a graceful fade-out of servers when their sessions are removed;
they continue to receive requests for their sticky session routes but are
passed over for requests with no specified route, just as if they were
disabled.  In other words, route-only workers are only enabled for sticky
session routes.

Intended use (Tomcat JSESSIONID noted here but could be PHPSESSIONID, Ruby
_session_id, or anything with cookie or request-parameter based session ids):
1. An Apache rev-proxy running for multiple Tomcats.
2. To fade-out a Tomcat for maintenance, set route-only enabled in the
balancer-manager or reload the configuration with the worker status +R.
(This depends on Tomcat web-apps delete session cookies, see further below.)
3. Check on the balancer-manager or its Tomcat worker even a few minutes /
hours, and when it seems to have completed old sessions you can mark it fully
disabled.
4. Once done maintenance, you can then set route-only disabled (status -R) and
fully enable the worker again.

To delete a JSESSIONID Cookie from a Servlet, you need to specify the same
Domain and Path as the original Cookie and setMaxAge=0 as in the typical
example below but you should check on your own Domain and Path when a Cookie is
created, e.g. watch the Cookie headers in Firefox Firebug.

// To delete a Cookie setMaxAge(0) and also any original domain and path if
specified.
Cookie ck = new Cookie(JSESSIONID, null);
//ck.setDomain();
ck.setPath(request.getContextPath());
ck.setMaxAge(0);
response.addCookie(ck);
 
\|/- Keith Mashinter 
kmash...@yahoo.com