<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: mod_proxy_balancer Is A Two Timing Hussy</title>
	<atom:link href="http://pezra.barelyenough.org/blog/2008/04/mod_proxy_balancer-is-a-two-timing-hussy/feed/" rel="self" type="application/rss+xml" />
	<link>http://pezra.barelyenough.org/blog/2008/04/mod_proxy_balancer-is-a-two-timing-hussy/</link>
	<description></description>
	<pubDate>Thu, 07 Aug 2008 20:07:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Peter Williams</title>
		<link>http://pezra.barelyenough.org/blog/2008/04/mod_proxy_balancer-is-a-two-timing-hussy/#comment-55977</link>
		<dc:creator>Peter Williams</dc:creator>
		<pubDate>Mon, 23 Jun 2008 05:12:50 +0000</pubDate>
		<guid isPermaLink="false">http://pezra.barelyenough.org/blog/?p=328#comment-55977</guid>
		<description>&lt;p&gt;Ben,&lt;/p&gt;

&lt;p&gt;Acquire does seem rather drastic, but I can see how it might result in the desired behavior.&lt;/p&gt;

&lt;p&gt;As for mod_proxy's documentation, it is not as clear as I like but I would not describe the verbage around max as unclear.  Specifically, it says, "Apache will never create more than the Hard Maximum connections to the backend server."  That could easily be wrong but is hardly unclear.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Ben,</p>
<p>Acquire does seem rather drastic, but I can see how it might result in the desired behavior.</p>
<p>As for mod_proxy&#8217;s documentation, it is not as clear as I like but I would not describe the verbage around max as unclear.  Specifically, it says, &#8220;Apache will never create more than the Hard Maximum connections to the backend server.&#8221;  That could easily be wrong but is hardly unclear.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://pezra.barelyenough.org/blog/2008/04/mod_proxy_balancer-is-a-two-timing-hussy/#comment-55976</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Mon, 23 Jun 2008 04:40:51 +0000</pubDate>
		<guid isPermaLink="false">http://pezra.barelyenough.org/blog/?p=328#comment-55976</guid>
		<description>&lt;p&gt;Hi Peter,&lt;/p&gt;

&lt;p&gt;I fought with this a few months ago, and I concluded that... this "max" parameter.... how do you say...  "I do not think it means what you think it means." :)&lt;/p&gt;

&lt;p&gt;The mod_proxy documentation could certainly be clearer, but my reading is that the setting is always per Apache child process.  So, in a typical prefork setup with, oh I don't know, 10 or 15 apache processes, you really end up with a max of 10 or 15 connections per Mongrel.  (And when you get busy and Apache spins up more children, you get even more connections per Mongrel.)  Basically you still end up with the "dumb" round-robin allocation.  Not what you or I intended.&lt;/p&gt;

&lt;p&gt;With the worker MPM, you can lock down ServerLimit so that everything is in lots of threads within one process, but that seems risky and probably not great at high load.  But with worker, you at least have some control.&lt;/p&gt;

&lt;p&gt;Here's a mailing list post touching on this:
http://marc.info/?l=apache-httpd-dev&#38;m=112552197217868&lt;/p&gt;

&lt;p&gt;However, refusing to believe that Apache is completely incapable of being a proper Rails frontend (as you said, nothing "fancy" is needed, just a dispatcher that finds or waits for an idle backend), I persisted in my googling.&lt;/p&gt;

&lt;p&gt;I ended up finding a reference to the "acquire" parameter... probably this message: http://rubyforge.org/pipermail/mongrel-users/2007-October/004146.html&lt;/p&gt;

&lt;p&gt;The Apache docs for "acquire" (a parameter to ProxyPass, like "max") make it sound pretty drastic.  True, if all backends are busy for the duration of the acquire timeout, it'll return a 503 Server Busy, but if any backends are idle it appears to make Apache hunt for one (after the timeout) instead of just picking a possibly busy one and waiting.&lt;/p&gt;

&lt;p&gt;For us, "acquire=1" has worked out pretty well.  We also have "max=1" but because of the above I don't think it's actually doing anything.  Just make sure you have enough Mongrels.  (Easy to say of course. :))&lt;/p&gt;

&lt;p&gt;HAproxy is still probably a better bet.  Rather pathetic that Apache is too "dumb/smart" to front for Mongrel/Rails isn't it?  Maybe someday someone will hack on Apache to make it behave properly in front of Rails.  Or maybe we'll all end up using mod_rails or whatever they're calling it these days. :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Peter,</p>
<p>I fought with this a few months ago, and I concluded that&#8230; this &#8220;max&#8221; parameter&#8230;. how do you say&#8230;  &#8220;I do not think it means what you think it means.&#8221; :)</p>
<p>The mod_proxy documentation could certainly be clearer, but my reading is that the setting is always per Apache child process.  So, in a typical prefork setup with, oh I don&#8217;t know, 10 or 15 apache processes, you really end up with a max of 10 or 15 connections per Mongrel.  (And when you get busy and Apache spins up more children, you get even more connections per Mongrel.)  Basically you still end up with the &#8220;dumb&#8221; round-robin allocation.  Not what you or I intended.</p>
<p>With the worker MPM, you can lock down ServerLimit so that everything is in lots of threads within one process, but that seems risky and probably not great at high load.  But with worker, you at least have some control.</p>
<p>Here&#8217;s a mailing list post touching on this:<br />
<a href="http://marc.info/?l=apache-httpd-dev&amp;m=112552197217868" rel="nofollow">http://marc.info/?l=apache-httpd-dev&amp;m=112552197217868</a></p>
<p>However, refusing to believe that Apache is completely incapable of being a proper Rails frontend (as you said, nothing &#8220;fancy&#8221; is needed, just a dispatcher that finds or waits for an idle backend), I persisted in my googling.</p>
<p>I ended up finding a reference to the &#8220;acquire&#8221; parameter&#8230; probably this message: <a href="http://rubyforge.org/pipermail/mongrel-users/2007-October/004146.html" rel="nofollow">http://rubyforge.org/pipermail/mongrel-users/2007-October/004146.html</a></p>
<p>The Apache docs for &#8220;acquire&#8221; (a parameter to ProxyPass, like &#8220;max&#8221;) make it sound pretty drastic.  True, if all backends are busy for the duration of the acquire timeout, it&#8217;ll return a 503 Server Busy, but if any backends are idle it appears to make Apache hunt for one (after the timeout) instead of just picking a possibly busy one and waiting.</p>
<p>For us, &#8220;acquire=1&#8243; has worked out pretty well.  We also have &#8220;max=1&#8243; but because of the above I don&#8217;t think it&#8217;s actually doing anything.  Just make sure you have enough Mongrels.  (Easy to say of course. :))</p>
<p>HAproxy is still probably a better bet.  Rather pathetic that Apache is too &#8220;dumb/smart&#8221; to front for Mongrel/Rails isn&#8217;t it?  Maybe someday someone will hack on Apache to make it behave properly in front of Rails.  Or maybe we&#8217;ll all end up using mod_rails or whatever they&#8217;re calling it these days. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Casey</title>
		<link>http://pezra.barelyenough.org/blog/2008/04/mod_proxy_balancer-is-a-two-timing-hussy/#comment-50434</link>
		<dc:creator>Casey</dc:creator>
		<pubDate>Thu, 08 May 2008 18:02:43 +0000</pubDate>
		<guid isPermaLink="false">http://pezra.barelyenough.org/blog/?p=328#comment-50434</guid>
		<description>&lt;p&gt;Peter,
I too have seen this same issue with mod_proxy_balancer and some long running queries.  It happens exactly how you described it too ... connection 1 starts the long running query, conn 2 and 3 finish ... and four is stuck waiting for 1 to finish.  Unfortunately at this point we have just increased the number of mongrels and tuned the long running queries.  It seems to have helped for now - but definitely not an optimal solution.  I would be interested to see how HAProxy worked for you.&lt;/p&gt;

&lt;p&gt;Keep me posted.
Casey&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Peter,<br />
I too have seen this same issue with mod_proxy_balancer and some long running queries.  It happens exactly how you described it too &#8230; connection 1 starts the long running query, conn 2 and 3 finish &#8230; and four is stuck waiting for 1 to finish.  Unfortunately at this point we have just increased the number of mongrels and tuned the long running queries.  It seems to have helped for now - but definitely not an optimal solution.  I would be interested to see how HAProxy worked for you.</p>
<p>Keep me posted.<br />
Casey</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Williams</title>
		<link>http://pezra.barelyenough.org/blog/2008/04/mod_proxy_balancer-is-a-two-timing-hussy/#comment-48563</link>
		<dc:creator>Peter Williams</dc:creator>
		<pubDate>Mon, 28 Apr 2008 17:05:21 +0000</pubDate>
		<guid isPermaLink="false">http://pezra.barelyenough.org/blog/?p=328#comment-48563</guid>
		<description>&lt;p&gt;Glenn,&lt;/p&gt;

&lt;p&gt;That does not appear to be exactly what I want.  I don't want requests dispatched to the least busy backend.  I want them dispatched to a not busy backend.  If there is not an idle backend available, I want them queued until there is one.&lt;/p&gt;

&lt;p&gt;Consider following scenario:&lt;/p&gt;

&lt;pre&gt;
time       1     2     3     4     5
======================================   
backends 
  1        &#124;-----------------&#124; (a)
                     &#124;........-----&#124; (c)
        
  2              &#124;-----&#124; (b)
&lt;/pre&gt;

&lt;p&gt;A fair balancer without a connection limit might (correctly) send request c to backend 1.  This is because all the backends are equally "busy" it is not wrong to send that request to any backend.  However, as human you can see that it ends up have quite suboptimal results in this scenario&lt;/p&gt;

&lt;p&gt;Basically any balancer algorithm with the ability to set a max connections on each backend (that actually worked) would solve my problem.  Once there is a balancer for nginx that has that I am there.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Glenn,</p>
<p>That does not appear to be exactly what I want.  I don&#8217;t want requests dispatched to the least busy backend.  I want them dispatched to a not busy backend.  If there is not an idle backend available, I want them queued until there is one.</p>
<p>Consider following scenario:</p>
<pre>
time       1     2     3     4     5
======================================
backends
  1        |-----------------| (a)
                     |........-----| (c)

  2              |-----| (b)
</pre>
<p>A fair balancer without a connection limit might (correctly) send request c to backend 1.  This is because all the backends are equally &#8220;busy&#8221; it is not wrong to send that request to any backend.  However, as human you can see that it ends up have quite suboptimal results in this scenario</p>
<p>Basically any balancer algorithm with the ability to set a max connections on each backend (that actually worked) would solve my problem.  Once there is a balancer for nginx that has that I am there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Rempe</title>
		<link>http://pezra.barelyenough.org/blog/2008/04/mod_proxy_balancer-is-a-two-timing-hussy/#comment-48562</link>
		<dc:creator>Glenn Rempe</dc:creator>
		<pubDate>Mon, 28 Apr 2008 16:32:29 +0000</pubDate>
		<guid isPermaLink="false">http://pezra.barelyenough.org/blog/?p=328#comment-48562</guid>
		<description>&lt;p&gt;Your solution is likely waiting in Nginx + the Upstream Fair module.&lt;/p&gt;

&lt;p&gt;Nginx is a fantastic (and lightweight) reverse proxy and the Upstream fair load balancer loads your back end processes according to usage.&lt;/p&gt;

&lt;p&gt;The module is here.&lt;/p&gt;

&lt;p&gt;http://github.com/gnosek/nginx-upstream-fair/tree/master&lt;/p&gt;

&lt;p&gt;Glenn&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Your solution is likely waiting in Nginx + the Upstream Fair module.</p>
<p>Nginx is a fantastic (and lightweight) reverse proxy and the Upstream fair load balancer loads your back end processes according to usage.</p>
<p>The module is here.</p>
<p><a href="http://github.com/gnosek/nginx-upstream-fair/tree/master" rel="nofollow">http://github.com/gnosek/nginx-upstream-fair/tree/master</a></p>
<p>Glenn</p>
]]></content:encoded>
	</item>
</channel>
</rss>
