- Newest
- Most votes
- Most comments
It's possible you have:
- A load balancer with cross-zone load balancing switched off (for NLB & GLB it's off by default)
- Not all of your load balancer's AZs with a valid working target.
So some requests would succeed and some fail.
Hello Yuri,
An additional component to check is the healthcheck around your target groups/instances. It could be possible that no healthy instances for your HTTPS target group could be found.
You should be able to check the health status under "target groups" in the AWS console.
Below is some additional documentation from AWS around these health checks.
https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html
I am experiencing the same with my load balancer. It sometimes gives a 504, and sometimes not.
This seems to happen only with instances outside the load balancer's VPC, that are specified by their internal IP. The health check is working fine, the instances are healthy all the time.
我遇到的情況是 使用nlb+ec2(container on 3000)進行流量管理,nlb對外主要使用的port是444port,且我的ec2的health check完全沒有問題。最後發現是因為我的Cross-Zone Load Balancing沒有打開,且我選擇了兩個不同az的public subnet,但只有其中一個az上有ec2+app在運行,再加上公司的ip是在幾個之間輪流替換(搭配上nlb的ip hash的流量分配規則),所以導致我有時能成功與我的後端互動,有的時候又完全沒有反應。
解決方法: 把所有有選到的subnet上都開好ec2並運行app,或是開啟Cross-Zone Load Balancing
The situation I encountered is I use nlb+ec2 (container on 3000) for traffic management. The main port used by nlb for external communication is port 444, and there is no problem with the health check of my ec2. Finally I found out that it was because my Cross-Zone Load Balancing was not turned on, and I selected two public subnets of different az, but only one of the az had ec2+app running, and the company's IP was rotated between several (combined with the traffic distribution rules of nlb's IP hash), so sometimes I could successfully interact with my backend, and sometimes there was no response at all.
Solution: Open EC2 on all selected subnets and run the app, or enable Cross-Zone Load Balancing
Relevant content
- asked 4 years ago

How can I check this?
Settings in the Load Balancer console, CloudWatch metrics and Load Balancer logging.