Playing with ruby to send asynchronous http requests
I wanted to explore different options for having a script run with asynchronous request to a remote http server. With PHP this can be done with multicurl handles, but limiting the concurrent requests was problematic. It also seemed slow.
After a bit of research, I chose Ruby as i found the Typhoeus library/gem, it just meant I had to learn some Ruby.
Typhoeus is just a libcurl library, but also comes with Hydra, a method for stacking requests concurrently.
I also have a wireguard VPN setup, which comes along with optional socks5 proxies to reroute traffic as desired.
The script loops through the list of proxies and queries a remote server for the requesting IP address. And with some additional information about the timing of the requests.
seconds proxy ip
0.304 89.44.10.121
0.922 socks5://us9-wg.socks5.mullvad.net:1080 198.54.133.163
1.436 socks5://ch2-wg.socks5.mullvad.net:1080 81.17.24.202
1.531 socks5://cz1-wg.socks5.mullvad.net:1080 185.242.6.19
1.583 socks5://se1-wg.socks5.mullvad.net:1080 193.138.218.221
1.592 socks5://bg4-wg.socks5.mullvad.net:1080 217.138.221.179
********************************************************************************
1.596 seconds total
0.266 per request [6 requests]
Whilst running requests through a proxy does increase the time taken, the ability to have 400+ remote ip addresses available is worth the decrease in performance. I could use this to test the performance of my webserver, for instance.
And I got to use a new programming language.
Full script as follows: