美文网首页
一次线上请求超时定位历程

一次线上请求超时定位历程

作者: 愿远方有你 | 来源:发表于2022-03-12 21:44 被阅读0次

    遇到一个生产问题,平时rpc接口请求耗时都是在100 ms 毫秒以内的请求,今天突然请求响应时间到到1000ms 左右,定位过程如下:

    • 1、查看服务rpc 接口响应时间,查询大部分请求时间确实边长了
    • 2、查看 依赖的服务的http 接口响应时间,是正常,都是在100ms 以内
    • 3、查看服务gc 日志,gc 时间正常 没有啥问题
    • 4、通过Arthas 打印调用链路耗时、命令 trace com.xxx.xxx.MyClass pullTask ,用法 全限定类名和方法名。打印出各个方法,看到是通过consul 获取地址,耗时长
    • 5、查看代码,服务调用过程


      image.png
    • 6、通过curl 直接访问,记录耗时时长,方便找运维看问题
      1、准备一个文本文件 time_format.txt
        time_namelookup:  %{time_namelookup}\n
        time_connect:  %{time_connect}\n
        time_appconnect:  %{time_appconnect}\n
        time_redirect:  %{time_redirect}\n
       time_pretransfer:  %{time_pretransfer}\n
       time_starttransfer:  %{time_starttransfer}\n
                        ----------\n
             time_total:  %{time_total}\n
      

    2、 命令 curl -w "@time_format.txt" -o /dev/null -s -L 'http://127.0.0.1:8500/v1/health/service/xxxx?passing=true'
    3、执行结果

    image.png
    4、通过这个运维,就ok了

    参考链接:
    https://zhuanlan.zhihu.com/p/52181300
    https://www.duyidong.com/2019/11/26/arthas-analytics-rt/

    相关文章

      网友评论

          本文标题:一次线上请求超时定位历程

          本文链接:https://www.haomeiwen.com/subject/rasldrtx.html