[英]How do I diagnose a long Initial Connection to webpage hosted in AWS with Nginx/ELB/ECS
I have a React web page that uses the Razzle framework for SSR, containerised and deployed into ECS along with an Nginx container.我有一个 React web 页面,它使用用于 SSR 的 Razzle 框架,与一个 Nginx 容器一起容器化并部署到 ECS 中。 I use Route 53 for DNS, which routes the record to an ELB, then to the target group where my container resides.我将 Route 53 用于 DNS,它将记录路由到 ELB,然后路由到我的容器所在的目标组。
If I clear all browsing data and go to the site, it takes over a minute to establish an "Initial Connection" and everything else looks quick.如果我清除网站的所有浏览数据和 go,建立“初始连接”需要一分钟多的时间,其他一切看起来很快。 Subsequent loads of the page do not take long at all.页面的后续加载根本不需要很长时间。
I have no idea where to start to diagnose the issue, does anyone have an idea where I should look?我不知道从哪里开始诊断问题,有人知道我应该看哪里吗?
Here is my Nginx configuration file这是我的 Nginx 配置文件
server {
listen 80;
listen [::]:80;
if ($http_x_forwarded_proto = 'http'){
return 301 https://$host$request_uri;
}
location / {
proxy_pass http://0.0.0.0:3000;
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
server {
server_name www.<domain>.com;
return 301 $scheme://<domain>.com$request_uri;
}
I found my issues was due to my ELB configuration where I had two private su.nets associated instead of public su.nets.我发现我的问题是由于我的 ELB 配置造成的,其中我有两个关联的私有 su.net 而不是公共 su.net。 After creating a public su.net in each availability zone and associating it with the ELB the initial connection time became negligible.在每个可用区创建公共 su.net 并将其与 ELB 关联后,初始连接时间变得可以忽略不计。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.