Skip to content

Cloudfront Multiple File download issue

0

I am facing an issue with downloading multiple files (3 to 4) through CloudFront. While we have increased the CloudFront response timeout to 180 seconds, it still results in a 504 error after the timeout period. Single file downloads are working fine, but the issue occurs when multiple files are downloaded simultaneously. Without Cloudfront it was working with elb after cloudfront implementation it is giving the error.

1 Answer
0

The issue you're experiencing with multiple file downloads through CloudFront resulting in 504 errors, despite increasing the response timeout, is likely related to how CloudFront interacts with your origin server (in this case, your Application Load Balancer or ELB).

Here are some potential reasons and solutions to consider:

  1. Origin server capacity: When multiple files are requested simultaneously, it may be overwhelming your origin server. Ensure that your ELB and backend instances can handle the concurrent requests efficiently.

  2. CloudFront to origin connection: CloudFront has a default timeout of 60 seconds for requests to origins, which can be extended up to 60 minutes for custom origins. However, when using an ALB as an origin, CloudFront doesn't automatically inherit the ALB's timeout settings. You may need to request a timeout increase from AWS Support specifically for your CloudFront to ALB connection.

  3. Keep-alive mechanism: Implement a client-side keep-alive mechanism to maintain the connection, periodically sending small requests to prevent the timeout.

  4. Optimize your application: Try to optimize your application to complete requests within the CloudFront timeout period. This might involve breaking down long-running operations into smaller chunks or implementing a polling mechanism.

  5. Use WebSockets: If your application supports it, WebSocket connections can be maintained for longer periods and might be suitable for long-running operations like multiple file downloads.

  6. Custom origin: Consider setting up a custom origin instead of using the ALB directly. This would allow you to configure longer timeouts (up to 60 minutes) directly in CloudFront.

  7. Lambda@Edge: You could implement a Lambda@Edge function to manage the routing and timing of requests, potentially breaking up the multiple file downloads into more manageable chunks.

  8. CloudFront configuration: Review your CloudFront distribution settings, particularly the origin connection timeout, connection attempts, and origin response timeout. Adjusting these settings might improve performance for multiple file downloads.

If these solutions don't resolve the issue, you may need to contact AWS Support for further assistance, as they can provide guidance specific to your setup and potentially increase timeouts beyond standard limits if necessary.

Sources
Cloudfront timeout to Application Load Balancer | AWS re:Post
CloudFront sometimes send delayed request to origin server. | AWS re:Post

answered 2 years ago

EXPERT

reviewed 2 years ago

  • I would like to highlight the following: 1.Origin server capacity is not the issue, as the requests are working fine when accessed without CloudFront. 2.CloudFront timeout settings have already been increased to 180 seconds, but it still results in a 504 error after the timeout period. 3. I have also applied the Keep-Alive header, but the issue still persists. Below points are code level or app level changes which is not feasible as it is already working through alb.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.