简体   繁体   English

如何使用 Nginx/ELB/ECS 诊断与托管在 AWS 中的网页的长时间初始连接

[英]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.页面的后续加载根本不需要很长时间。

Chrome Dev Tools 的计时面板

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.

相关问题 如何为在 AWS ECS 中运行的 Docker 容器配置“ulimits”? - How do I configure "ulimits" for a Docker container running in AWS ECS? 如何使用 Fluentbit 将 AWS ECS 连接到 ElasticSearch? - How do I connect AWS ECS to ElasticSearch with Fluentbit? AWS Application Load Balancing:看到极长的初始连接时间 - AWS Application Load Balancing: Seeing extremely long initial connection time AWS ECS Fargate + Python + Nginx - AWS ECS Fargate + Python + Nginx AWS ECS 错误:目标组中的任务未能通过 ELB 健康检查 - AWS ECS error: Task failed ELB health checks in Target group 如何将 EBS 连接到 ECS Fargate? - How do I connect EBS to ECS Fargate? 如何自动获取DNS ELB ELB AWS Cloud formation - how to get DNS ELB automatically ELB AWS Cloud formation 通过 Terraform 获取 AWS ELB 的所有托管区域 ID 的问题 - Issue to get all hosted zone id of AWS ELB through Terraform AWS ECS 任务定义:如何在另一个环境变量中引用一个环境变量? - AWS ECS Task Definition: How do I reference an environment variable in another environment variable? 如何诊断失败的 Azure 容器应用程序修订? - How do I diagnose a failed Azure Container App revision?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM