Faster Net::HTTP for Ruby 1.8.6
20
Dec/081
Dec/081
We’ve been a bit frustrated at work with Net::HTTP performance (as have so many others) so here’s a monkeypatch for 1.8.6 that combines the buffer size increase in 1.8.7 with Aaron Patterson’s recent tweak to use non-blocking IO (unfortunately, the non-blocking IO patch doesn’t work with HTTPS, which is why we use the buffer size tweak when the @io variable suggests that HTTPS is happening. No guarantee implied, etc.
class Net::BufferedIO #:nodoc: aliasld_rbuf_fill :rbuf_fill def rbuf_fill BUFSIZE = 1024 * 16 # HTTPS can't use the non-blocking strategy below in 1.8.6; so at least # increase buffer size over 1.8.6 default of 1024 if !@io.respond_to? :read_nonblock timeout(@read_timeout) { @rbuf << @io.sysread(BUFSIZE) } return end # non-blocking begin @rbuf << @io.read_nonblock(BUFSIZE) rescue Errno::EWOULDBLOCK if IO.select([@io], nil, nil, @read_timeout) @rbuf << @io.read_nonblock(BUFSIZE) else raise Timeout::TimeoutError end end end end
DNS failover: Short TTL vs Multiple A Records?
1
Dec/080
Dec/080
Note to self:
Apparently the reason people do round-robin DNS with multiple A records is because Internet Explorer retires a bad IP better when the A Record disappears vs. the TTL expiring (worse case for the latter: 28 minutes!).
http://www.netwidget.net/books/apress/dns/info/failover.html
