gpt4 book ai didi

php - Apache 非常高的页面加载时间

转载 作者:可可西里 更新时间:2023-11-01 08:06:03 24 4
gpt4 key购买 nike

我的 Drupal 6 站点多年来一直运行平稳,但最近出现了间歇性的极度缓慢(10-60 秒页面加载)。几个小时的缓慢,然后是数小时的正常(4-6 秒)页面加载。页面总是加载无误,只是有时会花很长时间。

我的设置:

  • window 服务器 2003
  • Apache/2.2.15 (Win32) Jrun/4.0
  • PHP 5
  • MySql 5.1
  • Drupal 6
  • 冷融合 9
  • VMware 虚拟环境
  • 企业防火墙后面的 DMZ
  • 流量:1-3 次点击/秒峰值

疑难解答

  • apache 错误日志中没有适用的错误
  • drupal 事件日志中没有错误
  • Drupal 开发模块在 366.23 毫秒内显示 242 个查询,页面执行时间为 2069.62 毫秒。 (所以看起来查询和 php 脚本不是问题)
  • 没有异常高的 CPU、内存或磁盘 IO
  • Cold fusion 应用程序和 drupal 之外的其他静态页面也加载缓慢
  • webpagetest.org 测试显示第一个字节的时间非常长

问题似乎与 Apache 响应请求有关,但以前我只在 100% CPU 负载下看到过这种行为。仅通过资源监控来判断,似乎几乎没有什么进展。

关键是——大约一半的网站访问来 self 们的 LAN,但如果我禁用防火墙规则并阻止来 self 们网络外部的访问,内部 (LAN) 访问(1000 多台设备)会很快。但是一旦恢复外部访问,站点就会瘫痪。

Apache 配置?爬虫/机器人?攻击者?我已无计可施,我应该去哪里寻找问题所在?

------编辑:------

附件是来自 webpagetest.org 的瀑布图,显示了 15 秒的加载时间。我见过长达几分钟的时间。而且,服务器大部分时间都运行良好。绿色区域表示浏览器已发送请求并正在等待接收从服务器返回的第一个字节数据。这当然是后端延迟,但令人费解的是,在此缓慢期间几乎没有使用 CPU。

(没有足够的代表发布图片,请参阅 https://webmasters.stackexchange.com/questions/54658/apache-very-high-page-load-time

------编辑------

在 Apache 方面 - 这可能是 ThreadsPerChild 问题吗?

最佳答案

经过大量研究,我可能找到了解决方案。如果我是正确的,那是 apache 配置问题。具体来说,“ThreadsPerChild”指令。见... http://httpd.apache.org/docs/2.2/platform/windows.html

Because Apache for Windows is multithreaded, it does not use a separate process for each request, as Apache can on Unix. Instead there are usually only two Apache processes running: a parent process, and a child which handles the requests. Within the child process each request is handled by a separate thread.

ThreadsPerChild: This directive is new. It tells the server how many threads it should use. This is the maximum number of connections the server can handle at once, so be sure to set this number high enough for your site if you get a lot of hits. The recommended default is ThreadsPerChild 150, but this must be adjusted to reflect the greatest anticipated number of simultaneous connections to accept.

原来,这个指令根本没有在我的配置中设置,因此默认为 64。我通过查看任务管理器中第二个 httpd.exe 进程的线程数来确认这一点。当服务器达到超过 64 个连接时,多余的请求只需等待线程打开即可。我在 httpd.conf 中添加了 ThreadsPerChild 150。

此外,我启用了 apache 状态模块 http://httpd.apache.org/docs/2.2/mod/mod_status.html

...除其他外,它允许人们在任何给定时刻查看服务器上事件请求的总数。马上,我可以看到多达 80 个事件请求的峰值。时间会证明一切,但我相信这会解决我的问题。到目前为止,30 小时没有打嗝。

关于php - Apache 非常高的页面加载时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19696359/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com