Skip to content

Instantly share code, notes, and snippets.

@jonniesweb
Last active March 25, 2018 15:55
Show Gist options
  • Save jonniesweb/5fc677b08a071c05e7c64b12af663151 to your computer and use it in GitHub Desktop.
Save jonniesweb/5fc677b08a071c05e7c64b12af663151 to your computer and use it in GitHub Desktop.
A simple example of using the Typhoeus parallel HTTP client library
# setup requests
request_one = Typhoeus.get("www.example.com")
request_two = Typhoeus.get("www.google.com")
request_three = Typhoeus.get("www.bing.com")
# initialize a "Hydra" for performing requests in parallel
hydra = Typhoeus::Hydra.new
hydra.queue(request_one)
hydra.queue(request_two)
hydra.queue(request_three)
# run and wait for all requests to finish
hydra.run
# fetch the body of the response
puts request_one.response.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment