![为什么同一个请求有不同的响应时间?](https://linux22.com/image/726898/%E4%B8%BA%E4%BB%80%E4%B9%88%E5%90%8C%E4%B8%80%E4%B8%AA%E8%AF%B7%E6%B1%82%E6%9C%89%E4%B8%8D%E5%90%8C%E7%9A%84%E5%93%8D%E5%BA%94%E6%97%B6%E9%97%B4%EF%BC%9F.png)
我有一个 API(使用 nodejs 构建)并使用 docker 镜像部署在 kubernetes 集群上。
对于默认路线我只是返回一条Hello World QA!
消息。
我正在测试此 GET 请求的响应时间,我发现偶尔会有一个请求比其他请求花费的时间长得多,例如:
Cristians-MBP:google_cloud cristiboariu$ curl -X GET "http://35.230.22.104:8000" -w "@curl-format.txt" -s
Hello World QA!time_namelookup: 0.005095
time_connect: 0.203066
time_appconnect: 0.000000
time_pretransfer: 0.203164
time_redirect: 0.000000
time_starttransfer: 0.420915
----------
time_total: 0.421004
Cristians-MBP:google_cloud cristiboariu$ curl -X GET "http://35.230.22.104:8000" -w "@curl-format.txt" -s
Hello World QA!time_namelookup: 0.005164
time_connect: 0.236487
time_appconnect: 0.000000
time_pretransfer: 0.236551
time_redirect: 0.000000
time_starttransfer: 0.449582
----------
time_total: 0.449632
Cristians-MBP:google_cloud cristiboariu$ curl -X GET "http://35.230.22.104:8000" -w "@curl-format.txt" -s
Hello World QA!time_namelookup: 0.005092
time_connect: 0.214788
time_appconnect: 0.000000
time_pretransfer: 0.214851
time_redirect: 0.000000
time_starttransfer: 0.419028
----------
time_total: 0.419075
Cristians-MBP:google_cloud cristiboariu$ curl -X GET "http://35.230.22.104:8000" -w "@curl-format.txt" -s
Hello World QA!time_namelookup: 0.005099
time_connect: 1.009918
time_appconnect: 0.000000
time_pretransfer: 1.009983
time_redirect: 0.000000
time_starttransfer: 3.137044
----------
time_total: 3.137087
此处托管的任何端点都会发生这种情况。我根本不知道可能是什么原因造成的。有人能帮忙吗?