简体   繁体   English

有时我网站上的页面加载速度很慢

[英]Sometimes pages on my website load very slowly

Across all browsers/devices, I find random different pages, at random times, are very slow to load/don't load.在所有浏览器/设备中,我发现随机不同的页面在随机时间加载/不加载非常慢。 The browser is stuck on 'Waiting for website.com'.浏览器卡在“等待 website.com”。 I will wait 20 seconds and nothing will happen until I manually refresh the page.我将等待 20 秒,在我手动刷新页面之前什么都不会发生。 As I realise this is very vague, can you suggest a) most likely issues to look for first or b) some diagnostic tools that I could use to try and de-bug the issue as a starting point, so that my hosts/developers can solve the issue.当我意识到这非常模糊时,您能否建议 a) 最有可能首先寻找的问题或 b) 我可以用来尝试调试问题的一些诊断工具作为起点,以便我的主机/开发人员可以解决问题。 Here are some results of recent speed tests.以下是最近速度测试的一些结果。

One thing to also add is that, it seems it more often gets stuck on particular pages.要补充的一件事是,它似乎更经常卡在特定页面上。 Namely the pages where users take practice tests.即用户进行练习测试的页面。 After each time the user clicks 'Next', their selected answer is inserted into the database.每次用户单击“下一步”后,他们选择的答案都会插入到数据库中。 My speculation is that potentially it's an issue with the DB itself, or the process which inserts into the database.我的猜测是,这可能是数据库本身的问题,或者是插入数据库的过程。 It's when clicking 'Next', that the whole website sometimes just dies as described above.当点击“下一步”时,整个网站有时会像上面描述的那样死掉。

Results from Google Speed Test谷歌速度测试的结果

Waterfall image瀑布图

A wait time of 20secs at random times and random pages could possibly be due to stop-the-world garbage collection.随机时间和随机页面的等待时间为 20 秒,这可能是由于 stop-the-world 垃圾收集。 So GC logs are probably a good starting point.所以 GC 日志可能是一个很好的起点。

A thread sampler such as Djigger a colleague of mine wrote might probably also help you figuring out what the machine is doing during the 20 seconds.我的同事写的Djigger之类的线程采样器可能还可以帮助您弄清楚机器在 20 秒内正在做什么。

If that doesn't help I suggest to use a Profiler or better an APM tool to monitor whats going on on your system.如果这没有帮助,我建议使用 Profiler 或更好的 APM 工具来监控系统上发生的事情。 Those tools give a you a broader insight of the internals.这些工具让您对内部有更广泛的了解。

You need to run a few page speed tests and look at the waterfall images.您需要运行一些页面速度测试并查看瀑布图像。

It is very common on shared servers for the server to be too busy to get to your request.在共享服务器上,服务器太忙而无法处理您的请求是很常见的。 20 seconds would indicate a serious issue with the server. 20 秒表示服务器存在严重问题。

Another common reason is the page has a link to a third party resource and that resource is too often unavailable.另一个常见原因是该页面具有指向第三方资源的链接,并且该资源经常不可用。

In your case the culprit is website.com and I assume that is your site.在您的情况下,罪魁祸首是 website.com,我认为那是您的网站。

Use something like webpagetest.org to run the tests.使用类似webpagetest.org 的东西来运行测试。

In the waterfall image below在下面的瀑布图中
Dark Green is DNS lookup time.深绿色是 DNS 查找时间。
Orange is the time for Browser to connect to server.橙色是浏览器连接服务器的时间。
Green is the wait time for server to put image in output buffer.绿色是服务器将图像放入输出缓冲区的等待时间。
Blue is the time for the server to transmit to the Browser.蓝色是服务器传输到浏览器的时间。

The problem with the sample waterfall page is the index page took 4 seconds to be generated or retrieved.示例瀑布页面的问题是索引页面需要 4 秒才能生成或检索。 Most likely this is a Word Press site with plugins.这很可能是一个带有插件的 Word Press 网站。

I suspect yours may be 20 seconds.我怀疑你的可能是 20 秒。 But due to the randomness, is is also a good possibility it is a page resource that is stalled.但是由于随机性,也很有可能是页面资源被停止。

If it is the index page, then you likely have a poor ISP and or one of the other users of the server is hogging the CPU.如果它是索引页面,那么您的 ISP 可能很差,或者服务器的其他用户之一正在占用 CPU。

Keep running the tests until you see the problem occur.继续运行测试,直到您看到问题发生。

It will be very obvious where the problem is located.问题出在哪里会很明显。

You can post the waterfall image and send me a message if you have any questions.如果您有任何问题,您可以发布瀑布图像并给我发送消息。

Waterfall from webpagetest.org

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM