Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

S3 to EC2 transfer is too slow

I'm trying to move a large file (~1.75GB) from S3 to EC2 instance in the same region.

Via AWS command line I can do it in ~13 seconds.

aws s3 cp s3://mybucket/myfile.txt ~

wget from the same EC2 instance (if I make the file public) does it in 34 seconds.

wget https://mybucket.s3.amazonaws.com/myfile.txt

My application via REST API can download it with the same speed as wget.

The instance is m5a.2xlarge which should have "Up to 10 Gbps" network. If my math is right 10Gbps should be around 1 gigabyte per second, so under 2 seconds to get the file?

UPD: speedtest-cli shows 850Mbit/s.

Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by BroadAspect (Ashburn, VA) [0.98 km]: 1.387 ms
Testing download speed................................................................................
Download: 850.94 Mbit/s
Testing upload speed......................................................................................................
Upload: 929.41 Mbit/s

UPD2: Enhanced Networking is enabled

[ec2-user@ip-172-30-0-196 ~]$ ethtool -i eth0
driver: ena
version: 2.0.2g

UPD3: Tried couple of more instance types. Smallest/cheapest ARM a1.medium and i3en.6xlarge (I/O optimized, "guaranteed" 25Gbps)

Time to copy 1.75GB file from S3 to EC2 instance in the same region:

|instance type|Network Gbps|aws s3 cp|wget|
|-------------|------------|---------|----|
|m5a.2xlarge  |  Up to 10  |   13    | 34 |
|a1.medium    |  Up to 10  |   26    | 34 |
|i3en.6xlarge |     25     |   7.5   | 18 |

What's interesting - switching to IO - optimized instance improves the transfer speed, but it's still not anywhere near [file size]/[instance Gbps].

UPD4: AWS S3 configuration

AWS S3 CLI tool offers few configurations options such as:

aws configure set default.s3.max_concurrent_requests 10
aws configure set default.s3.multipart_chunksize 8MB

Numbers above are defaults. After playing with these for a bit, the best combination I found for m5a.2xlarge is 3 concurrent requests, 180MB chunk size. That brings the download time down to 9 seconds or ~204MiB/sec. Better, but still quite far from (theoretical?) maximum.

like image 753
Anton Avatar asked Jul 02 '19 21:07

Anton


People also ask

Why is downloading from S3 so slow?

Large object size For very large Amazon S3 objects, you might notice slow download times as your web browser tries to download the entire object. Instead, try downloading large objects with a ranged GET request using the Amazon S3 API.

Which of the below does S3 transfer acceleration use to get your data into aws quicker?

Amazon S3 Transfer Acceleration – This new feature accelerates Amazon S3 data transfers by making use of optimized network protocols and the AWS edge infrastructure. Improvements are typically in the range of 50% to 500% for cross-country transfer of larger objects, but can go ever higher under certain conditions.


1 Answers

Having 10Gbps doesn't guarantee that the other end is sending data to you at that speed.

Prior to current-generation EC2 instance types configured with ENA, which support up to 25 Gbps to S3, the maximum was 5 Gbps.

You could do a couple of additional tests, for example EC2 to EC2 or EC2 to speedtest.net (or equivalent).

By the way, if you genuinely are downloading a 1.75GB text file then compression would help.

like image 162
jarmod Avatar answered Oct 19 '22 00:10

jarmod