|Summary:||mod_jk load balance algorithm that accounts for current worker load|
|Product:||Tomcat Connectors||Reporter:||Chris Lamprecht <clamprecht>|
|Component:||Common||Assignee:||Tomcat Developers Mailing List <dev>|
|Bug Depends on:|
|Attachments:||New load balancing algorithm for mod_jk|
Description Chris Lamprecht 2005-08-11 06:11:44 UTC
This is the mod_jk patch I mentioned on the tomcat-dev mailing list on August 6. The patch adds a new lb.method option 'B' for 'Busyness'. The algorithm picks the lbworker with the lowest current load, based on how many requests the worker is currently serving (the "Busy" column in the jkstatus page). This number is divided by the worker's lbfactor, and the lowest value (least busy) worker is picked. We tested about 25-30 threads against 6 load-balanced tomcats with requests that take about 250ms each to complete. Using the "Busyness" algorithm improved our throughput from 12-16 requests per second to 60+ requests per second, and watching the jkstatus page showed that all servers were kept "evenly" busy. If one particular server started lagging, its Busy value increased, so it received fewer requests. If a request is received when none of the workers are busy, this algorithm is effectively an evenly-weighted round-robin. Note that we found some race conditions with the code that updates the various lb status values, especially the lbworker "busy" value, which our algorithm requires to be accurate. To fix this, we had to refactor some of the shared memory and critical-section locking code, by moving the lock into get_most_suitable_worker() (jk_lb_worker.c). We also found some problems that would cause the 'busy' value to be set to less than zero (displaying MAX_INT - 1, for example, in jkstatus). We fixed this by setting the busy value to 0 if it is ever less than 0. See jk_lb_worker.c lines 389-400. Finally, we added a new column to the jkstatus page. The "Ssc" column now reports the number of times the worker was reused from sticky session. See jk_shm.c line 89, and jk_lb_worker.c line 584. We have load-tested this patch under apache 2.0.50, and we've also been running it in a busy production site for almost a week. This patch is donated by Andrew Hudson and Chris Lamprecht.
Comment 1 Chris Lamprecht 2005-08-11 06:12:45 UTC
Created attachment 16009 [details] New load balancing algorithm for mod_jk
Comment 2 Shankar Unni 2006-02-27 22:50:22 UTC
fixed summary back - someone (mohan@...) accidentally munged it.
Comment 3 Mladen Turk 2006-03-16 07:55:29 UTC
Commited to the trunk. I have modified couple of things, mostly removing extra stuff added to shm. Thanks.