Monitor tornado AsyncHTTPClient queue when max_clients is reached

Viewed 148

In a large scale tornado application we are using shared AsyncHTTPClient for our outgoing requests with a pre-set max_clients.

http_client = tornado.httpclient.AsyncHTTPClient(max_clients=100)

class SomeHandler(tornado.web.RequestHandler):

    @tornado.gen.coroutine
    def get(self, *args, **kwargs):
        response = yield tornado.gen.Task(http_client.fetch, <some_url>, method='GET')
        ...

What i would like to ask, is there a way to see at any given time, if the max_clients treshold had been reached and what is the count of the requests in the queue, to help us scaling it up if needed?

1 Answers

There is currently no supported way to do this. You could peek at implementation details of the AsyncHTTPClient implementation (with no guarantees about future compatibility), or wrap the AsyncHTTPClient object with something that keeps a count of pending fetches.

Related