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.000000000
-0600
+++ httpd-2.2.15-patched/modules/proxy/mod_proxy.c 2010-04-05
15:42:53.000000000 -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.000000000
-0600
+++ httpd-2.2.15-patched/modules/proxy/mod_proxy.h 2010-04-05
15:43:26.000000000 -0500
@@ -791,5 +791,8 @@
extern int PROXY_DECLARE_DATA proxy_lb_workers;
+/* For setting lbfactor to zero */
+#define PROXY_WORKER_NOLBFACTOR 101
+
#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.000000000 -0500
+++ httpd-2.2.15-patched/modules/proxy/mod_proxy_balancer.c 2010-04-05
15:46:42.000000000 -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){
+ mytraffic =
(worker->s->transferred/worker->s->lbfactor) +
+ (worker->s->read/worker->s->lbfactor);
+ if (!mycandidate || mytraffic < curmin) {
+ mycandidate = worker;
+ curmin = mytraffic;
+ }
}
}
}