為什麼相同的請求有不同的回應時間?

為什麼相同的請求有不同的回應時間?

我有一個 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

此處託管的任何端點都會發生這種情況。我根本不知道原因是什麼。有人可以幫忙嗎?

相關內容