Commit 5579def9 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Introduce three new params, to limit overflow queue length

and to force HTTP/1.1 protocol version.




git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1078 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 6c895b5d
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "heritage.h"
#include "shmlog.h" #include "shmlog.h"
#include "cache.h" #include "cache.h"
...@@ -664,6 +665,9 @@ http_CopyReq(struct worker *w, int fd, struct http *to, struct http *fm) ...@@ -664,6 +665,9 @@ http_CopyReq(struct worker *w, int fd, struct http *to, struct http *fm)
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
http_copyh(w, fd, to, fm, HTTP_HDR_REQ, HTTP_T_Request); http_copyh(w, fd, to, fm, HTTP_HDR_REQ, HTTP_T_Request);
http_copyh(w, fd, to, fm, HTTP_HDR_URL, HTTP_T_URL); http_copyh(w, fd, to, fm, HTTP_HDR_URL, HTTP_T_URL);
if (params->backend_http11)
http_seth(w, fd, to, HTTP_HDR_PROTO, HTTP_T_Protocol, "HTTP/1.1");
else
http_copyh(w, fd, to, fm, HTTP_HDR_PROTO, HTTP_T_Protocol); http_copyh(w, fd, to, fm, HTTP_HDR_PROTO, HTTP_T_Protocol);
} }
...@@ -674,6 +678,9 @@ http_CopyResp(struct worker *w, int fd, struct http *to, struct http *fm) ...@@ -674,6 +678,9 @@ http_CopyResp(struct worker *w, int fd, struct http *to, struct http *fm)
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
if (params->client_http11)
http_seth(w, fd, to, HTTP_HDR_PROTO, HTTP_T_Protocol, "HTTP/1.1");
else
http_copyh(w, fd, to, fm, HTTP_HDR_PROTO, HTTP_T_Protocol); http_copyh(w, fd, to, fm, HTTP_HDR_PROTO, HTTP_T_Protocol);
http_copyh(w, fd, to, fm, HTTP_HDR_STATUS, HTTP_T_Status); http_copyh(w, fd, to, fm, HTTP_HDR_STATUS, HTTP_T_Status);
http_copyh(w, fd, to, fm, HTTP_HDR_RESPONSE, HTTP_T_Response); http_copyh(w, fd, to, fm, HTTP_HDR_RESPONSE, HTTP_T_Response);
......
...@@ -268,6 +268,14 @@ WRK_QueueSession(struct sess *sp) ...@@ -268,6 +268,14 @@ WRK_QueueSession(struct sess *sp)
UNLOCK(&qp->mtx); UNLOCK(&qp->mtx);
LOCK(&tmtx); LOCK(&tmtx);
if ((VSL_stats->n_wrk_overflow >
(params->wthread_max * params->overflow_max) / 100)) {
VSL_stats->n_wrk_drop++;
UNLOCK(&tmtx);
vca_close_session(sp, "dropped");
vca_return_session(sp);
return;
}
/* /*
* XXX: If there are too many requests in the overflow queue * XXX: If there are too many requests in the overflow queue
* XXX: we should kill the request right here. * XXX: we should kill the request right here.
......
...@@ -38,6 +38,8 @@ struct params { ...@@ -38,6 +38,8 @@ struct params {
unsigned wthread_timeout; unsigned wthread_timeout;
unsigned wthread_pools; unsigned wthread_pools;
unsigned overflow_max;
/* Memory allocation hints */ /* Memory allocation hints */
unsigned mem_workspace; unsigned mem_workspace;
...@@ -69,6 +71,10 @@ struct params { ...@@ -69,6 +71,10 @@ struct params {
/* Srcaddr hash */ /* Srcaddr hash */
unsigned srcaddr_hash; unsigned srcaddr_hash;
unsigned srcaddr_ttl; unsigned srcaddr_ttl;
/* HTTP proto behaviour */
unsigned backend_http11;
unsigned client_http11;
}; };
extern struct params *params; extern struct params *params;
......
...@@ -160,6 +160,16 @@ tweak_thread_pool_timeout(struct cli *cli, struct parspec *par, const char *arg) ...@@ -160,6 +160,16 @@ tweak_thread_pool_timeout(struct cli *cli, struct parspec *par, const char *arg)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void
tweak_overflow_max(struct cli *cli, struct parspec *par, const char *arg)
{
(void)par;
tweak_generic_uint(cli, &params->overflow_max, arg, 0, UINT_MAX);
}
/*--------------------------------------------------------------------*/
static void static void
tweak_http_workspace(struct cli *cli, struct parspec *par, const char *arg) tweak_http_workspace(struct cli *cli, struct parspec *par, const char *arg)
{ {
...@@ -299,6 +309,24 @@ tweak_srcaddr_ttl(struct cli *cli, struct parspec *par, const char *arg) ...@@ -299,6 +309,24 @@ tweak_srcaddr_ttl(struct cli *cli, struct parspec *par, const char *arg)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void
tweak_backend_http11(struct cli *cli, struct parspec *par, const char *arg)
{
(void)par;
tweak_generic_bool(cli, &params->backend_http11, arg);
}
/*--------------------------------------------------------------------*/
static void
tweak_client_http11(struct cli *cli, struct parspec *par, const char *arg)
{
(void)par;
tweak_generic_bool(cli, &params->client_http11, arg);
}
/*--------------------------------------------------------------------*/
/* /*
* Make sure to end all lines with either a space or newline of the * Make sure to end all lines with either a space or newline of the
* formatting will go haywire. * formatting will go haywire.
...@@ -355,6 +383,11 @@ static struct parspec parspec[] = { ...@@ -355,6 +383,11 @@ static struct parspec parspec[] = {
EXPERIMENTAL EXPERIMENTAL
DELAYED_EFFECT, DELAYED_EFFECT,
"120", "seconds" }, "120", "seconds" },
{ "overflow_max", tweak_overflow_max,
"Limit on overflow queue length in percent of "
"thread_pool_max parameter.\n"
EXPERIMENTAL,
"100", "%" },
{ "http_workspace", tweak_http_workspace, { "http_workspace", tweak_http_workspace,
"Bytes of HTTP protocol workspace allocated. " "Bytes of HTTP protocol workspace allocated. "
"This space must be big enough for the entire HTTP protocol " "This space must be big enough for the entire HTTP protocol "
...@@ -439,6 +472,18 @@ static struct parspec parspec[] = { ...@@ -439,6 +472,18 @@ static struct parspec parspec[] = {
"Zero will disable srcaddr accounting entirely.\n" "Zero will disable srcaddr accounting entirely.\n"
EXPERIMENTAL, EXPERIMENTAL,
"30", "seconds" }, "30", "seconds" },
{ "backend_http11", tweak_backend_http11,
"Force all backend requests to be HTTP/1.1.\n"
"By default we copy the protocol version from the "
"incoming client request."
EXPERIMENTAL,
"off", "bool" },
{ "client_http11", tweak_client_http11,
"Force all client responses to be HTTP/1.1.\n"
"By default we copy the protocol version from the "
"backend response."
EXPERIMENTAL,
"off", "bool" },
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };
......
...@@ -27,6 +27,7 @@ MAC_STAT(n_wrk_failed, uint64_t, "u", "N worker threads not created") ...@@ -27,6 +27,7 @@ MAC_STAT(n_wrk_failed, uint64_t, "u", "N worker threads not created")
MAC_STAT(n_wrk_max, uint64_t, "u", "N worker threads limited") MAC_STAT(n_wrk_max, uint64_t, "u", "N worker threads limited")
MAC_STAT(n_wrk_queue, uint64_t, "u", "N queued work requests") MAC_STAT(n_wrk_queue, uint64_t, "u", "N queued work requests")
MAC_STAT(n_wrk_overflow, uint64_t, "u", "N overflowed work requests") MAC_STAT(n_wrk_overflow, uint64_t, "u", "N overflowed work requests")
MAC_STAT(n_wrk_drop, uint64_t, "u", "N dropped work requests")
MAC_STAT(n_expired, uint64_t, "u", "N expired objects") MAC_STAT(n_expired, uint64_t, "u", "N expired objects")
MAC_STAT(n_deathrow, uint64_t, "u", "N objects on deathrow") MAC_STAT(n_deathrow, uint64_t, "u", "N objects on deathrow")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment