What is the fastest method of retrieving data from S3 on EC2 instances?

I’m already using extensive disk caching on NVMe instances, and CloudFront has a 70% hit rate. But inside the 30% non-cached requests where my application needs to fetch data from S3, 1-5 MB worth, it takes ~75% of the overall time from incoming request to data served.

Peak, sustained, throughput is 10 req/s (per VM) averaging 450ms responses.

My application is running on m5ad.xlarges right now, would a VM with more than “up to 10 Gbps” Ethernet make any difference? Is there an accelerated path to retrieving data from S3, or maybe some tricks/upgrades?

Thanks in advance!

Off the top of my head, are you using an S3 VPC endpoint? IIRC, those can reduce the latency a bit.

Also, would hosting the hosting the data on EFS be feasible? I think that’s a bit more performant than S3.

You can set max_concurrent_requests option to e.g 100 in awscli config file. You can also try to set S3 gateway endpoint for your network.

How large is the data set on s3?

100+ TB, I work for a video streaming platform

Make sure your app is streaming the data from S3 to the requester, and not downloading the object first and then only afterwards outputting it to the requester. This reduces your time to first byte.

I second the VPC endpoint. Don’t quote me on this but if I remember right requests from EC2 to S3 traverse the internet unless you use an endpoint. Using an endpoint makes traffic traverse the AWS backbone. I remember reading that from an AWS support doc that talked about securing S3, but I can’t seem to find it.

Not sure what your use case is but maybe take a look at ‘fsx for lustre’?

VPC endpoints and multi region access points or classic access points may help

Also, s3 key space are throttled at like 3k requests per second. You can partition your bucket using different keys so you increase the request rate

Consider testing minio with instance storage. We use it for anything requiring performance, and s3 for archive use cases.

Right now it’s set to 40, but I can always go full 100. Thanks for the suggestion.

Good suggestion, we’re already doing this!

fsx for lustre

Hadn’t seen this, I’ll have to see if it’s feasible and more performant. Thank you!

In 99% of cases you’re right, but we’re in a legally tight market and have to do things a certain way. Thanks for the suggestion!

if I remember right requests from EC2 to S3 traverse the internet unless you use an endpoint. Using an endpoint makes traffic traverse the AWS backbone.

This is what I was looking for, I think. I imagined it stayed internal, but if it doesn’t that’s going to add a lot of overhead.

S3 VPC endpoint

We are not, I’ll look into this!

That’s an interesting suggestion…I hadn’t considered a private S3 to outperform the broader S3, but it might.

“Up to 10 Gbps” is burst, baselines are listed here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/general-purpose-instances.html#general-purpose-network-performance

1.25Gbps for m5ad.xlarges. So it sounds like you’re not close to the baseline at peak throughput (measure this!). There is m6id(n) with more bandwidth but I guess it’s not what you need.

This doc: https://docs.aws.amazon.com/AmazonS3/latest/userguide/optimizing-performance.html
Links to these two docs:
https://docs.aws.amazon.com/AmazonS3/latest/userguide/optimizing-performance-guidelines.html
https://docs.aws.amazon.com/AmazonS3/latest/userguide/optimizing-performance-design-patterns.html

Which both offer similar guidelines for improving S3 performance. Given the following info:

  1. “5,500 GET/HEAD requests per second per partitioned prefix” ← this is maximum per-item in S3, you’re at 10 reqs/sec (though you mention per VM, how many total nodes are you using?)

I would suggest the following sections would likely be most useful for you:

  1. Use Byte-Range Fetches - parallelize requests to a single object, though you need to know the size of the object to start so you can slice it up
  2. S3 Transfer Acceleration - I’m not sure where you’re utilizing CloudFront in this situation, if it’s in front of your application, or you’re using it to cache between your app and S3.

I’d also ask if it’s possible to take your application out of the equation and have Cloudfront just cache S3 to your end-users directly. If your S3 data requires authorization, there’s still ways to do that, such as Lambda@Edge or have your app handle the auth.