When and how to use Tornado? When is it useless?

后端 未结 2 861
小蘑菇
小蘑菇 2021-01-29 19:46

Ok, Tornado is non-blocking and quite fast and it can handle a lot of standing requests easily.

But I guess it\'s not a silver bullet and if we just blindly run Django-b

2条回答
  •  孤独总比滥情好
    2021-01-29 20:19

    I'm sorry for answering an old question, but I came across this one and wondered why it didn't have more answers. To answer Bart J's question:

    I would like to parse RSS feeds in the Tornado application. Would you consider that fairly computationally intensive?

    Well that depends on what kind of parsing you're doing and on what hardware :) Long time is a long time, so if your app takes more than say half a second to respond, it'll seem sluggish - profile your app.

    The key to fast systems is great architecture, not so much the specifics as for instance which framework you're using (Twisted, Tornado, Apache+PHP). Tornado has an asynchronous processing style and that's really what a lot of it comes down to in my opinion. Node.js, Twisted and Yaws are examples of other asynchronous web servers that scale very well because of a lightweight approach and asynchronous processing style.

    So:

    When should Tornado be used?

    When is it useless?

    Tornado is good for handling a lot of connections, since it can respond to an incoming client, dispatch a request handler and don't think about that client until the result-callback is pushed on the event queue. So for that specific quality Tornado should be used when you want to scale well when handling a lot of requests. The async processing facilitates functional decoupling and shared-nothing data access. That swings really well with stateless design like REST or other Service Oriented Architectures. You also don't have to deal with spawning threads or processes with the inherent overhead so much and you can save some of the locking/IPC trouble.

    Tornado won't make much of a difference, on the other hand, if your backend and/or data store takes a long time to process the requests. It helps to do concurrent designs and Web services in particular. The concurrent architecture makes it easier to scale your design and keep the coupling low. That's my experience with Tornado at least.

提交回复
热议问题