nghttpx: Add --backend-request-buffer option

This commit is contained in:
Tatsuhiro Tsujikawa 2015-01-13 23:30:28 +09:00
parent d6db38a318
commit f004361ef2
4 changed files with 22 additions and 3 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_request_buffer_size = 16 * 1024;
mod_config()->downstream_response_buffer_size = 64 * 1024; mod_config()->downstream_response_buffer_size = 64 * 1024;
} }
} // namespace } // namespace
@ -878,6 +879,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-request-buffer=<SIZE>
Set buffer size used to store backend request.
Default: )"
<< util::utos_with_unit(get_config()->downstream_request_buffer_size)
<< R"(
--backend-response-buffer=<SIZE> --backend-response-buffer=<SIZE>
Set buffer size used to store backend response. Set buffer size used to store backend response.
Default: )" Default: )"
@ -1280,6 +1286,7 @@ int main(int argc, char **argv) {
{"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}, {"backend-response-buffer", required_argument, &flag, 71},
{"backend-request-buffer", required_argument, &flag, 72},
{nullptr, 0, nullptr, 0}}; {nullptr, 0, nullptr, 0}};
int option_index = 0; int option_index = 0;
@ -1605,6 +1612,10 @@ int main(int argc, char **argv) {
// --backend-response-buffer // --backend-response-buffer
cmdcfgs.emplace_back(SHRPX_OPT_BACKEND_RESPONSE_BUFFER, optarg); cmdcfgs.emplace_back(SHRPX_OPT_BACKEND_RESPONSE_BUFFER, optarg);
break; break;
case 72:
// --backend-request-buffer
cmdcfgs.emplace_back(SHRPX_OPT_BACKEND_REQUEST_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_REQUEST_BUFFER[] = "backend-request-buffer";
const char SHRPX_OPT_BACKEND_RESPONSE_BUFFER[] = "backend-response-buffer"; const char SHRPX_OPT_BACKEND_RESPONSE_BUFFER[] = "backend-response-buffer";
namespace { namespace {
@ -1118,7 +1119,8 @@ int parse_config(const char *opt, const char *optarg) {
return 0; return 0;
} }
if (util::strieq(opt, SHRPX_OPT_BACKEND_RESPONSE_BUFFER)) { if (util::strieq(opt, SHRPX_OPT_BACKEND_REQUEST_BUFFER) ||
util::strieq(opt, SHRPX_OPT_BACKEND_RESPONSE_BUFFER)) {
size_t n; size_t n;
if (parse_uint_with_unit(&n, opt, optarg) != 0) { if (parse_uint_with_unit(&n, opt, optarg) != 0) {
return -1; return -1;
@ -1130,7 +1132,11 @@ int parse_config(const char *opt, const char *optarg) {
return -1; return -1;
} }
if (util::strieq(opt, SHRPX_OPT_BACKEND_REQUEST_BUFFER)) {
mod_config()->downstream_request_buffer_size = n;
} else {
mod_config()->downstream_response_buffer_size = n; mod_config()->downstream_response_buffer_size = n;
}
return 0; return 0;
} }

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_REQUEST_BUFFER[];
extern const char SHRPX_OPT_BACKEND_RESPONSE_BUFFER[]; extern const char SHRPX_OPT_BACKEND_RESPONSE_BUFFER[];
union sockaddr_union { union sockaddr_union {
@ -257,6 +258,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_request_buffer_size;
size_t downstream_response_buffer_size; 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().

View File

@ -443,7 +443,7 @@ void Downstream::set_request_http2_expect_body(bool f) {
bool Downstream::request_buf_full() { bool Downstream::request_buf_full() {
if (dconn_) { if (dconn_) {
return request_buf_.rleft() >= 16384; return request_buf_.rleft() >= get_config()->downstream_request_buffer_size;
} else { } else {
return false; return false;
} }