HTTP load balancing algorithm

Ezra Zygmuntowicz ezmobius at gmail.com
Tue Jan 23 00:20:16 MSK 2007


On Jan 22, 2007, at 1:12 PM, Igor Sysoev wrote:

> On Mon, 22 Jan 2007, Ezra Zygmuntowicz wrote:
>
>>
>> On Jan 22, 2007, at 12:43 PM, Jonathan Vanasco wrote:
>>
>>> On Jan 22, 2007, at 3:28 PM, Igor Sysoev wrote:
>>>> I do not know ROR and Mongrel, but as I understand you may try
>>>> to route slow requests to the dedicated backends:
>>> that's what I thought of too, and you can do that with any proxy  
>>> ( though i prefer nginx )
>>> i'd be deathly scared of running a loadbalancer that  
>>> automagically handled slow/fast requests the way you expect.  the  
>>> configuration would be a nightmare, and it would be doing so much  
>>> logging and profiling of request timings, it might negate the  
>>> purpose of a load balancer to begin with.
>> 	The ideal way that nginx's proxy could work best for rails/ 
>> mongrel backends would be an optional proxy setting for not  
>> sending a request to a backend until said backend returns from a  
>> request.
>>
>> 	Rails is not thread safe and so there is a mutex lock around each  
>> rails request. It would be better for nginx to queue these up  
>> instead of mongrel's queuing these up. Each mongrel can only serve  
>> *one* rails request at a time. So if a slow action happens then  
>> nginx will continue to send requests to that mongrel where they  
>> will stack up and each have to wait for the one before it to finish.
>>
>> 	If nginx was able to send a request to a backend, and then not  
>> send another request to that same backend until it returns the  
>> request it's working on. This would make the requests queue in  
>> nginx and be sent to the first backend that returns from a request.
>>
>> 	If support was added to the proxy module to only send one request  
>> to each backend at a time then it would significantly increase the  
>> performance of rails applications running on mongrels behind  
>> nginx. I know that Haproxy has this feature but I don't know of  
>> any of the webserver/proxy balancers currently used with rails  
>> that has this. This feature would give a substantial edge to nginx  
>> in the rails application world.
>>
>
> I plan to add someting like this:
>
>     upstream name {
>         server   host:9000  max_conn=5  max_wait=100  wait_time=60s;
>     }

	This would be perfect.



>
>> 	Also Igor,  what is the algorithm that nginx uses for proxy  
>> module? Is it a round robin or something else?
>
> Yes, currently it's round-robin only.

	Ok thanks Igor.

-- Ezra Zygmuntowicz 
-- Lead Rails Evangelist
-- ez at engineyard.com
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)







More information about the nginx mailing list