nghttpx: Better distribute load to backend h2 servers
This commit is contained in:
parent
290a697bf9
commit
53989dc70c
|
@ -737,6 +737,8 @@ ClientHandler::get_downstream_connection(Downstream *downstream) {
|
||||||
if (shared_addr->proto == PROTO_HTTP2) {
|
if (shared_addr->proto == PROTO_HTTP2) {
|
||||||
auto &http2_freelist = shared_addr->http2_freelist;
|
auto &http2_freelist = shared_addr->http2_freelist;
|
||||||
|
|
||||||
|
Http2Session *http2session;
|
||||||
|
|
||||||
if (http2_freelist.empty() ||
|
if (http2_freelist.empty() ||
|
||||||
http2_freelist.size() < shared_addr->addrs.size()) {
|
http2_freelist.size() < shared_addr->addrs.size()) {
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
|
@ -749,21 +751,22 @@ ClientHandler::get_downstream_connection(Downstream *downstream) {
|
||||||
<< shared_addr->addrs.size();
|
<< shared_addr->addrs.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto session = make_unique<Http2Session>(
|
http2session = new Http2Session(
|
||||||
conn_.loop, shared_addr->tls ? worker_->get_cl_ssl_ctx() : nullptr,
|
conn_.loop, shared_addr->tls ? worker_->get_cl_ssl_ctx() : nullptr,
|
||||||
worker_, &group);
|
worker_, &group);
|
||||||
http2_freelist.append(session.release());
|
} else {
|
||||||
|
http2session = http2_freelist.head;
|
||||||
|
http2_freelist.remove(http2session);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto http2session = http2_freelist.head;
|
|
||||||
|
|
||||||
if (http2session->max_concurrency_reached(1)) {
|
if (http2session->max_concurrency_reached(1)) {
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
CLOG(INFO, this) << "Maximum streams are reached for Http2Session("
|
CLOG(INFO, this) << "Maximum streams are reached for Http2Session("
|
||||||
<< http2session
|
<< http2session
|
||||||
<< "). Remove Http2Session from http2_freelist";
|
<< "). Remove Http2Session from http2_freelist";
|
||||||
}
|
}
|
||||||
http2_freelist.remove(http2session);
|
} else {
|
||||||
|
http2_freelist.append(http2session);
|
||||||
}
|
}
|
||||||
|
|
||||||
dconn = make_unique<Http2DownstreamConnection>(http2session);
|
dconn = make_unique<Http2DownstreamConnection>(http2session);
|
||||||
|
|
Loading…
Reference in New Issue