- Newest
- Most votes
- Most comments
When downloading large files using C++ aws::crt::http::httpclient and HTTP GET, there are several best practices to consider for a robust implementation:
-
Use byte-range requests: Instead of downloading the entire file in one request, split it into multiple smaller requests. This approach is particularly useful for large files (e.g., 60GB or more) as it can help maintain consistent bandwidth and improve retry capabilities if interruptions occur. Typically, byte-range sizes of 8-16 MB are recommended.
-
Implement parallel downloads: Use concurrent requests to download different byte ranges of the file simultaneously. This can significantly increase throughput. As a general guideline, make one concurrent request for each 85-90 MB/s of desired network throughput.
-
Handle timeouts and retries: While the SocketOptions ConnectTimeoutMs handles the initial connection, you should implement additional timeout mechanisms for the download process itself. This prevents the thread from hanging indefinitely if there's a network interruption. Implement a retry mechanism with exponential backoff for failed requests.
-
Error handling: Implement robust error handling to manage various scenarios such as network interruptions, HTTP errors, or unexpected responses. This includes handling partial downloads and resuming from where the download was interrupted.
-
Monitor and adjust performance: Start with a single request and gradually increase the number of concurrent requests while monitoring performance. Adjust based on your specific network conditions and requirements.
-
Consider using Transfer Acceleration: For geographically distant transfers, Amazon S3 Transfer Acceleration can help minimize latency and improve download speeds.
-
Implement checksum verification: After downloading, verify the integrity of the file using checksums to ensure the download was successful and complete.
While backpressure is more relevant for streaming applications, implementing a form of flow control in your application can help manage resource usage, especially when dealing with very large files or multiple concurrent downloads.
Regarding connection interruptions, while you're not using ChannelBootstrap, it's still important to implement a mechanism to detect and handle disconnections. This could involve setting read timeouts on the HTTP client and implementing a reconnection strategy.
Even though your current implementation is working fine for 100 MB files, these practices will make your system more robust and scalable, especially when dealing with larger files or less stable network conditions.
Sources
Horizontal Scaling and Request Parallelization for High Throughput - Best Practices Design Patterns: Optimizing Amazon S3 Performance
Use Byte-Range Fetches - Best Practices Design Patterns: Optimizing Amazon S3 Performance
Download bandwidth | AWS re:Post
Performance design patterns for Amazon S3 - Amazon Simple Storage Service
Relevant content
asked 4 years ago
asked 5 years ago
asked 4 years ago
- AWS OFFICIALUpdated 4 months ago
