<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>assertTrue: Is RubyGems running really, really slow on OSX? How about 60 second delays for HTTP requests?</title>
    <link>http://www.asserttrue.com/articles/2008/05/04/is-rubygems-running-really-really-slow-on-osx-how-about-60-second-delays-for-http-requests</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>powered by Pattern Park</description>
    <item>
      <title>Is RubyGems running really, really slow on OSX? How about 60 second delays for HTTP requests?</title>
      <description>&lt;p&gt;&lt;strong&gt;Updated on June 23, 2008:&lt;/strong&gt; &lt;em&gt;There was just a release to RubyGems 1.2 yesterday and RubyGems is now blazing fast, no more index updates and who-knows-what-else every time you install a gem.&lt;/em&gt;&lt;/p&gt;


	&lt;p&gt;Ali and I ran into an interesting Ruby bug on &lt;span class="caps"&gt;OSX&lt;/span&gt; Leopard last week and I thought I&amp;#8217;d share the result of our finding&amp;#8230;.&lt;/p&gt;


	&lt;p&gt;Basically, we were requesting a 2k &lt;span class="caps"&gt;RSS&lt;/span&gt; feed from a url that had two sub-domains as in:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;http://sub1.sub2.example.com&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;The request worked fine if we hit the server with only one sub-domain as in:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;http://sub2.example.com&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;In the first example, the request would hang for exactly 60 seconds and then return the result. When we tried with a third sub-domain, we got a 120 second hang and then an error.&lt;/p&gt;


	&lt;p&gt;After digging through the Ruby sources, it looked like the problem was in the TCPSocket C implementation so I threw an &lt;a href="http://www.ruby-forum.com/topic/151729#new"&gt;email&lt;/a&gt; up on the Ruby list.&lt;/p&gt;


	&lt;p&gt;Turns out the fix is that if you&amp;#8217;re trying to use Ruby networking features that sit on top of &lt;span class="caps"&gt;TCP&lt;/span&gt; on &lt;span class="caps"&gt;OS X&lt;/span&gt; Leopard, you &lt;em&gt;may&lt;/em&gt; need to add the following to your code:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;require 'resolv-replace'&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Found the fix in this &lt;a href="http://www.ruby-forum.com/topic/138634"&gt;thread&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;I also added this line to /usr/lib/ruby/1.8/rubygems.rb (around line 11) and RubyGems is suddenly much, much faster.&lt;/p&gt;</description>
      <pubDate>Sun, 04 May 2008 14:36:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:8ff32b8a-5210-4283-9b77-06d7632cc92a</guid>
      <author>Luke Bayes</author>
      <link>http://www.asserttrue.com/articles/2008/05/04/is-rubygems-running-really-really-slow-on-osx-how-about-60-second-delays-for-http-requests</link>
      <category>ruby</category>
      <category>rubygems</category>
      <trackback:ping>http://www.asserttrue.com/articles/trackback/1563</trackback:ping>
    </item>
  </channel>
</rss>
