title: S3 to EC2 transfer is too slow
body: <p>I'm trying to move a large file (~1.75GB) from S3 to EC2 instance in the same region.</p>
  
  <p>Via AWS command line I can do it in ~13 seconds.</p>
  
  <pre><code>aws s3 cp s3://mybucket/myfile.txt ~
  </code></pre>
  
  <p><code>wget</code> from the same EC2 instance (if I make the file public) does it in 34 seconds.</p>
  
  <pre><code>wget https://mybucket.s3.amazonaws.com/myfile.txt
  </code></pre>
  
  <p>My application via REST API can download it with the same speed as <code>wget</code>.</p>
  
  <p>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?</p>
  
  <p><strong>UPD:</strong> speedtest-cli shows 850Mbit/s.</p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>UPD2:</strong> <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking-ena.html" rel="noreferrer">Enhanced Networking</a> is enabled</p>
  
  <pre><code>[ec2-user@ip-172-30-0-196 ~]$ ethtool -i eth0
  driver: ena
  version: 2.0.2g
  </code></pre>
  
  <p><strong>UPD3:</strong> Tried couple of more instance types. Smallest/cheapest ARM a1.medium and i3en.6xlarge (I/O optimized, "guaranteed" 25Gbps)</p>
  
  <p><em>Time to copy 1.75GB file from S3 to EC2 instance in the same region:</em></p>
  
  <pre><code>|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 |
  </code></pre>
  
  <p>What's interesting - switching to IO - optimized instance improves the transfer speed, but it's still not anywhere near [file size]/[instance Gbps].</p>
  
  <p><strong>UPD4:</strong> AWS S3 configuration</p>
  
  <p>AWS S3 CLI tool offers few <a href="https://docs.aws.amazon.com/cli/latest/topic/s3-config.html#cli-aws-help-s3-config" rel="noreferrer">configurations options</a> such as:</p>
  
  <pre><code>aws configure set default.s3.max_concurrent_requests 10
  aws configure set default.s3.multipart_chunksize 8MB
  </code></pre>
  
  <p>Numbers above are defaults. After playing with these for a bit, the best combination I found for <code>m5a.2xlarge</code> 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.</p>