Home > other >  Tornado AsyncHTTPClient and CurlAsyncHTTPClient concurrency issues
Tornado AsyncHTTPClient and CurlAsyncHTTPClient concurrency issues

Time:12-04

I use a tornado do web API, there is no database storage business, main business is to call third-party web API interface,
Start using the requests module to do the HTTP request, found that concurrent slightly better in nginx log request timeout, lots of afterwards by searching the related information, found that tornado need use asynchronous httpclient, stepped on the first hole,

Behind all will request the third party interface replace AsyncHTTPClient, immediately to solve the above problem, enhance concurrent ability, nginx haven't got the error log,
Then according to business needs, need to request the third party use proxy interface, AsyncHTTPClient does not support proxy Settings, need to switch to CurlAsyncHTTPClient, according to the official documentation modified code, and concurrent timeout problems, will change CurlAsyncHTTPClient AsyncHTTPClient problem disappears,


This picture is to use AsyncHTTPClient, server operation, each process how child process,

And when using CurlAsyncHTTPClient or requests, each process here is only a child process, also created a concurrent bottleneck problem,

note that if you are using curl_httpclient, strongly suggest you use the latest version of libcurl and pycurl. The current minimum version is 7.21.1 libcurl can be supported, the minimum version is 7.18.2 pycurl can be supported. It is strongly recommended that you install libcurl is and asynchronous DNS resolver (threaded or c - ares) to build together, otherwise you may encounter a variety of questions request timeout (for more information please check

This is the official document to remind, I according to the requirements, recompile install curl, c - ares/1.10.0 also support, but still can't solve the problem,


Above is the description of the problem, I hope who can help me to provide the solution,
Only 20 points,
  • Related