Make Tornado able to handle new requests while waiting response from RPC over RabbitMQ

巧了我就是萌 提交于 2019-12-12 04:36:50

问题


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.



来源:https://stackoverflow.com/questions/26554857/make-tornado-able-to-handle-new-requests-while-waiting-response-from-rpc-over-ra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!