hoodwink.d enhanced
RSS
2.0
XHTML
1.0

RedHanded

Speeding Up Net::HTTP, OpenURI or Any Other TCPSocket Offspring #

by why in bits

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.

From his own tongue:

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.

said on 26 Apr 2006 at 17:48

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.

said on 07 May 2006 at 00:07

Comments are closed for this entry.