-->

Make Tornado able to handle new requests while wai

2019-09-06 15:10发布

问题:

I have web-server listening clients and when someone hit handler server send an RPC message to RabbitMQ and waiting for response while keeping connection. When response from RMQ came server pass it to the client as response to request.

All async examples in Tornado docs works with their own http.fetch_async() or something like that methods, and I understand that I have to wait/read for RMQ asynchronously... But how? And even worse - sometimes I have to send several messages at one moment (I create pool of threads and each thread send one message).

Right now I cannot rebuild architecture to get rid of waiting to send an answer from RMQ, so I have web-server blocked. Yet we have no a lot of requests and RMQ response quickly enough but sometimes it can make server waiting up to a minute.

So now we just using Gunicorn with A LOT of workers and BIG SERVERS but I feel it should be a better solution and investigate different options.

Python 3.4, so we cannot use pika RMQ adapter and work with py-amqp from Celery.

回答1:

Use nginx with embedded perl.. It works like superman.. We are using this for our analytics tool.