何时以及如何使用龙卷风?什么时候没用了?

发布于 2024-10-03 15:16:50 字数 318 浏览 6 评论 0原文

好的,Tornado 是无阻塞的并且速度相当快,它可以轻松处理大量长期请求。

但我想这不是灵丹妙药,如果我们只是盲目地使用 Tornado 运行基于 Django 的网站或任何其他网站,它不会带来任何性能提升。

我找不到对此的全面解释,所以我在这里问:

  • 何时应该使用 Tornado?
  • 什么时候没用了?
  • 使用时应注意什么?
  • 我们如何使用 Tornado 使网站效率低下
  • 有一个服务器和一个网络框架。 我们什么时候应该使用框架,什么时候可以用其他框架替代它?

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-based or any other site with Tornado it won't give any performance boost.

I couldn't find comprehensive explanation of this, so I'm asking it here:

  • When should Tornado be used?
  • When is it useless?
  • When using it, what should be taken into account?
  • How can we make inefficient site using Tornado?
  • There is a server and a webframework.
    When should we use framework and when can we replace it with other one?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨的味道风的声音 2024-10-10 15:16:50

有一个服务器和一个网络框架。什么时候应该使用框架,什么时候可以用其他框架代替?

这个区别有点模糊。如果您仅提供静态页面,则可以使用快速服务器之一,例如 lighthttpd。否则,大多数服务器都提供不同复杂性的框架来开发 Web 应用程序。 Tornado 是一个很好的网络框架。 Twisted 的能力更强,被认为是一个很好的网络框架。它支持很多协议。

Tornado 和 Twisted 是提供非阻塞、异步 Web/网络应用程序开发支持的框架。

什么时候应该使用龙卷风?
什么时候没用了?
使用时应注意什么?

就其本质而言,异步/非阻塞 I/O 在 I/O 密集型而非计算密集型时效果很好。大多数网络/网络应用程序都非常适合这种模型。如果您的应用程序需要完成某些计算密集型任务,则必须将其委托给可以更好地处理它的其他服务。而Tornado / Twisted可以完成Web服务器的工作,响应Web请求。

我们如何使用 Tornado 来制作效率低下的网站?

  1. 做任何计算密集型任务
  2. 引入阻塞操作

但我想这不是灵丹妙药,如果我们只是盲目地使用 Tornado 运行基于 Django 的网站或任何其他网站,它不会带来任何性能提升。

性能通常是完整 Web 应用程序架构的一个特征。如果应用程序设计不当,大多数 Web 框架的性能都会降低。考虑缓存、负载平衡等。Tornado

和 Twisted 提供合理的性能,它们非常适合构建高性能的 Web 应用程序。您可以查看扭曲和龙卷风的推荐,看看它们的能力。

There is a server and a webframework. When should we use framework and when can we replace it with other one?

This distinction is a bit blurry. If you are only serving static pages, you would use one of the fast servers like lighthttpd. Otherwise, most servers provide a varying complexity of framework to develop web applications. Tornado is a good web framework. Twisted is even more capable and is considered a good networking framework. It has support for lot of protocols.

Tornado and Twisted are frameworks that provide support non-blocking, asynchronous web / networking application development.

When should Tornado be used?
When is it useless?
When using it, what should be taken into account?

By its very nature, Async / Non-Blocking I/O works great when it is I/O intensive and not computation intensive. Most web / networking applications suits well for this model. If your application demands certain computational intensive task to be done then it has to be delegated to some other service that can handle it better. While Tornado / Twisted can do the job of web server, responding to web requests.

How can we make inefficient site using Tornado?

  1. Do any thing computational intensive task
  2. Introduce blocking operations

But I guess it's not a silver bullet and if we just blindly run Django-based or any other site with Tornado it won't give any performance boost.

Performance is usually a characteristic of complete web application architecture. You can bring down the performance with most web frameworks, if the application is not designed properly. Think about caching, load balancing etc.

Tornado and Twisted provide reasonable performance and they are good for building performant web applications. You can check out the testimonials for both twisted and tornado to see what they are capable of.

筱果果 2024-10-10 15:16:50

我很抱歉回答一个老问题,但我遇到了这个问题,想知道为什么它没有更多答案。回答巴特·J的问题:

我想在 Tornado 应用程序中解析 RSS 提要。您认为这相当计算密集吗?

好吧,这取决于您正在执行哪种解析以及在什么硬件上:) 时间很长,所以如果您的应用程序需要超过半秒的时间来响应,它会显得缓慢 - 分析您的应用程序。

快速系统的关键是出色的架构,而不是具体细节,例如您正在使用哪个框架(Twisted、Tornado、Apache+PHP)。 Tornado 具有异步处理风格,在我看来,这就是它的本质所在。 Node.js、Twisted 和 Yaws 是其他异步 Web 服务器的示例,它们由于轻量级方法和异步处理风格而具有良好的扩展性。

所以:

什么时候应该使用龙卷风?

什么时候没用?

Tornado 适合处理大量连接,因为它可以响应传入的客户端、分派请求处理程序,并且在将结果回调推送到事件队列之前不考虑该客户端。因此,对于特定的质量,当您希望在处理大量请求时能够很好地扩展时,应该使用 Tornado。
异步处理有利于功能解耦和无共享数据访问。这与无状态设计(例如 REST 或其他 面向服务的架构。您也不必处理产生太多固有开销的线程或进程,并且可以节省一些锁定/IPC 麻烦。

另一方面,如果您的后端和/或数据存储需要很长时间来处理请求,则龙卷风不会产生太大影响。它特别有助于并发设计和 Web 服务。并发架构使您可以更轻松地扩展设计并保持低耦合。至少这是我对龙卷风的体验。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文