Am I crazy or is it actually going this fast? (MultiThreading)
<pre><code>from tornado import httpclient
import time

start = time.time()

for x in range(1000):
    httpclient.AsyncHTTPClient().fetch("https://www.google.com", method="GET")

print ('{0} seconds'.format(time.time() - start))
</code></pre>

<p>Result <code>1.11500000954 seconds</code></p>

<p>I wrote this to see how fast I can send 1000 requests to any site (I chose google) and I don't know why, but I feel like I did something wrong and its not actually going this quick, if I did do something wrong, could someone point out my error?</p>

<p>Thank you!</p>

<p>I haven't run this yet, so I could be wrong, but fetch() is an asynchronous method that takes a callback, and the callback is what handles the response from the server when it comes. In other words, I'm pretty sure all you're doing here in this ~1 second is creating the representations of the requests â you're definitely not waiting for responses, and I'm not sure you're necessarily even sending the requests. I don't know the internal implementation here, but you might be buffering them in some sense, or you could be making attempts to send them as fast as possible but some/many are failing â and you don't really know what's actually happening, because these asynchronous requests are "fire and forget". </p>

<p>If you want to know how many USEFUL requests you can send, as in ones that will reach the server and get a response, you'd need to do the timing in a callback, not in the thread that's creating the requests. </p>

python multithreading tornado