Mercurial > hg > nginx
changeset 7697:b9071b875194
Core: added a warning about reusing connections.
Previously, reusing connections happened silently and was only
visible in monitoring systems. This was shown to be not very user-friendly,
and administrators often didn't realize there were too few connections
available to withstand the load, and configured timeouts (keepalive_timeout
and http2_idle_timeout) were effectively reduced to keep things running.
To provide at least some information about this, a warning is now logged
(at most once per second, to avoid flooding the logs).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 10 Aug 2020 18:52:59 +0300 |
parents | 45764bca69b0 |
children | 5440ff4ac6fc |
files | src/core/ngx_connection.c src/core/ngx_cycle.h |
diffstat | 2 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/ngx_connection.c Mon Aug 10 18:52:34 2020 +0300 +++ b/src/core/ngx_connection.c Mon Aug 10 18:52:59 2020 +0300 @@ -1298,6 +1298,19 @@ ngx_queue_t *q; ngx_connection_t *c; + if (cycle->reusable_connections_n == 0) { + return; + } + + if (cycle->connections_reuse_time != ngx_time()) { + cycle->connections_reuse_time = ngx_time(); + + ngx_log_error(NGX_LOG_WARN, cycle->log, 0, + "%ui worker_connections are not enough, " + "reusing connections", + cycle->connection_n); + } + n = ngx_max(ngx_min(32, cycle->reusable_connections_n / 8), 1); for (i = 0; i < n; i++) {