任意接口请求通过 ip 访问有较大概率 5 秒才会响应且几乎慢就是 5 秒, localhost 则几百毫秒内返回从不超时
java 服务,使用 springboot 内置 tomcat 运行 使用 docker 运行服务 dockes 配置未对容器进行 cpu 资源限制 内存也给了 2G
服务是部署在两台机器上 都有这个问题。
1.最开始猜测是 docker cpu 限制太严重所以后面把 cpu 限制的参数删除了问题还存在
2.docker 网络使用的是 host 模式
下面贴上 tcpdump 的抓包
19:00:22.174754 IP host-145-152-6-83.openstacklocal.48702 > host-145-152-6-83.openstacklocal.26107: Flags [S], seq 1281709290, win 43690, options [mss 65495,sackOK,TS val 2912860989 ecr 0,nop,wscale 7], length 0
19:00:22.174777 IP host-145-152-6-83.openstacklocal.26107 > host-145-152-6-83.openstacklocal.48702: Flags [S.], seq 2952690423, ack 1281709291, win 43690, options [mss 65495,sackOK,TS val 2912860989 ecr 2912860989,nop,wscale 7], length 0
19:00:22.174789 IP host-145-152-6-83.openstacklocal.48702 > host-145-152-6-83.openstacklocal.26107: Flags [.], ack 1, win 342, options [nop,nop,TS val 2912860989 ecr 2912860989], length 0
19:00:22.174846 IP host-145-152-6-83.openstacklocal.48702 > host-145-152-6-83.openstacklocal.26107: Flags [P.], seq 1:103, ack 1, win 342, options [nop,nop,TS val 2912860989 ecr 2912860989], length 102
19:00:22.174854 IP host-145-152-6-83.openstacklocal.26107 > host-145-152-6-83.openstacklocal.48702: Flags [.], ack 103, win 342, options [nop,nop,TS val 2912860989 ecr 2912860989], length 0
19:00:27.181953 IP host-145-152-6-83.openstacklocal.26107 > host-145-152-6-83.openstacklocal.48702: Flags [P.], seq 1:156, ack 103, win 342, options [nop,nop,TS val 2912865996 ecr 2912860989], length 155
19:00:27.181970 IP host-145-152-6-83.openstacklocal.48702 > host-145-152-6-83.openstacklocal.26107: Flags [.], ack 156, win 350, options [nop,nop,TS val 2912865996 ecr 2912865996], length 0
19:00:27.182133 IP host-145-152-6-83.openstacklocal.26107 > host-145-152-6-83.openstacklocal.48702: Flags [P.], seq 156:161, ack 103, win 342, options [nop,nop,TS val 2912865997 ecr 2912865996], length 5
19:00:27.182139 IP host-145-152-6-83.openstacklocal.48702 > host-145-152-6-83.openstacklocal.26107: Flags [.], ack 161, win 350, options [nop,nop,TS val 2912865997 ecr 2912865997], length 0
19:00:27.182257 IP host-145-152-6-83.openstacklocal.48702 > host-145-152-6-83.openstacklocal.26107: Flags [F.], seq 103, ack 161, win 350, options [nop,nop,TS val 2912865997 ecr 2912865997], length 0
19:00:27.182407 IP host-145-152-6-83.openstacklocal.26107 > host-145-152-6-83.openstacklocal.48702: Flags [F.], seq 161, ack 104, win 342, options [nop,nop,TS val 2912865997 ecr 2912865997], length 0
19:00:27.182416 IP host-145-152-6-83.openstacklocal.48702 > host-145-152-6-83.openstacklocal.26107: Flags [.], ack 162, win 350, options [nop,nop,TS val 2912865997 ecr 2912865997], length 0
可以看到有一段 5 秒的
我测试的接口是只返回当前系统的时间戳
因为 localhost 一直正常我且本地测试也正常我几乎不认为是服务本身的问题。
服务器本身 cpu 并不高 内存也还有富余
有人遇到了类似的问题吗?希望能指导下
25 条回复
joyhub2140
136 天前
@
alipei666 建议用 Rocky Linux 部署一套测试版看看呗。
反正都是 docker 部署的,导出个镜像不复杂吧。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/1063590
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.