nghttpx: Add --backend-response-buffer option

This commit is contained in:
Tatsuhiro Tsujikawa 2015-01-13 23:20:06 +09:00
parent 0d614cf103
commit c88a5291b7
4 changed files with 32 additions and 1 deletions

View File

@ -747,6 +747,7 @@ void fill_default_config() {
mod_config()->listener_disable_timeout = 0.; mod_config()->listener_disable_timeout = 0.;
mod_config()->auto_tls_ticket_key = true; mod_config()->auto_tls_ticket_key = true;
mod_config()->tls_ctx_per_worker = false; mod_config()->tls_ctx_per_worker = false;
mod_config()->downstream_response_buffer_size = 64 * 1024;
} }
} // namespace } // namespace
@ -877,6 +878,11 @@ Performance:
Set maximum number of open files (RLIMIT_NOFILE) to <N>. Set maximum number of open files (RLIMIT_NOFILE) to <N>.
If 0 is given, nghttpx does not set the limit. If 0 is given, nghttpx does not set the limit.
Default: )" << get_config()->rlimit_nofile << R"( Default: )" << get_config()->rlimit_nofile << R"(
--backend-response-buffer=<SIZE>
Set buffer size used to store backend response.
Default: )"
<< util::utos_with_unit(get_config()->downstream_response_buffer_size)
<< R"(
Timeout: Timeout:
--frontend-http2-read-timeout=<SEC> --frontend-http2-read-timeout=<SEC>
@ -1273,6 +1279,7 @@ int main(int argc, char **argv) {
{"tls-ticket-key-file", required_argument, &flag, 68}, {"tls-ticket-key-file", required_argument, &flag, 68},
{"rlimit-nofile", required_argument, &flag, 69}, {"rlimit-nofile", required_argument, &flag, 69},
{"tls-ctx-per-worker", no_argument, &flag, 70}, {"tls-ctx-per-worker", no_argument, &flag, 70},
{"backend-response-buffer", required_argument, &flag, 71},
{nullptr, 0, nullptr, 0}}; {nullptr, 0, nullptr, 0}};
int option_index = 0; int option_index = 0;
@ -1594,6 +1601,10 @@ int main(int argc, char **argv) {
// --tls-ctx-per-worker // --tls-ctx-per-worker
cmdcfgs.emplace_back(SHRPX_OPT_TLS_CTX_PER_WORKER, "yes"); cmdcfgs.emplace_back(SHRPX_OPT_TLS_CTX_PER_WORKER, "yes");
break; break;
case 71:
// --backend-response-buffer
cmdcfgs.emplace_back(SHRPX_OPT_BACKEND_RESPONSE_BUFFER, optarg);
break;
default: default:
break; break;
} }

View File

@ -141,6 +141,7 @@ const char SHRPX_OPT_LISTENER_DISABLE_TIMEOUT[] = "listener-disable-timeout";
const char SHRPX_OPT_TLS_TICKET_KEY_FILE[] = "tls-ticket-key-file"; const char SHRPX_OPT_TLS_TICKET_KEY_FILE[] = "tls-ticket-key-file";
const char SHRPX_OPT_RLIMIT_NOFILE[] = "rlimit-nofile"; const char SHRPX_OPT_RLIMIT_NOFILE[] = "rlimit-nofile";
const char SHRPX_OPT_TLS_CTX_PER_WORKER[] = "tls-ctx-per-worker"; const char SHRPX_OPT_TLS_CTX_PER_WORKER[] = "tls-ctx-per-worker";
const char SHRPX_OPT_BACKEND_RESPONSE_BUFFER[] = "backend-response-buffer";
namespace { namespace {
Config *config = nullptr; Config *config = nullptr;
@ -1130,6 +1131,22 @@ int parse_config(const char *opt, const char *optarg) {
return 0; return 0;
} }
if (util::strieq(opt, SHRPX_OPT_BACKEND_RESPONSE_BUFFER)) {
size_t n;
if (parse_uint_with_unit(&n, opt, optarg) != 0) {
return -1;
}
if (n == 0) {
LOG(ERROR) << opt << ": specify an integer strictly more than 0";
return -1;
}
mod_config()->downstream_response_buffer_size = n;
return 0;
}
if (util::strieq(opt, SHRPX_OPT_TLS_CTX_PER_WORKER)) { if (util::strieq(opt, SHRPX_OPT_TLS_CTX_PER_WORKER)) {
mod_config()->tls_ctx_per_worker = util::strieq(optarg, "yes"); mod_config()->tls_ctx_per_worker = util::strieq(optarg, "yes");

View File

@ -129,6 +129,7 @@ extern const char SHRPX_OPT_LISTENER_DISABLE_TIMEOUT[];
extern const char SHRPX_OPT_TLS_TICKET_KEY_FILE[]; extern const char SHRPX_OPT_TLS_TICKET_KEY_FILE[];
extern const char SHRPX_OPT_RLIMIT_NOFILE[]; extern const char SHRPX_OPT_RLIMIT_NOFILE[];
extern const char SHRPX_OPT_TLS_CTX_PER_WORKER[]; extern const char SHRPX_OPT_TLS_CTX_PER_WORKER[];
extern const char SHRPX_OPT_BACKEND_RESPONSE_BUFFER[];
union sockaddr_union { union sockaddr_union {
sockaddr sa; sockaddr sa;
@ -256,6 +257,7 @@ struct Config {
size_t padding; size_t padding;
size_t worker_frontend_connections; size_t worker_frontend_connections;
size_t rlimit_nofile; size_t rlimit_nofile;
size_t downstream_response_buffer_size;
// Bit mask to disable SSL/TLS protocol versions. This will be // Bit mask to disable SSL/TLS protocol versions. This will be
// passed to SSL_CTX_set_options(). // passed to SSL_CTX_set_options().
long int tls_proto_mask; long int tls_proto_mask;

View File

@ -642,7 +642,8 @@ Memchunks4K *Downstream::get_response_buf() { return &response_buf_; }
bool Downstream::response_buf_full() { bool Downstream::response_buf_full() {
if (dconn_) { if (dconn_) {
return response_buf_.rleft() >= 64 * 1024; return response_buf_.rleft() >=
get_config()->downstream_response_buffer_size;
} else { } else {
return false; return false;
} }