nghttpx: Randomize backend address round robin order per thread

This commit is contained in:
Tatsuhiro Tsujikawa 2019-01-11 22:36:45 +09:00
parent 11d0533cfc
commit fdcdb21c38
1 changed files with 3 additions and 0 deletions

View File

@ -304,6 +304,9 @@ void Worker::replace_downstream_config(
shared_addr->http1_pri.weight = num_http1; shared_addr->http1_pri.weight = num_http1;
shared_addr->http2_pri.weight = num_http2; shared_addr->http2_pri.weight = num_http2;
std::shuffle(std::begin(shared_addr->addrs), std::end(shared_addr->addrs),
randgen_);
if (shared_addr->affinity.type != SessionAffinity::NONE) { if (shared_addr->affinity.type != SessionAffinity::NONE) {
for (auto &addr : shared_addr->addrs) { for (auto &addr : shared_addr->addrs) {
addr.dconn_pool = std::make_unique<DownstreamConnectionPool>(); addr.dconn_pool = std::make_unique<DownstreamConnectionPool>();