comparison src/http/modules/ngx_http_upstream_least_conn_module.c @ 6705:29bf0dbc0a77

Upstream: max_conns.
author Ruslan Ermilov <ru@nginx.com>
date Thu, 22 Sep 2016 19:32:47 +0300
parents a44ba757851d
children
comparison
equal deleted inserted replaced
6704:a44ba757851d 6705:29bf0dbc0a77
152 && now - peer->checked <= peer->fail_timeout) 152 && now - peer->checked <= peer->fail_timeout)
153 { 153 {
154 continue; 154 continue;
155 } 155 }
156 156
157 if (peer->max_conns && peer->conns >= peer->max_conns) {
158 continue;
159 }
160
157 /* 161 /*
158 * select peer with least number of connections; if there are 162 * select peer with least number of connections; if there are
159 * multiple peers with the same number of connections, select 163 * multiple peers with the same number of connections, select
160 * based on round-robin 164 * based on round-robin
161 */ 165 */
207 && now - peer->checked <= peer->fail_timeout) 211 && now - peer->checked <= peer->fail_timeout)
208 { 212 {
209 continue; 213 continue;
210 } 214 }
211 215
216 if (peer->max_conns && peer->conns >= peer->max_conns) {
217 continue;
218 }
219
212 peer->current_weight += peer->effective_weight; 220 peer->current_weight += peer->effective_weight;
213 total += peer->effective_weight; 221 total += peer->effective_weight;
214 222
215 if (peer->effective_weight < peer->weight) { 223 if (peer->effective_weight < peer->weight) {
216 peer->effective_weight++; 224 peer->effective_weight++;
294 302
295 uscf->peer.init_upstream = ngx_http_upstream_init_least_conn; 303 uscf->peer.init_upstream = ngx_http_upstream_init_least_conn;
296 304
297 uscf->flags = NGX_HTTP_UPSTREAM_CREATE 305 uscf->flags = NGX_HTTP_UPSTREAM_CREATE
298 |NGX_HTTP_UPSTREAM_WEIGHT 306 |NGX_HTTP_UPSTREAM_WEIGHT
307 |NGX_HTTP_UPSTREAM_MAX_CONNS
299 |NGX_HTTP_UPSTREAM_MAX_FAILS 308 |NGX_HTTP_UPSTREAM_MAX_FAILS
300 |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT 309 |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT
301 |NGX_HTTP_UPSTREAM_DOWN 310 |NGX_HTTP_UPSTREAM_DOWN
302 |NGX_HTTP_UPSTREAM_BACKUP; 311 |NGX_HTTP_UPSTREAM_BACKUP;
303 312