alibaba / tengine

A distribution of Nginx with some advanced features
https://tengine.taobao.org
BSD 2-Clause "Simplified" License
12.81k stars 2.52k forks source link

Max connection limit for upstream #718

Open Dead2 opened 8 years ago

Dead2 commented 8 years ago

nginx has a max_conns parameter for each server in upstream, tengine does not seem to have this feature at all.

We are experiencing a reoccuring deadlock of the upstream server due to all connections being used by processes attempting to connect to itself (mod_pagespeed). The only proper way of avoiding this is to make tengine wait when too many connections are in use. Increasing the connection limit on upstream only makes the problem harder to trigger, but it unfortunately does not resolve the problem.

Ex: 300 connections running on 4 cores is horribly inefficient, having tengine limit the connections to upstream would increase performance due to reduced context-switching and avoid the potential out-of-memory situations that can occur with that many connections.

cfsego commented 8 years ago

I think you can try this module by me: https://github.com/cfsego/nginx-limit-upstream/

however, I don't know whether it works well with you tengine, so tell me when you meet any problem

Dead2 commented 8 years ago

It seems like it needs some modification/updates to work with current tengine.

I also see that you have considered having it merged into tengine, and it seems like a good idea to me since this feature should be very useful. Is there any hope of that happening?