-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add vnswrr algorithm for upstream module. #1306
Conversation
} | ||
|
||
*rpeer = best; | ||
if (best == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
peers->peer
will be never empty, and we don't skip failed peer, is it possible to have a NULL
value best
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, thx.
The check logical is not necessary.
uvnscf->vnumber = i; | ||
} | ||
|
||
begin_number = (uvnscf->last_number + 1) % uvnscf->vnumber; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we don't need to % uvnscf->vnumber
here? There is already a % uvnscf->vnumber
in the for loop below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary. Because the initial value of begin_number
is ngx_random() % peers->number
, But uvnscf->vnumber <= peers->number
.
Test Result
Introduction
The
VNSWRR
module is an efficient load balancing algorithm that is smooth, decentralized, and high-performance compared to Nginx's officialSWRR
algorithm.Example
Installation
Build Tengine with this module from source:
Directive
Enable
VNSWRR
load balancing algorithm.Performance
In the same pressure environment, the CPU consumption of
VNSWRR
algorithm accounts for0.27%
(ngx_http_upstream_get_vnswrr
).Compared with
VNSWRR
algorithm, the CPU consumption ofSWRR
(ngx_http_upstream_get_peer
39%
) is an order of magnitude higher thanVNSWRR
.In the above environment, the QPS of
VNSWRR
increases by60%
compared withSWRR
algorithm.Observing the changes of QPS and RT in the different back-end number scenarios.
Under SWRR algorithm, when the number of back-end for every
500
addition, then the QPS of Nginx decreases by about10%
and RT increases by about1 ms
. But under theVNSWRR
algorithm, QPS and RT do not change much.