Speeding Up Net::HTTP, OpenURI or Any Other TCPSocket Offspring #
Only if you’re doing lots of requests amongst threads and you notice that the opening of the socket is blocking everything.
require 'resolv-replace'
And if you are, then it’s the Matz’ pajamas.
I’m sorry if you feel offended, it’s not my intention. But if getaddrinfo() on your system does not work as you expect, I’m not the right person to report. The only workaround I can think of is to use “resolv-replace”, which is pure Ruby resolver. It is not fast at all, but at least other thread can work during resolving.
For an example, see Josh Harvey’s code.
MenTaLguY
You know, this just reinforces my opinion that everything which does IO should have an asynchronous interface by default.
Granted, it’d still be good to provide a synchronous interface built atop that for convenience—but the point is that you can build a synchronous interface atop an asynchronous one. You can’t really do the reverse.
Comments are closed for this entry.