tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andre Gebers <andre.geb...@tipp24.de>
Subject mod_jk change lb behavior for local_workers
Date Fri, 23 Jan 2004 09:56:57 GMT
Hi,

i had a problem setting up mod_jk to load-balance my local_workers 
properly. Here is my environment:

2 Apaches 2.0.48 + mod_jk 1.2.5
4 Workers behind them.
all on linux rh8

the workers.properties for apache-A look like this:

worker.list=loadbal

worker.devprocA1.type=ajp13
worker.devprocA1.host=w1.my.net
worker.devprocA1.port=10011
worker.devprocA1.lbfactor=1
worker.devprocA1.local_worker=1

worker.devprocA2.type=ajp13
worker.devprocA2.host=w2.my.net
worker.devprocA2.port=10012
worker.devprocA2.lbfactor=1
worker.devprocA2.local_worker=1

worker.devprocB1.type=ajp13
worker.devprocB1.host=w3.my.net
worker.devprocB1.port=10021
worker.devprocB1.lbfactor=1
worker.devprocB1.local_worker=0

worker.devprocB2.type=ajp13
worker.devprocB2.host=w4.my.net
worker.devprocB2.port=10022
worker.devprocB2.lbfactor=1
worker.devprocB2.local_worker=0

worker.loadbal.type=lb
worker.loadbal.balanced_workers= devprocA1, devprocA2, devprocB1, devprocB2
worker.loadbal.local_worker_only=0
worker.loadbal.sticky_session=1

the workers.properties for apache-B looks the same, except for the 
worker.devproc*.local_worker setting, which is inverted.

My goal was to balance devprocA1,devprocA2 by Apache-A and 
devprocB1,devprocB2 by Apache-B + If Apache-A local workers fail it 
should failover to the B-Workers and vice-versa for Apache-B

Everything worked fine except the balancing of the local_workers.

Apache-A balanced every request to devprocA1 and Apache-B balanced every 
request to devprocB1. The balancing with a sticky session sill worked fine.

Maybe i misunderstood the meaning of local_worker but in my opinion it 
should first try to balance the local_workers (equally) and if all 
local_worker fail it should try to balance the other workers (equally).

I had a look at the mod_jk code and after applying the patch below it 
worked as expected.

--------- cut here ---------
diff -ruN 
jakarta-tomcat-connectors-jk-1.2.5-src/jk/native/common/jk_lb_worker.c 
jakarta-tomcat-connectors-jk-1.2.5-src_patch/jk/native/common/jk_lb_worker.c
--- 
jakarta-tomcat-connectors-jk-1.2.5-src/jk/native/common/jk_lb_worker.c 
     2003-07-15 14:15:42.000000000 +0200
+++ 
jakarta-tomcat-connectors-jk-1.2.5-src_patch/jk/native/common/jk_lb_worker.c 
        2004-01-23 09:15:55.000000000 +0100
@@ -291,16 +291,17 @@
                      }
                  }
              } else {
-                if(p->lb_workers[i].lb_value < lb_min || !rc) {
+                if(!rc ||
+                   (!rc->is_local_worker && 
p->lb_workers[i].is_local_worker) ||
+                   ((rc->is_local_worker == 
p->lb_workers[i].is_local_worker) && (p->lb_workers[i].lb_value < 
lb_min))) {
                      lb_min = p->lb_workers[i].lb_value;
                      rc = &(p->lb_workers[i]);
-                    if (rc->is_local_worker) break;
                  }
              }
          }
      }

-    if(rc && !rc->is_local_worker) {
+    if(rc) {
          rc->lb_value += rc->lb_factor;
      }
--------- cut here ---------

any comments?

if the code and lb change is ok, please feel free to commit the patch to 
the cvs.

thanks
Andre


-- 
Software-Entwicklung

Tipp24 AG
Kleine Johannisstrasse 2-4
20457 Hamburg | Germany
phone +49 (0)40 32 55 33-37
fax   +49 (0)40 32 55 33-99

http://www.Tipp24.de
Tipp24.de - Einfach mal im Lotto gewinnen.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message