nghttpx: Don't greedily read data from backend

This might help throughput, but it interfere stream priority.  The
throughput issue is generally caused by the small buffer size to store
response body, which was 16K.  We increased it to 128K to compensate
this change.
This commit is contained in:
Tatsuhiro Tsujikawa 2016-01-20 11:12:52 +09:00
parent 6377c51f9c
commit eb8649bf9b
3 changed files with 0 additions and 35 deletions

View File

@ -1241,22 +1241,11 @@ ssize_t downstream_data_read_callback(nghttp2_session *session,
void *user_data) {
int rv;
auto downstream = static_cast<Downstream *>(source->ptr);
auto upstream = static_cast<Http2Upstream *>(downstream->get_upstream());
auto body = downstream->get_response_buf();
assert(body);
auto dconn = downstream->get_downstream_connection();
const auto &resp = downstream->response();
if (body->rleft() == 0 && dconn &&
downstream->get_response_state() != Downstream::MSG_COMPLETE) {
// Try to read more if buffer is empty. This will help small
// buffer and make priority handling a bit better.
if (upstream->downstream_read(dconn) != 0) {
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
}
auto nread = std::min(body->rleft(), length);
auto body_empty = body->rleft() == nread;

View File

@ -571,22 +571,9 @@ int HttpsUpstream::on_write() {
return 0;
}
auto dconn = downstream->get_downstream_connection();
auto output = downstream->get_response_buf();
const auto &resp = downstream->response();
if (output->rleft() == 0 && dconn &&
downstream->get_response_state() != Downstream::MSG_COMPLETE) {
if (downstream->resume_read(SHRPX_NO_BUFFER, resp.unconsumed_body_length) !=
0) {
return -1;
}
if (downstream_read(dconn) != 0) {
return -1;
}
}
if (output->rleft() > 0) {
return 0;
}

View File

@ -786,17 +786,6 @@ ssize_t spdy_data_read_callback(spdylay_session *session, int32_t stream_id,
auto body = downstream->get_response_buf();
assert(body);
auto dconn = downstream->get_downstream_connection();
if (body->rleft() == 0 && dconn &&
downstream->get_response_state() != Downstream::MSG_COMPLETE) {
// Try to read more if buffer is empty. This will help small
// buffer and make priority handling a bit better.
if (upstream->downstream_read(dconn) != 0) {
return SPDYLAY_ERR_CALLBACK_FAILURE;
}
}
auto nread = body->remove(buf, length);
auto body_empty = body->rleft() == 0;