Why Do Long Http Round Trip-times Stall My Tornado Asynchttpclient?
Solution 1:
After some tinkering and tcpdumping, I've concluded that two things were really slowing down my coroutine. With these two corrected stalling has gone down enormously drastically and the timeout
in yield wakeup_condition.wait(timeout=timedelta(seconds=interval))
is much better respected:
- The computer I'm running on doesn't seem to be caching DNS, which for AsyncHTTPClient seem to be a blocking network call. As such every coroutine sending requests has the added time to wait for the DNS to resolve. Tornado docs say:
tornado.httpclient in the default configuration blocks on DNS resolution but not on other network access (to mitigate this use
ThreadedResolver
or atornado.curl_httpclient
with a properly-configured build oflibcurl
).
...and in the AsynHTTPClient docs
To select curl_httpclient, call AsyncHTTPClient.configure at startup:
AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
I ended up implementing my own thread which resolves and caches DNS, however, and that resolved the issue by issuing the request directly to the IP address.
- The URL I was using was HTTPS, changing to a HTTP url improved performance. For my use case that's not always possible, but it's good to be able to localize part of the issue
Post a Comment for "Why Do Long Http Round Trip-times Stall My Tornado Asynchttpclient?"