tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r1174394 - in /tomcat/jk/trunk: native/common/jk_lb_worker.c native/common/jk_lb_worker.h native/common/jk_status.c xdocs/miscellaneous/changelog.xml xdocs/reference/status.xml xdocs/reference/workers.xml
Date Thu, 22 Sep 2011 21:17:03 GMT
Author: rjung
Date: Thu Sep 22 21:17:03 2011
New Revision: 1174394

URL: http://svn.apache.org/viewvc?rev=1174394&view=rev
Log:
New LB balancing method "Next" to distribute
sessions in a round-robin way.

Modified:
    tomcat/jk/trunk/native/common/jk_lb_worker.c
    tomcat/jk/trunk/native/common/jk_lb_worker.h
    tomcat/jk/trunk/native/common/jk_status.c
    tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml
    tomcat/jk/trunk/xdocs/reference/status.xml
    tomcat/jk/trunk/xdocs/reference/workers.xml

Modified: tomcat/jk/trunk/native/common/jk_lb_worker.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_lb_worker.c?rev=1174394&r1=1174393&r2=1174394&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_lb_worker.c (original)
+++ tomcat/jk/trunk/native/common/jk_lb_worker.c Thu Sep 22 21:17:03 2011
@@ -185,6 +185,8 @@ int jk_lb_get_method_code(const char *v)
         return JK_LB_METHOD_BUSYNESS;
     else if  (*v == 's' || *v == 'S' || *v == '3')
         return JK_LB_METHOD_SESSIONS;
+    else if  (*v == 'n' || *v == 'N' || *v == '4')
+        return JK_LB_METHOD_NEXT;
     else
         return JK_LB_METHOD_DEF;
 }
@@ -619,14 +621,21 @@ static jk_uint64_t decay_load(lb_worker_
 {
     unsigned int i;
     jk_uint64_t curmax = 0;
+    jk_uint64_t curmin;
     lb_sub_worker_t *w;
     ajp_worker_t *aw;
 
     JK_TRACE_ENTER(l);
+    curmin = (&p->lb_workers[0])->s->lb_value;
     for (i = 0; i < p->num_of_workers; i++) {
         w = &p->lb_workers[i];
         if (p->lbmethod != JK_LB_METHOD_BUSYNESS) {
-            w->s->lb_value >>= exponent;
+            if (p->lbmethod != JK_LB_METHOD_NEXT) {
+                w->s->lb_value >>= exponent;
+            }
+            if (w->s->lb_value < curmin) {
+                curmin = w->s->lb_value;
+            }
             if (w->s->lb_value > curmax) {
                 curmax = w->s->lb_value;
             }
@@ -634,6 +643,12 @@ static jk_uint64_t decay_load(lb_worker_
         aw = (ajp_worker_t *)w->worker->worker_private;
         aw->s->reply_timeouts >>= exponent;
     }
+    if (p->lbmethod == JK_LB_METHOD_NEXT) {
+        for (i = 0; i < p->num_of_workers; i++) {
+            w = &p->lb_workers[i];
+            w->s->lb_value -= curmin;
+        }
+    }
     JK_TRACE_EXIT(l);
     return curmax;
 }
@@ -1219,10 +1234,11 @@ static int JK_METHOD service(jk_endpoint
                 rec->s->busy++;
                 if (p->worker->s->busy > p->worker->s->max_busy)
                     p->worker->s->max_busy = p->worker->s->busy;
-                if ( (p->worker->lbmethod == JK_LB_METHOD_REQUESTS) ||
-                     (p->worker->lbmethod == JK_LB_METHOD_BUSYNESS) ||
-                     (p->worker->lbmethod == JK_LB_METHOD_SESSIONS &&
-                      !sessionid) )
+                if (p->worker->lbmethod == JK_LB_METHOD_REQUESTS ||
+                    p->worker->lbmethod == JK_LB_METHOD_BUSYNESS ||
+                    (!sessionid &&
+                     (p->worker->lbmethod == JK_LB_METHOD_SESSIONS ||
+                      p->worker->lbmethod == JK_LB_METHOD_NEXT)))
                     rec->s->lb_value += rec->lb_mult;
                 if (p->worker->lblock == JK_LB_LOCK_PESSIMISTIC)
                     jk_shm_unlock();

Modified: tomcat/jk/trunk/native/common/jk_lb_worker.h
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_lb_worker.h?rev=1174394&r1=1174393&r2=1174394&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_lb_worker.h (original)
+++ tomcat/jk/trunk/native/common/jk_lb_worker.h Thu Sep 22 21:17:03 2011
@@ -44,12 +44,14 @@ extern "C"
 #define JK_LB_METHOD_TRAFFIC           (1)
 #define JK_LB_METHOD_BUSYNESS          (2)
 #define JK_LB_METHOD_SESSIONS          (3)
+#define JK_LB_METHOD_NEXT              (4)
 #define JK_LB_METHOD_DEF               (JK_LB_METHOD_REQUESTS)
-#define JK_LB_METHOD_MAX               (JK_LB_METHOD_SESSIONS)
+#define JK_LB_METHOD_MAX               (JK_LB_METHOD_NEXT)
 #define JK_LB_METHOD_TEXT_REQUESTS     ("Request")
 #define JK_LB_METHOD_TEXT_TRAFFIC      ("Traffic")
 #define JK_LB_METHOD_TEXT_BUSYNESS     ("Busyness")
 #define JK_LB_METHOD_TEXT_SESSIONS     ("Sessions")
+#define JK_LB_METHOD_TEXT_NEXT         ("Next")
 #define JK_LB_METHOD_TEXT_DEF          (JK_LB_METHOD_TEXT_REQUESTS)
 #define JK_LB_LOCK_OPTIMISTIC          (0)
 #define JK_LB_LOCK_PESSIMISTIC         (1)

Modified: tomcat/jk/trunk/native/common/jk_status.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_status.c?rev=1174394&r1=1174393&r2=1174394&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_status.c (original)
+++ tomcat/jk/trunk/native/common/jk_status.c Thu Sep 22 21:17:03 2011
@@ -2720,6 +2720,12 @@ static void form_worker(jk_ws_service_t 
     if (lb->lbmethod == JK_LB_METHOD_SESSIONS)
         jk_puts(s, " checked=\"checked\"");
     jk_puts(s, "/></td></tr>\n");
+    jk_putv(s, "<tr><td>&nbsp;&nbsp;Next</td><td><input
name=\"",
+            JK_STATUS_ARG_LB_METHOD, "\" type=\"radio\"", NULL);
+    jk_printf(s, " value=\"%d\"", JK_LB_METHOD_NEXT);
+    if (lb->lbmethod == JK_LB_METHOD_NEXT)
+        jk_puts(s, " checked=\"checked\"");
+    jk_puts(s, "/></td></tr>\n");
     jk_putv(s, "<tr><td>", JK_STATUS_ARG_LB_TEXT_LOCK,
             ":</td><td></td></tr>\n", NULL);
     jk_putv(s, "<tr><td>&nbsp;&nbsp;Optimistic</td><td><input
name=\"",

Modified: tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml?rev=1174394&r1=1174393&r2=1174394&view=diff
==============================================================================
--- tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml Thu Sep 22 21:17:03 2011
@@ -53,6 +53,10 @@
         variable JK_STICKY_IGNORE. This can be useful to break cookie stickyness
         for non-sticky requests like login forms. (rjung)
       </add>
+      <add>
+        LB: New balancing method "Next" to distribute sessions in a round-robin
+        way. (rjung)
+      </add>
     </changelog>
   </subsection>
 </section>

Modified: tomcat/jk/trunk/xdocs/reference/status.xml
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/xdocs/reference/status.xml?rev=1174394&r1=1174393&r2=1174394&view=diff
==============================================================================
--- tomcat/jk/trunk/xdocs/reference/status.xml (original)
+++ tomcat/jk/trunk/xdocs/reference/status.xml Thu Sep 22 21:17:03 2011
@@ -487,7 +487,7 @@ contain the configuration information, y
 <b>vlf</b>: sticky_session_force (0/f/n/off=off, 1/t/y/on=on; case insensitive)
 </li>
 <li>
-<b>vlm</b>: method (0/r="Requests", 1/t="Traffic", 2/b="Busyness", 3/s="Sessions";
case insensitive, only first character is used)
+<b>vlm</b>: method (0/r="Requests", 1/t="Traffic", 2/b="Busyness", 3/s="Sessions",
4/s="Next"; case insensitive, only first character is used)
 </li>
 <li>
 <b>vll</b>: lock (0/o="Optimistic", 1/p="Pessimistic"; case insensitive, only
first character is used)

Modified: tomcat/jk/trunk/xdocs/reference/workers.xml
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/xdocs/reference/workers.xml?rev=1174394&r1=1174393&r2=1174394&view=diff
==============================================================================
--- tomcat/jk/trunk/xdocs/reference/workers.xml (original)
+++ tomcat/jk/trunk/xdocs/reference/workers.xml Thu Sep 22 21:17:03 2011
@@ -536,13 +536,13 @@ setting of worker.maintain. The value of
 using the status worker.
 </p>
 <p>
-If method is set to <b>R[equest]</b> the balancer will use number of requests
+If method is set to <b>R[equest]</b> the balancer will use the number of requests
 to find the best worker. Accesses will be distributed according to the
 lbfactor in a sliding time window. This is the default value and should be
 working well for most applications.
 </p>
 <p>
-If method is set to <b>S[ession]</b> the balancer will use number of sessions
+If method is set to <b>S[ession]</b> the balancer will use the number of sessions
 to find the best worker. Accesses will be distributed according to the
 lbfactor in a sliding time window. Because the balancer does not keep any state,
 it actually does not know the number of sessions. Instead it counts each request
@@ -553,6 +553,18 @@ if sessions are your limiting resource, 
 and your sessions need a lot of memory.
 </p>
 <p>
+If method is set to <b>N[ext]</b> the balancer will again use the number of sessions
+to find the best worker. The difference to the <b>S[ession]</b> method is how
+the session count is handled in the sliding time window. The <b>N[ext]</b> method
+does not divide by 2, instead it subtracts the minimum number. This should effectively
+result in a round-robin session balancing, thus the name <b>N[ext]</b>.
+Under high load, the two session balancing
+methods will result in a similar distribution, but <b>N[ext]</b> will be better
+if you need to distribute small numbers of sessions. Again this method will
+neither know, when a session is being invalidated, nor will it correct its load numbers
+according to session timeouts or worker failover.
+</p>
+<p>
 If set to <b>T[raffic]</b> the balancer will use
 the network traffic between JK and Tomcat to find the best worker.
 Accesses will be distributed according to the lbfactor in a sliding time window.



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


Mime
View raw message