我正在使用无服务器将nextjs应用程序部署到AWS。在我的一页上,即使它是静态的,我也看到了一些可怕的延迟。使用 curl_for_latency.sh (AWS认可的脚本),我得到以下统计信息:
---------Operation is beginning---------
url_effective : 'https://sayy.it/sayy' <-- (The URL that was fetched last.)
http_code : 200 <-- (The numerical response code that was found in the last retrieved HTTP(S) or FTP(s) transfer.)
content_type : 'text/html; charset=utf-8' <-- (The Content-Type of the requested document, if there was any.)
---------Local DNS resolution beginning---------
time_namelookup : 0.004911 <-- (The time, in seconds, it took from the start until the DNS name resolution was completed.)
---------Connection to CloudFront beginning---------
time_connect : 0.012322 <-- (The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed.)
time_appconnect : 0.043697 <-- (The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed.)
---------Communication between CloudFront and API Gateway (via Internet backbone networks) beginning---------
time_pretransfer : 0.043951 <-- (The time, in seconds, it took from the start until the file transfer was just about to begin.)
time_redirect : 0.000000 <-- (The time, in seconds, it took for all redirection steps before the final transaction was started.)
---------NOTE: Communication between API Gateway and the Integration Request Endpoint occurring---------
---------NOTE: Communication between API Gateway and CloudFront (via Internet backbone networks) occurring---------
---------Response from CloudFront beginning---------
time_starttransfer : 1.125288 <-- (The time, in seconds, it took from the start until the first byte was just about to be transferred.)
size_download : 43629 <-- (The total amount of bytes that were downloaded.)
---------Response has been received---------
time_total : 1.134074 <-- (The total time, in seconds, that the full operation lasted.)
---------Operation is complete---------
问题似乎出在Cloudfront的 time_starttransfer 上。我应该注意,这不是一个冷门:不仅这些lamnbdas温暖,而且我还有一个使它们保持温暖的热身插件。