ruby on rails - Speed up OpenUri by keeping connection open? -
is there way speed openuri connections in ruby, maybe somehow keeping stream open?
here i'm doing retrieve data:
doc = nokogiri::html( open(url).read )
which seems slow when batch processing several thousand urls.
if you're processing several thousand urls using openuri, you're using wrong library. instead should looking @ let process them in parallel.
i recommend @ using typhoeus , hydra. typhoeus the code gets url, , hydra handles multiple connections. check out examples on main page see how easy have many parallel connections running @ once.
run benchmark tests determine @ point saturate host, , internet connection. trying run more connections pipe can handle wastes cpu time. also, careful if you're trying process multiple connections same host you're eating bandwidth , cpu too, great way banned.
Comments
Post a Comment