Klaus Demo nginx / d817cea
Upstream keepalive: keepalive_requests directive. The directive configures maximum number of requests allowed on a connection kept in the cache. Once a connection reaches the number of requests configured, it is no longer saved to the cache. The default is 100. Much like keepalive_requests for client connections, this is mostly a safeguard to make sure connections are closed periodically and the memory allocated from the connection pool is freed. Maxim Dounin 3 years ago
2 changed file(s) with 16 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1111
1212 typedef struct {
1313 ngx_uint_t max_cached;
14 ngx_uint_t requests;
1415 ngx_msec_t timeout;
1516
1617 ngx_queue_t cache;
8990 ngx_conf_set_msec_slot,
9091 NGX_HTTP_SRV_CONF_OFFSET,
9192 offsetof(ngx_http_upstream_keepalive_srv_conf_t, timeout),
93 NULL },
94
95 { ngx_string("keepalive_requests"),
96 NGX_HTTP_UPS_CONF|NGX_CONF_TAKE1,
97 ngx_conf_set_num_slot,
98 NGX_HTTP_SRV_CONF_OFFSET,
99 offsetof(ngx_http_upstream_keepalive_srv_conf_t, requests),
92100 NULL },
93101
94102 ngx_null_command
141149 ngx_http_upstream_keepalive_module);
142150
143151 ngx_conf_init_msec_value(kcf->timeout, 60000);
152 ngx_conf_init_uint_value(kcf->requests, 100);
144153
145154 if (kcf->original_init_upstream(cf, us) != NGX_OK) {
146155 return NGX_ERROR;
311320 goto invalid;
312321 }
313322
323 if (c->requests >= kp->conf->requests) {
324 goto invalid;
325 }
326
314327 if (!u->keepalive) {
315328 goto invalid;
316329 }
499512 */
500513
501514 conf->timeout = NGX_CONF_UNSET_MSEC;
515 conf->requests = NGX_CONF_UNSET_UINT;
502516
503517 return conf;
504518 }
15451545
15461546 c = u->peer.connection;
15471547
1548 c->requests++;
1549
15481550 c->data = r;
15491551
15501552 c->write->handler = ngx_http_upstream_handler;