如何诊断或减少“等待”是时候发布网页内容了吗?

发布于 2024-12-11 20:54:25 字数 360 浏览 0 评论 0原文

我不断看到我的服务器上的性能不一致,并且我发现很难诊断/解决问题。大多数情况下,页面加载速度很快,但有 10-20% 的时间加载速度非常慢。在 Chrome 的网络选项卡中,“等待”时间占延迟的 99%。我什至测试过加载没有输出的空白 PHP 页面,但我仍然看到 10-20% 的页面浏览量的等待时间变长。

我尝试过对 PHP 脚本进行计时,所有页面浏览量始终很低,包括等待时间较长的页面浏览量。例如,我可以加载空白页面,它将在 150 毫秒内加载,然后我再次加载它,它会在 8500 毫秒内加载,但两次 PHP 脚本的执行时间都是 <0.5 毫秒。

关于还有什么可能导致此问题的任何想法(我已经在多台计算机/网络上进行了测试,并且正在从世界各地的用户那里获取报告)?

I keep seeing inconsistent performance on a server of mine, and I'm finding it hard to diagnose/fix the problem. For the most part, pages load quickly, but 10-20% of the time they load very slowly. In Chrome's network tab shows "waiting" time as 99% of the lag. I've even tested loading a blank PHP page that has no output and I still see the wait time get large on 10-20% of page views.

I've tried timing the PHP script and it is consistently low on all page views, including the ones that have long wait times. For example, I could load the blank page and it will load in 150ms, and then I load it again and it loads in 8500ms, but both times the PHP script executed in <.5ms.

Any ideas on what else could be causing this (I've tested on multiple computers/networks and am getting reports from users from around the world)?

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

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

发布评论

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

评论(2

廻憶裏菂餘溫 2024-12-18 20:54:25

连接问题/数据包丢失

您的连接上是否存在大量数据包丢失? TCP 连接有时会出现超时,导致数据包丢失,从而最初会丢失连接,但随后(在最坏的情况下)在重试几秒钟后设法连接。

当然,您不仅会注意到查看您的网站的问题,还会注意到该连接上的任何网站的问题。

服务器上的争用

它是否是共享服务器,同一服务器上的其他客户端是否有时会使用过多的 IO 或 CPU,或活动的 Apache 进程?

您可以使用 top 命令(查看一般 CPU 使用情况或负载队列)或 ps -AH v 命令(查看活动 Apache 进程的数量和其他正在运行的进程的概述)。

Connection issues/packet loss

Could it be a high packet loss on your connection? TCP connections sometimes reach timeouts where there is packet loss, whereby it misses a connection initially, but then (in worst case) manages to connect after some seconds worth of retrying.

Of course, you'd notice issues not just viewing your site, but any site on that connection.

Contention on the server

Is it a shared server, and could other clients on the same server be using an excessive amount of IO or CPU, or active Apache processes, at times?

You would debug this with the top command (to see general CPU usage or load queue) or the ps -AH v command (to see the number of active Apache processes and an overview of the other processes running too).

甜尕妞 2024-12-18 20:54:25

对于互联网服务器来说,有很多地方可能会导致加载时间问题。我在我管理的一个网站上也得到了类似的结果。通过互联网,它由多个区域组成。您的计算机上的软件/硬件、您的路由器、您的 ISP 网关、到达您的主机所需的路径、您的主机的网关以及您服务器上的软件/硬件。根据当前负载,所有这些都可能导致瓶颈。等待时间的最常见原因是查找或存储的路由表。这是您计算机的 arp 和网络缓存,可以清除以查看它是否正确(这在某些情况下有帮助)。它不是尝试获得最快的路线,而是使用现在可能具有高负载的旧路径。

第二个原因是您的服务器资源可能不足。如果您使用共享主机,则情况更是如此。如果您有专用服务器,我会在速度缓慢时检查您的资源使用情况。可能有一个进程在某些时间占用资源,例如 cron 作业。

如果不检查这些,就无法知道问题是什么。我唯一能说的是尽可能检查一切并运行tracerouts/pings来检查服务器时间和您正在使用的路径。

With internet servers there are alot of areas that can cause issues with load times. I have had similar results with one website I manage. With the internet, it composes of multiple areas. The software/hardware on your computer, your router, your ISP gateway, the path it takes to get to your hosting, the gateway of your hosting, and the software/hardware on your server. All these can cause bottlenecks depending on current load. The most common reason of waiting time is the lookup or stored routing table. This is your computers arp and network cache and can be cleared to see if it corrects (this has helped in some cases). Instead of trying to get the fastest route it uses old paths which may now have high loads.

The second reason is that your server may be low on resources. This can be more true if you are on shared hosting. If you have a dedicated server, I would check your resource usage when it seems to be slow. There could be a process that is hogging the resources at certain times, example is a cron job.

Without checking these there is no way to know what the issue is. The only thing I can say is to check everything you can and run tracerouts/pings to check the server times and the path you are using.

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