celluloid / celluloid-io

UNMAINTAINED: See celluloid/celluloid#779 - Evented sockets for Celluloid actors
https://celluloid.io
MIT License
879 stars 93 forks source link

DNS resolution occasionally hangs #113

Open jonhyman opened 9 years ago

jonhyman commented 9 years ago

Hi,

We've been experimenting with using the HTTP gem with Celluloid::IO to make API calls to SendGrid. In testing this out with different pool sizes of HttpFetcher (taken from https://github.com/tarcieri/http/blob/master/examples/parallel_requests_with_celluloid.rb) and making a few hundred requests, getting future.value would hang occasionally, requiring a force kill of the program. We debugged this down to be the DNSResolver hanging, and were able to reproduce it with a simple example. The repro case is very sporadic, though, so it may take a few dozen times to run this code to get it to hang but we've been able to do it with this code.

Using MRI Ruby 2.1.2, Celluloid 0.15.2, Celluloid-IO 0.15.0

class Foo
  include Celluloid::IO
  def test
    Celluloid::IO::DNSResolver.new.resolve("api.sendgrid.com")
  end
end

f = Foo.pool(:size => 400)

futures = []
1000.times do |i|
  futures << f.future.test
end

# Occasionally this will hang on one of the iterations.
1000.times do |i|
  puts(i)
  futures[i].value
end
tarcieri commented 9 years ago

I'd suggest upgrading to the latest versions of celluloid/celluloid-io and see if your problems still persist

jonhyman commented 9 years ago

I'll give it a shot after 0.16.1, since we're stuck on 0.15.2 due to https://github.com/celluloid/celluloid/issues/457.

tarcieri commented 9 years ago

Which problem in particular? I should probably break #457 down into more granular tickets

jonhyman commented 9 years ago

We were being affected by https://github.com/mperham/sidekiq/issues/1929 and couldn't get our Sidekiq workers to shut down / restart. I didn't notice the other 2 that Mike talks about, but we caught that first one in staging the day we updated so we reverted quickly.

tarcieri commented 9 years ago

I'm still looking into that one myself. If you have any ideas, let me know.

Asmod4n commented 9 years ago

Btw, what about using https://code.google.com/p/libevhdns/ for crubies and whatever non blocking resolver Java has?