- Newest
- Most votes
- Most comments
The issue you're experiencing with intermittent "AbortedOrigin" errors and 502 status codes is not uncommon when dealing with CloudFront distributions connected to EC2 instances running web servers like Apache. The fact that increasing the keep-alive timeout settings has reduced the error rate supports your theory about a potential race condition in connection handling.
When CloudFront forwards requests to the origin, it attempts to maintain persistent connections to improve performance. However, if the keep-alive timeout is too short, CloudFront might try to use a connection that the origin server has already closed, resulting in the "AbortedOrigin" error.
Your approach of increasing the keep-alive timeout on both CloudFront (to 60 seconds) and Apache (to 100 seconds) is a good strategy. This allows more requests to reuse existing connections, reducing the likelihood of encountering the race condition.
To further optimize your setup, consider the following:
-
Ensure that the origin response timeout in CloudFront is set appropriately. The default is 30 seconds, but you can increase it up to 60 seconds if needed.
-
Monitor your origin's health and performance closely. Even though CPU and network usage are low, there might be other factors affecting response times.
-
If possible, implement health checks on your origin to ensure it's responding correctly.
-
Consider enabling origin keep-alive in CloudFront, which can help maintain persistent connections more effectively.
As for reporting a potential bug to AWS, the best approach is to contact AWS Support. If you have an Enterprise or Business support plan, you can open a technical support case directly. For other support plans, you can use the AWS forums or reach out to AWS on social media platforms. When reporting, provide detailed information about your setup, the error logs, and the steps you've taken to troubleshoot.
While your current configuration seems to have improved the situation, continue monitoring the error rate. If you still see occasional issues, it may be worth exploring other factors such as network connectivity between CloudFront and your origin, or potential limitations in your EC2 instance type.
Sources
Optimize high availability with CloudFront origin failover - Amazon CloudFront
HTTP 504 status code (Gateway Timeout) - Amazon CloudFront
Cloudfront timeout to Application Load Balancer | AWS re:Post
answered 2 years ago
Relevant content
asked 2 years ago

It almost sounds like it knows what its talking about! The only relevent discussion I found on the web is here: https://discuss.konghq.com/t/502-keepalive-connection-closed-aws-cloudfront-classic-lb-kong-k8s/7397