阿帕奇+ mod_wsgi / Lighttpd + wsgi - 我会看到性能差异吗?

发布于 2024-11-15 04:21:37 字数 400 浏览 3 评论 0原文

我是使用 Python 进行开发的新手,我正在拼凑所需的信息,以便在另外两个开放问题中做出明智的选择。 (这不是重复的。)

我不是使用框架进行开发,而是使用 gevent 库从头开始构建 Web 应用程序。就前端Web服务器而言,我似乎有三个选择:nginx、apache和lighttpd。

从我读过的所有帐户来看,nginx 的 mod_wsgi 不合适。

这就留下了两个选择——lighttpd 和 Apache。在重负载下,我是否会看到性能和内存消耗特征的重大差异?我的印象是,即使不使用 prefork,Apache 也往往会占用内存,但我不知道 lighttp 对于 Python 应用程序有多合适。

相对于 apache 使用lighttpd 有什么注意事项或好处吗?我真的很想听听你可能让我厌烦的所有信息!

I'm a newbie to developing with Python and I'm piecing together the information I need to make intelligent choices in two other open questions. (This isn't a duplicate.)

I'm not developing using a framework but building a web app from scratch using the gevent library. As far as front-end web servers go, it seems I have three choices: nginx, apache, and lighttpd.

From all accounts that I've read, nginx's mod_wsgi isn't suitable.

That leaves two choices - lighttpd and Apache. Under heavy load, am I going to see major differences in performance and memory consumption characteristics? I'm under the impression Apache tends to be memory hungry even when not using prefork, but I don't know how suitable lighttp is for Python apps.

Are there any caveats or benefits to using lighttpd over apache? I really want to hear all the information you can possibly bore me with!

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

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

发布评论

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

评论(2

绝影如岚 2024-11-22 04:21:37

Apache...

Apache 是迄今为止使用最广泛的 Web 服务器。这是一件好事。关于如何使用它做事情有很多信息,当出现问题时,有很多人知道如何修复它。但是,它也是开箱即用的最慢的;需要大量调整和比 Lighttpd 更强大的服务器。就您而言,使用 Apache 和 Python 会容易得多。那里有无数的 AMP 软件包,以及许多关于如何设置 python 并使应用程序运行的指南。只需快速谷歌搜索即可让您上路。在重负载下,Lighttpd 会胜过 Apache,但 Apache 就像一列火车。它只是继续前进。

优点

  • 广泛的用户群
  • 通用支持
  • 很多插件

缺点

  • 开箱即用速度慢
  • 需要性能调整
  • 内存妓女(不可能让它在 64MB VPS 上运行)

Lighttpd...

Lighttpd 是新来的。它速度快、功能强大,并且性能出色(更不用说像没有内存一样使用)。 Lighttpd 开箱即用,与 Apache 擦肩而过。但是,了解 Lighttpd 的人并不多,因此让它发挥作用更加困难。是的,它是第二大最常用的网络服务器,但它背后没有那么多的社区支持。如果你看看这里,在 stackoverflow 上,有一个家伙一直在询问如何让他的 Python 应用程序工作,但没有人帮助他。在重负载下,如果配置正确,Lighttpd 将超越 Apache(我不久前做了一些测试,您可能会看到每秒请求的性能提高了 200-300%)。

优点

  • 开箱即用快速
  • 使用很少的内存

缺点

  • 不像Apache那样支持
  • 有时只是不起作用

Nginx
如果您运行静态网站,那么您将使用 nginx。你说 nginx 的 mod_wsgi 不合适是正确的。

结论
好处?都有网络服务器;设计为能够相互替换。如果两台网络服务器都调整正确并且您有足够的硬件,那么使用其中一台服务器并没有真正的好处。您应该尝试看看哪个网络服务器可以满足您的需求,但要问我;我会说选择 Lighttpd。在我看来,它更容易配置并且可以正常工作。

另外,您应该查看 Cherokee Web Server。设置起来非常简单,而且性能还不错。您也应该在服务器故障上询问这个问题。

Apache...

Apache is by far the most widely used web server out there. Which is a good thing. There is so much more information on how to do stuff with it, and when something goes wrong there are a lot of people who know how to fix it. But, it is also the slowest out of the box; requring a lot of tweaking and a beefier server than Lighttpd. In your case, it will be a lot easier to get off the ground using Apache and Python. There are countless AMP packages out there, and many guides on how to setup python and make your application work. Just a quick google search will get you on your way. Under heavy load, Lighttpd will outshine Apache, but Apache is like a train. It just keeps chugging along.

Pros

  • Wide User Base
  • Universal support
  • A lot of plugins

Cons

  • Slow out of the box
  • Requires performance tweaking
  • Memory whore (No way you could get it working on a 64MB VPS)

Lighttpd...

Lighttpd is the new kid on the block. It is fast, powerful, and kicks ass performance wise (not to mention use like no memory). Out of the box, Lighttpd wipes the floor with Apache. But, not as many people know Lighttpd, so getting it to work is harder. Yes, it is the second most used webserver, but it does not have as much community support behind it. If you look here, on stackoverflow, there is this dude who keeps asking about how to get his Python app working but nobody has helped him. Under heavy load, if configured correctly, Lighttpd will out preform Apache (I did some tests a while back, and you might see a 200-300% performance increase in requests per second).

Pros

  • Fast out of the box
  • Uses very little memory

Cons

  • Not as much support as Apache
  • Sometimes just does not work

Nginx
If you were running a static website, then you would use nginx. you are correct in saying nginx's mod_wsgi isn't suitable.

Conclusion
Benefits? There are both web servers; designed to be able to replace one another. If both web servers are tuned correctly and you have ample hardware, then there is no real benefit of using one over another. You should try and see which web server meets your need, but asking me; I would say go with Lighttpd. It is, in my opinion, easier to configure and just works.

Also, You should look at Cherokee Web Server. Mad easy to set up and, the performance aint half bad. And you should ask this on Server Fault as well.

久光 2024-11-22 04:21:37

你提到的 gevent 很重要。这是否意味着您正在专门尝试实现长轮询应用程序?如果您是,并且该功能是应用程序的大部分,那么您需要将 gevent 服务器放在使用异步技术而不是进程/线程模型实现的前端 Web 服务器后面。 Lighttd 是一个异步服务器,符合这一要求,而 Apache 则不然。因此,使用 Apache 并不适合作为长轮询应用程序的前端代理。如果这是标准,实际上建议您使用 nginx 而不是 Lighttpd。

现在,如果您没有进行长轮询或任何其他需要长时间运行请求的高并发性的操作,那么您不一定会通过使用 gevent 获得太多收益,特别是如果您打算在顶部使用 WSGI 层。对于 WSGI 应用程序,最终不同服务器之间的性能差异很小,因为您的应用程序不太可能是基准测试都使用的 hello world 程序。真正的瓶颈不是服务器,而是您的应用程序代码、数据库、外部标注、缺乏缓存等。有鉴于此,您应该只使用您最初发现更容易使用的任何 WSGI 托管机制,并且当您正确计算出什么是托管要求是针对您的应用程序的,基于要测试的实际应用程序,然后您可以在必要时切换到更合适的东西。

总之,您只是在浪费时间尝试过早地优化,试图找到理论上最好的服务器,而实际上您的应用程序才是您最初应该关注的。之后,您还应该查看应用程序监控工具,因为如果没有监控工具,您如何确定一种托管解决方案是否优于另一种。

That you have mentioned gevent is important. Does that mean you are specifically trying to implement a long polling application? If you are and that functionality is the bulk of the application, then you will need to put your gevent server behind a front end web server that is implemented using async techniques rather that processes/threading model. Lighttd is an async server and fits that bill whereas Apache isn't. So use of Apache isn't good as front end proxy for long polling application. If that is the criteria though, would actually suggest you use nginx rather than Lighttpd.

Now if you are not doing long polling or anything else that needs high concurrency for long running requests, then you aren't necessarily going to gain too much by using gevent, especially if intention is to use a WSGI layer on top. For WSGI applications, ultimately the performance difference between different servers is minimal because your application is unlikely to be a hello world program that the benchmarks all use. The real bottlenecks are not the server but your application code, database, external callouts, lack of caching etc etc. In light of that, you should just use whatever WSGI hosting mechanism you find easier to use initially and when you properly work out what the hosting requirements are for your application, based on having an actual real application to test, then you can switch to something more appropriate if necessary.

In summary, you are just wasting your time trying to prematurely optimize by trying to find what may be the theoretically best server when in practice your application is what you should be concentrating on initially. After that, you also should be looking at application monitoring tools, because without monitoring tools how are you even going to determine if one hosting solution is better than another.

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