title: ruby net/http opening connection very slow
body: <p>When I'm working with <code>net/http</code> in development it is extremely slow. I've installed <code>net-http-spy</code> gem to get some info about each request and I've found out that "opening connection" part takes the most time (more than 10 seconds). Further more, it doesn't keep connections alive, so it needs to reopen it on every request.</p>
  
  <pre><code>opening connection to maps.google.com...
  # ~10 seconds
  opened
  </code></pre>
  
  <p>Is there any way I could somehow improve the performance of <code>net/http</code> library by settings some of its defaults? I don't want a request specific fix, but something that would fix the issue globally. I'm using <code>geokit</code> gem in curent project and I cannot change the way it handles request internally, other than knowing it is using <code>net/http</code>, and it is working great on production (Heroku) but extremely slow in development.</p>
  
  <p>I'm using ruby 1.9.2-p290 on Mac OS X Lion. Ruby is installed and managed with rbenv.</p>
  
  <hr>
  
  <p>Here is the sample code:</p>
  
  <pre><code>require 'net/http'
  require 'uri'
  
  time = Time.now.to_i
  uri = URI.parse("http://maps.google.com/maps/geo?q=Chicago&amp;output=xml&amp;oe=utf-8")
  
  Net::HTTP.get(uri)
  puts (Time.now.to_i - time)
  
  Net::HTTP.get(uri)
  puts (Time.now.to_i - time)
  </code></pre>
  
  <p>It doesn't really matter what URL I put in there. It always take exactly 10 seconds for each request..</p>