<?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: Thin, Mongrel, Rack and performance</title>
	<atom:link href="http://nutrun.com/weblog/thin-mongrel-rack-and-performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://nutrun.com/weblog/thin-mongrel-rack-and-performance/</link>
	<description>nutrun</description>
	<pubDate>Sat, 06 Sep 2008 04:23:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: Vidar Hokstad</title>
		<link>http://nutrun.com/weblog/thin-mongrel-rack-and-performance/#comment-386</link>
		<dc:creator>Vidar Hokstad</dc:creator>
		<pubDate>Fri, 04 Apr 2008 18:36:05 +0000</pubDate>
		<guid isPermaLink="false">http://nutrun.com/?p=130#comment-386</guid>
		<description>Very interesting. This is a request for a static file on my blog setup using Rack::Static.

ab -k -n5000 http://www.hokstad.com:3000/static/style.css (I put it up on that port only for testing - it's likely to be down when you see this)
Thin: 756.41 req/s
Mongrel: 104.60 req/s

ab -n5000 http://www.hokstad.com:3000/static/style.css (no keepalive):
Thin: 747 req/s
Mongrel: 211.89 req/s

With the test script above:
Thin: 138.94 req/s
Mongrel: 94.81 req/s

I first thought the -k option to "ab" caused part of the huge speedup, so that's why I tried without it. So clearly part of it is related either to how Net::HTTP send the request or (I guess more likely) overall Net::HTTP performance. As for why Mongrel does twice as good with keepalive turned off, I have no good explanation - I reran those tests several times because I suspected I'd made a mistake.

Overall I'm thoroughly stumped, and I definitively will spend some more time looking at this... 

The relevant parts of my config.ru file looks like this, btw. (the custom Rack middleware involved can be found here: http://www.hokstad.com/tag/rack )

use LatestReferers::Gather, {:exclude =&#62; [ /\/referers/, /http:\/\/www\.hokstad\.com/ ]}
use LatestReferers::View, "/referers"
use Rack::ShowStatus
use RewriteContentType, {"js" =&#62; "text/javascript"}
use CacheSettings, {
  /\/static\// =&#62; { :cache_control =&#62; "max-age=86400,public", :expires =&#62; 86400 },
  /\\.html/ =&#62; { :cache_control =&#62; "max-age=86400,public", :expires =&#62; 86400 }
}

use Rack::Static, :urls =&#62; ["/static"]</description>
		<content:encoded><![CDATA[<p>Very interesting. This is a request for a static file on my blog setup using Rack::Static.</p>
<p>ab -k -n5000 <a href="http://www.hokstad.com:3000/static/style.css" rel="nofollow">http://www.hokstad.com:3000/static/style.css</a> (I put it up on that port only for testing - it&#8217;s likely to be down when you see this)<br />
Thin: 756.41 req/s<br />
Mongrel: 104.60 req/s</p>
<p>ab -n5000 <a href="http://www.hokstad.com:3000/static/style.css" rel="nofollow">http://www.hokstad.com:3000/static/style.css</a> (no keepalive):<br />
Thin: 747 req/s<br />
Mongrel: 211.89 req/s</p>
<p>With the test script above:<br />
Thin: 138.94 req/s<br />
Mongrel: 94.81 req/s</p>
<p>I first thought the -k option to &#8220;ab&#8221; caused part of the huge speedup, so that&#8217;s why I tried without it. So clearly part of it is related either to how Net::HTTP send the request or (I guess more likely) overall Net::HTTP performance. As for why Mongrel does twice as good with keepalive turned off, I have no good explanation - I reran those tests several times because I suspected I&#8217;d made a mistake.</p>
<p>Overall I&#8217;m thoroughly stumped, and I definitively will spend some more time looking at this&#8230; </p>
<p>The relevant parts of my config.ru file looks like this, btw. (the custom Rack middleware involved can be found here: <a href="http://www.hokstad.com/tag/rack" rel="nofollow">http://www.hokstad.com/tag/rack</a> )</p>
<p>use LatestReferers::Gather, {:exclude =&gt; [ /\/referers/, /http:\/\/www\.hokstad\.com/ ]}<br />
use LatestReferers::View, &#8220;/referers&#8221;<br />
use Rack::ShowStatus<br />
use RewriteContentType, {&#8221;js&#8221; =&gt; &#8220;text/javascript&#8221;}<br />
use CacheSettings, {<br />
  /\/static\// =&gt; { :cache_control =&gt; &#8220;max-age=86400,public&#8221;, :expires =&gt; 86400 },<br />
  /\\.html/ =&gt; { :cache_control =&gt; &#8220;max-age=86400,public&#8221;, :expires =&gt; 86400 }<br />
}</p>
<p>use Rack::Static, :urls =&gt; ["/static"]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George Malamidis</title>
		<link>http://nutrun.com/weblog/thin-mongrel-rack-and-performance/#comment-385</link>
		<dc:creator>George Malamidis</dc:creator>
		<pubDate>Fri, 04 Apr 2008 17:11:48 +0000</pubDate>
		<guid isPermaLink="false">http://nutrun.com/?p=130#comment-385</guid>
		<description>Hey Marc,

In terms of the client closing the connection, replacing "Net::HTTP.new('127.0.0.1', 2323).request_get('/')" with "Net::HTTP.new('127.0.0.1', 2323).start {&#124;http&#124; http.request_get('/')}" should ensure the connection is closed for each request, right? I tried this, but the results didn't change...

I totally agree with the ab/httperf suggestion, hence the "crud and unscientific" description of the example. Thanks for the cool server, by the way. It's a viable contender.</description>
		<content:encoded><![CDATA[<p>Hey Marc,</p>
<p>In terms of the client closing the connection, replacing &#8220;Net::HTTP.new(&#8217;127.0.0.1&#8242;, 2323).request_get(&#8217;/')&#8221; with &#8220;Net::HTTP.new(&#8217;127.0.0.1&#8242;, 2323).start {|http| http.request_get(&#8217;/')}&#8221; should ensure the connection is closed for each request, right? I tried this, but the results didn&#8217;t change&#8230;</p>
<p>I totally agree with the ab/httperf suggestion, hence the &#8220;crud and unscientific&#8221; description of the example. Thanks for the cool server, by the way. It&#8217;s a viable contender.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: macournoyer</title>
		<link>http://nutrun.com/weblog/thin-mongrel-rack-and-performance/#comment-384</link>
		<dc:creator>macournoyer</dc:creator>
		<pubDate>Fri, 04 Apr 2008 14:03:53 +0000</pubDate>
		<guid isPermaLink="false">http://nutrun.com/?p=130#comment-384</guid>
		<description>Your HTTP client doesn't close the connection and Thin supports keep-alive, which is on by default in HTTP 1.1, that might explain the slowdown.

I'd suggest running it w/ some real benchmarking tools like ab or httperf. Try running: ab -k -n5000 127.0.0.1:2323/

Thin is not all about speed but is should be faster then mongrel when concurrency in the application is not needed (like in rails), it should use less memory then mongrel and all other Ruby servers and support a lot more concurrent connections. Check out the tuning options: run thin -h

Let me know if you have any problem w/ thin, I'd be glad to help!</description>
		<content:encoded><![CDATA[<p>Your HTTP client doesn&#8217;t close the connection and Thin supports keep-alive, which is on by default in HTTP 1.1, that might explain the slowdown.</p>
<p>I&#8217;d suggest running it w/ some real benchmarking tools like ab or httperf. Try running: ab -k -n5000 127.0.0.1:2323/</p>
<p>Thin is not all about speed but is should be faster then mongrel when concurrency in the application is not needed (like in rails), it should use less memory then mongrel and all other Ruby servers and support a lot more concurrent connections. Check out the tuning options: run thin -h</p>
<p>Let me know if you have any problem w/ thin, I&#8217;d be glad to help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George Malamidis</title>
		<link>http://nutrun.com/weblog/thin-mongrel-rack-and-performance/#comment-383</link>
		<dc:creator>George Malamidis</dc:creator>
		<pubDate>Fri, 04 Apr 2008 10:03:22 +0000</pubDate>
		<guid isPermaLink="false">http://nutrun.com/?p=130#comment-383</guid>
		<description>Vidar,

I'm a fan of the big-framework-less approach, too and would be interested to hear the results if you go ahead with the benchmark you mention.</description>
		<content:encoded><![CDATA[<p>Vidar,</p>
<p>I&#8217;m a fan of the big-framework-less approach, too and would be interested to hear the results if you go ahead with the benchmark you mention.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vidar</title>
		<link>http://nutrun.com/weblog/thin-mongrel-rack-and-performance/#comment-382</link>
		<dc:creator>Vidar</dc:creator>
		<pubDate>Fri, 04 Apr 2008 09:32:59 +0000</pubDate>
		<guid isPermaLink="false">http://nutrun.com/?p=130#comment-382</guid>
		<description>I'm pretty surprised by the results, but I got similar ones, updated my Thin gem to the most recent version and stlll saw the same.

I'm not so surprised that Rack::Lint slows things down a lot in this test - for something as simple as your test Rack::Lint is going to add a huge amount of overhead with the tests it does, and when it's a single connection that will translate very directly to reduced requests.

I had a brief look at the strace output for both cases this morning, and nothing immediately stood out (other than the normal horrendous effects of Ruby's green threads). I'd be interested in seeing what it'd do on a real app and multiple connectons, though - I'll try hitting both of them with "ab" or something against my blog dev setup (it's running purely on Rack, with several layers of Rack middleware) later today.</description>
		<content:encoded><![CDATA[<p>I&#8217;m pretty surprised by the results, but I got similar ones, updated my Thin gem to the most recent version and stlll saw the same.</p>
<p>I&#8217;m not so surprised that Rack::Lint slows things down a lot in this test - for something as simple as your test Rack::Lint is going to add a huge amount of overhead with the tests it does, and when it&#8217;s a single connection that will translate very directly to reduced requests.</p>
<p>I had a brief look at the strace output for both cases this morning, and nothing immediately stood out (other than the normal horrendous effects of Ruby&#8217;s green threads). I&#8217;d be interested in seeing what it&#8217;d do on a real app and multiple connectons, though - I&#8217;ll try hitting both of them with &#8220;ab&#8221; or something against my blog dev setup (it&#8217;s running purely on Rack, with several layers of Rack middleware) later today.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
