nginx/apache/php 与 nginx/php 对比

发布于 2024-10-01 01:11:20 字数 524 浏览 4 评论 0原文

我目前有一台带有 nginx 的服务器,它反向代理到 apache(同一服务器)来处理 php 请求。我想知道我是否放弃 apache,这样如果我看到任何性能提升,我就会将 nginx/fastcgi 运行到 php。我假设我会这样做,因为 Apache 相当臃肿,但同时我不确定 fastcgi/php 有多可靠,尤其是在高流量情况下。

我的网站每月约有 200,000 名独立访问者,每月来自搜索引擎的页面抓取量约为 6,000,000 次。这个数字正在稳步增加,因此我正在考虑性能选项。

我的网站在代码方面进行了非常优化,没有任何缓存(也不希望这样),每个页面最多有 2 个 sql 查询,没有任何其他表的联接,索引也很完美。

大约一年后,我将重写所有内容以使用 ClearSilver 作为模板,然后可能使用 python 或 c++ 来获得极致性能。

我想我或多或少正在寻求任何熟悉 nginx/fastcgi 的人的建议,并且是否愿意提供一些基准。我的站点是一台配备 1 个四核 Xeon、8GB 内存、150GB velociraptor 驱动器的服务器。

I currently have one server with nginx that reverse_proxy to apache (same server) for processing php requests. I'm wondering if I drop apache so I'd run nginx/fastcgi to php if I'd see any sort of performance increases. I'm assuming I would since Apache's pretty bloated up, but at the same time I'm not sure how reliable fastcgi/php is especially in high traffic situations.

My sites gets around 200,000 unique visitors a month, with around 6,000,000 page crawls from the search engines monthly. This number is steadily increasing so I'm looking at perfomrance options.

My site is very optimized code wise and there isn't any caching (don't want that either), each page has a max of 2 sql queries without any joins on other tables, indexes are perfect as well.

In a year or so I'll be rewriting everything to use ClearSilver for the templates, and then probably use python or else c++ for extreme performance.

I suppose I'm more or less looking for any advice from anyone who is familiar with nginx/fastcgi and if willing to provide some benchmarks. My sites are one server with 1 quad core xeon, 8gb ram, 150gb velociraptor drive.

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

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

发布评论

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

评论(4

话少心凉 2024-10-08 01:11:20

nginx 肯定会比 Apache 运行得更快。我无法讲述 fastcgi,因为我从未将它与 nginx 一起使用过,但这个解决方案似乎在多个服务器上更有意义(一个用于静态内容,一个用于 fastcgi/PHP)。

如果您确实以性能为目标 - 甚至考虑 C/C++ - 那么您应该尝试 G-WAN,这是一款提供(非常快的)C 脚本的一体化服务器。

G-WAN 不仅内存占用小得离谱 (120 KB),而且其扩展能力无与伦比。如果您从 PHP 迁移,您还有很多工作要做,但您可以从性能关键型任务开始,然后逐步迁移。

我们已经完成了跳跃,不能考虑回到 Apache!

nginx will definitely work faster than Apache. I can't tell about fastcgi since I never used it with nginx but this solution seems to make more sense on several servers (one for static contents and one for fastcgi/PHP).

If you are really targeting performance -and even consider C/C++- then you should give a try to G-WAN, an all-in-one server which provides (very fast) C scripts.

Not only G-WAN has a ridiculously small memory footprint (120 KB) but it scales like nothing else. There's work ahead of you if you migrate from PHP, but you can start with the performance-critical tasks and migrate progressively.

We have made the jump and cannot consider to go back to Apache!

负佳期 2024-10-08 01:11:20

下面是一张图表,显示了 nginx、apache 和 g-wan 各自的性能:

g-wan.com/imgs/gwan-lighttpd-nginx-cherokee.png

apache 似乎并不领先(这是一个 -Quad XEON @ 3GHz)。

Here is a chart showing the respective performances of nginx, apache and g-wan:

g-wan.com/imgs/gwan-lighttpd-nginx-cherokee.png

apache does not seem to lead the pack (and that's a -Quad XEON @ 3GHz).

你在我安 2024-10-08 01:11:20

这是 g-wan 与 nginx、varnish 等的独立基准 http://nbonvin.wordpress.com/2011/03/14/apache-vs-nginx-vs-varnish-vs-gwan/

g-wan 每秒处理更多请求CPU 时间少得多。

Here is an independent benchmark for g-wan vs nginx, varnish and others http://nbonvin.wordpress.com/2011/03/14/apache-vs-nginx-vs-varnish-vs-gwan/

g-wan handles much more requests per second with much less CPU time.

心不设防 2024-10-08 01:11:20

NGINX 是当今网络服务器的最佳选择。

  1. Apache 和 NGINX 的主要区别在于它们的设计
    建筑学。 Apache 使用流程驱动的方法并创建
    每个请求的新线程。而 NGINX 使用事件驱动
    一个线程中处理多个请求的架构。
  2. 就静态内容而言,Nginx 超越了 Apache。
  3. 两者都擅长处理动态内容。
  4. Apache 可以在所有操作系统上运行,例如 UNIX、Linux 或 BSD,
    全面支持 Microsoft Windows 和 Windows NGINX 也运行在多个
    现代类 Unix 系统并支持 Windows,但其
    Windows 上的性能不如 UNIX 平台上的稳定。
  5. Apache 允许通过以下方式在每个目录的基础上进行额外配置
    .htaccess 文件。 Nginx 不允许额外的配置。
  6. 请求解释-Apache 传递文件系统位置。 nginx
    传递 URI 来解释请求。
  7. Apache 有 60 个官方动态可加载模块
    打开/关闭。Nginx 有第 3 方核心模块(不是动态的)
    可加载)。NGINX 提供了 Web 服务器的所有核心功能,
    不牺牲轻量化和高性能品质
    这使它成功。
  8. Apache 支持通过动态模块定制 Web 服务器。
    Nginx 不够灵活,无法支持动态模块和加载。
  9. Apache 确保在其服务器上运行的所有网站都是
    免受任何伤害和黑客攻击。 Apache 提供了以下配置提示
    DDoS 攻击处理,以及 mod_evasive 模块
    响应 HTTP DoS、DDoS 或暴力攻击。

何时选择 Apache 而不是 NGINX?

  • 当需要 .htaccess 文件时,您可以覆盖系统范围的设置
    每个目录的基础。
  • 在共享托管环境中,Apache 工作得更好,因为它
    .htaccess 配置。
  • 如果出现功能限制 – 使用 Apache

何时选择 NGINX 而不是 Apache

  • 快速静态内容处理
  • 非常适合高流量网站

当两者一起使用时

用户可以在 Apache 前面使用 Nginx 作为服务器代理。

NGINX is the best choice as a webserver now a days.

  1. The main difference between Apache and NGINX lies in their design
    architecture. Apache uses a process-driven approach and creates a
    new thread for each request. Whereas NGINX uses an event-driven
    architecture to handle multiple requests within one thread.
  2. As far as Static content is concerned, Nginx overpasses Apache.
  3. Both are great at processing Dynamic content.
  4. Apache runs on all operating systems such as UNIX, Linux or BSD and
    has full support for Microsoft Windows & NGINX also runs on several
    modern Unix-like systems and has support for Windows, but its
    performance on Windows is not as stable as that on UNIX platforms.
  5. Apache allows additional configuration on a per-directory basis via
    .htaccess files. Where Nginx doesn’t allow additional configuration.
  6. Request Interpretation-Apache pass file System location. Nginx
    Passes URI to interpret requests.
  7. Apache have 60 official dynamically loadable modules that can be
    turned On/Off.Nginx have 3rd Party core modules (not dynamically
    loadable).NGINX provides all of the core features of a web server,
    without sacrificing the lightweight and high-performance qualities
    that have made it successful.
  8. Apache Supports customization of web server through dynamic modules.
    Nginx is not flexible enough to support dynamic modules and loading.
  9. Apache makes sure that all the website that runs on its server are
    safe from any harm and hackers. Apache offers configuration tips for
    DDoS attack handling, as well as the mod_evasive module for
    responding to HTTP DoS, DDoS, or brute force attacks.

When Choose Apache over NGINX?

  • When needs .htaccess files, you can override system-wide settings on
    a per-directory basis.
  • In a shared hosting environment, Apache works better because of its
    .htaccess configuration.
  • In case of functionality limitations – use Apache

When Choose NGINX over Apache?

  • Fast Static Content Processing
  • Great for High Traffic Websites

When Use Both of them -Together

User can use Nginx in front of Apache as a server proxy.

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