原文网址:https://www.youyong.top/article/11594201453d0
公司的网站,最近一段时间访问有时挺慢的,以前首页加载都是6 7百毫秒,最近有时能到达3秒,在chrome里查看network,发现时间耗在了页面上,而非图片 css js, 难道是后端处理出了问题,看后端nginx日志,发现处理时间就一丢丢。 看了 timing,才知道是 stalled时间过长,如下图,那 stalled又是什么那?
原文网址:https://www.youyong.top/article/11594201453d0
公司的网站,最近一段时间访问有时挺慢的,以前首页加载都是6 7百毫秒,最近有时能到达3秒,在chrome里查看network,发现时间耗在了页面上,而非图片 css js, 难道是后端处理出了问题,看后端nginx日志,发现处理时间就一丢丢。 看了 timing,才知道是 stalled时间过长,如下图,那 stalled又是什么那?
原文网址:https://www.youyong.top/article/11594201453d0
以下引用来自: http://www.tuicool.com/articles/qQVj6nb
什么是stalled呢?下面是一段比较容易懂的解释:
Time the request spent waiting before it could be sent. This time is inclusive of any time spent in proxy negotiation. Additionally, this time will include when the browser is waiting for an already established connection to become available for re-use, obeying Chrome’s maximum six TCP connection per origin rule.
也即是从TCP连接建立完成,到真正可以传输数据之间的时间差。先让我们要分析TCP连接为什么要等待这么久才能用?我用Wireshark抓包发现,TCP连接过程中有多次重传,直到达到最大重传次数后连接被客户端重置。
为什么会发生重传呢?
The sender waits for an ACK for the byte-range sent to the client and when not received, resends the packets, after a particular interval. After a certain number of retries, the host is considered to be “down” and the sender gives up and tears down the TCP connection.
TCP三次握手后,发送端发送数据后,一段时间内(不同的操作系统时间段不同)接收不到服务端ACK包,就会以 某一时间间隔(时间间隔一般为指数型增长)重新发送,从重传开始到接收端正确响应的时间就是stalled阶段。而重传超过一定的次数(windows系统是5次),发送端就认为本次TCP连接已经down掉了,需要重新建立连接。 对比以下,没有重传的http请求过程。
总结一下:stalled阶段时TCP连接的检测过程,如果检测成功就会继续使用该TCP连接发送数据,如果检测失败就会重新建立TCP连接。所以出现stalled阶段过长,往往是丢包所致,这也意味着网络或服务端有问题。
我比较关心的问题是,到底是客户端的网络有问题,还是服务端的网络有问题?
其实这个问题也不难验证.
方法1:
ping 百度 和 ping 你的服务器。
如果都有超时,丢包的现象,说明是客户端的网络有问题(其实如果是客户端网络的问题,你访问其他网站也会慢的)方法2:
ping只能看出个大概,建议做个双向的 mtr 测试 (你本地到服务器,服务器到你本地)
相关方法参考:Linux下ping丢包或不通时链路测试工具推荐
共 0 条留言
iPhone X 跌破发行价,苏宁200亿入股恒大 | 财经日日评
资深黄牛现身说法:iPhone X价格秒变不停,就像炒股一样
改了php.ini中的open_basedir仍报错open_basedir restriction in effect
推荐 | PHP WEB消息推送框架 web-msg-sender (PHPSocket.IO)
如何准确判断请求是不是搜索引擎爬虫(蜘蛛)发出的请求?(php window linux)
PHP Warning: feof() expects parameter 1 to be resource, null
手机扫一扫
分享文章