简体   繁体   English

通过VPC后面的ALB请求Lambda极慢

[英]Requests to Lambda through ALB behind VPC are extremely slow

I am working on exposing a lambda to the public.net with the lambda residing behind an already existing VPC (so I can later on limit the IP range of incoming requests using a security group).我正在努力将 lambda 暴露给 public.net,其中 lambda 驻留在已经存在的 VPC 后面(因此我稍后可以使用安全组限制传入请求的 IP 范围)。

To test that everything works, I set up a small lambda that simply prints hello world.为了测试一切是否正常,我设置了一个小的 lambda,它只打印 hello world。 I am running into a problem where the connection is extremely slow.我遇到了连接速度极慢的问题。 The lambda executes in less than a milisecond, but each CURL to the endpoint run extremely slow. lambda 的执行时间不到一毫秒,但每个 CURL 到端点的运行速度都非常慢。

Using curl for diagnostics I have found that:使用 curl 进行诊断我发现:

curl -kso /dev/null my-alb-url -w "==============\n\n
| dnslookup: %{time_namelookup}\n
| connect: %{time_connect}\n
| appconnect: %{time_appconnect}\n
| pretransfer: %{time_pretransfer}\n
| starttransfer: %{time_starttransfer}\n
| total: %{time_total}\n
| size: %{size_download}\n
| HTTPCode=%{http_code}\n\n"
==============


| dnslookup: 0.061576

| connect: 75.256759

| appconnect: 0.000000

| pretransfer: 75.257615

| starttransfer: 75.794737

| total: 75.795154

| size: 28

| HTTPCode=200

The load balancer:负载均衡器:

  1. is connected to two availability zones that are both public facing连接到两个面向公众的可用性区域
  2. forward to a target group only containing my lambda转发到仅包含我的 lambda 的目标组
  3. is linked with a security group that has enabled all inbound and outbound traffic与已启用所有入站和出站流量的安全组链接

To make things more confusing, this is not an issue on every request but it is seemingly random.更令人困惑的是,这并不是每个请求都会出现的问题,但它似乎是随机的。

What would be the best way to debug this issue?调试此问题的最佳方法是什么?

I managed to resolve it but I am not entirely sure how.我设法解决了它,但我不完全确定如何解决。

I triple checked the su.net setup and just redid the setup again.我三次检查了 su.net 设置,然后再次重新设置。 10 minutes later and now it works as intended. 10 分钟后,现在它按预期工作。 My suspicion is that one of the AZs linked to the wrong su.net.我怀疑其中一个可用区链接到错误的 su.net。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM