Permalink
Browse files

Improved Node.js request load balancing

Closes GH-1322. Thanks to Charles Vallières for the analysis.
  • Loading branch information...
FooBarWidget committed Dec 18, 2014
1 parent 09eb0e3 commit 427800427f35b2396ca9cbb208f8267c4374c7e8
Showing with 10 additions and 11 deletions.
  1. +1 −0 CHANGELOG
  2. +9 −11 ext/common/ApplicationPool2/Process.h
View
@@ -47,6 +47,7 @@ Release 4.0.56
--------------
* Fixed a file descriptor leak that manifests when an error page is shown. Contributed by Paul Bonaud, closes GH-1325.
* Improved Node.js request load balancing. Closes GH-1322. Thanks to Charles Vallières for the analysis.
Release 4.0.55
@@ -534,19 +534,17 @@ class Process: public boost::enable_shared_from_this<Process> {
int busyness() const {
/* Different processes within a Group may have different
* 'concurrency' values. We want:
* - Group.pqueue to sort the processes from least used to most used.
* - to give processes with concurrency == 0 more priority over processes
* with concurrency > 0.
* Therefore, we describe our busyness as a percentage of 'concurrency', with
* the percentage value in [0..INT_MAX] instead of [0..1].
* - the process with the smallest busyness to be be picked for routing.
* - to give processes with concurrency == 0 more priority (in general)
* over processes with concurrency > 0.
* Therefore, in case of processes with concurrency > 0, we describe our
* busyness as a percentage of 'concurrency', with the percentage value
* in [0..INT_MAX] instead of [0..1]. That way, the busyness value
* of processes with concurrency > 0 is usually higher than that of processes
* with concurrency == 0.
*/
if (concurrency == 0) {
// Allows Group.pqueue to give idle sockets more priority.
if (sessions == 0) {
return 0;
} else {
return 1;
}
return sessions;
} else {
return (int) (((long long) sessions * INT_MAX) / (double) concurrency);
}

0 comments on commit 4278004

Please sign in to comment.