Performance guidelines for Amazon S3
When building applications that upload and retrieve objects from Amazon S3, follow our best practices guidelines to optimize performance. We also offer more detailed Performance design patterns for Amazon S3 .
To obtain the best performance for your application on Amazon S3, we recommend the following guidelines.
Topics
- Measure performance
- Scale storage connections horizontally
- Use byte-range fetches
- Retry requests for latency-sensitive applications
- Combine Amazon S3 (Storage) and Amazon EC2 (compute) in the same AWS Region
- Use Amazon S3 Transfer Acceleration to minimize latency caused by distance
- Use the latest version of the AWS SDKs
Measure performance
When optimizing performance, look at network throughput, CPU, and DRAM requirements. Depending on the mix of demands for these different resources, it might be worth evaluating different Amazon EC2 instance types. For more information about instance types, see Instance Types in the Amazon EC2 User Guide.
It’s also helpful to look at DNS lookup time, latency, and data transfer speed using HTTP analysis tools when measuring performance.
To understand the performance requirements and optimize the performance of your application, you can also monitor the 503 error responses that you receive.
Monitoring certain performance metrics may incur additional expenses. For more information, see Amazon S3 pricing
Monitor the number of 503 (Slow Down) status error responses
To monitor the number of 503 status error responses that you get, you can use one of the following options:
Use Amazon CloudWatch request metrics for Amazon S3. The CloudWatch request metrics include a metric for 5xx status responses. For more information about CloudWatch request metrics, see Monitoring metrics with Amazon CloudWatch.
Use the 503 (Service Unavailable) error count available in the advanced metrics section of Amazon S3 Storage Lens. For more information, see Using S3 Storage Lens metrics to improve performance.
Use Amazon S3 server access logging. With server access logging, you can filter and review all requests that receive 503 (Internal Error) responses. You can also use Amazon Athena to parse logs. For more information about server access logging, see Logging requests with server access logging.
By monitoring the number of HTTP 503 status error code, you can often gain valuable insights into which prefixes, keys, or buckets are getting the most throttling requests.
Scale storage connections horizontally
Spreading requests across many connections is a common design pattern to horizontally scale performance. When you build high performance applications, think of Amazon S3 as a very large distributed system, not as a single network endpoint like a traditional storage server. You can achieve the best performance by issuing multiple concurrent requests to Amazon S3. Spread these requests over separate connections to maximize the accessible bandwidth from Amazon S3. Amazon S3 doesn't have any limits for the number of connections made to your bucket.
Use byte-range fetches
Using the Range
HTTP header in a GET Object request, you can fetch a
byte-range from an object, transferring only the specified portion. You can use concurrent
connections to Amazon S3 to fetch different byte ranges from within the same object. This helps
you achieve higher aggregate throughput versus a single whole-object request. Fetching
smaller ranges of a large object also allows your application to improve retry times when
requests are interrupted. For more information, see Downloading objects.
Typical sizes for byte-range requests are 8 MB or 16 MB. If objects are PUT using a
multipart upload, it’s a good practice to GET them in the same part sizes (or at least
aligned to part boundaries) for best performance. GET requests can directly address
individual parts; for example, GET ?partNumber=N.
Retry requests for latency-sensitive applications
Aggressive timeouts and retries help drive consistent latency. Given the large scale of Amazon S3, if the first request is slow, a retried request is likely to take a different path and quickly succeed. The AWS SDKs have configurable timeout and retry values that you can tune to the tolerances of your specific application.
Combine Amazon S3 (Storage) and Amazon EC2 (compute) in the same AWS Region
Although S3 bucket names are globally unique, each bucket is stored in a Region that you select when you create the bucket. To learn more about bucket naming guidelines, see Buckets overview and Bucket naming rules. To optimize performance, we recommend that you access the bucket from Amazon EC2 instances in the same AWS Region when possible. This helps reduce network latency and data transfer costs.
For more information about data transfer costs, see Amazon S3 Pricing
Use Amazon S3 Transfer Acceleration to minimize latency caused by distance
Configuring fast, secure file transfers using Amazon S3 Transfer Acceleration manages fast, easy, and secure transfers of files over long geographic distances between the client and an S3 bucket. Transfer Acceleration takes advantage of the globally distributed edge locations in Amazon CloudFront. As the data arrives at an edge location, it is routed to Amazon S3 over an optimized network path. Transfer Acceleration is ideal for transferring gigabytes to terabytes of data regularly across continents. It's also useful for clients that upload to a centralized bucket from all over the world.
You can use the Amazon S3 Transfer Acceleration Speed comparison tool
Use the latest version of the AWS SDKs
The AWS SDKs provide built-in support for many of the recommended guidelines for optimizing Amazon S3 performance. The SDKs provide a simpler API for taking advantage of Amazon S3 from within an application and are regularly updated to follow the latest best practices. For example, the SDKs include logic to automatically retry requests on HTTP 503 errors and are investing in code to respond and adapt to slow connections.
The SDKs also provide the Transfer Manager, which automates horizontally scaling connections to achieve thousands of requests per second, using byte-range requests where appropriate. It’s important to use the latest version of the AWS SDKs to obtain the latest performance optimization features.
You can also optimize performance when you are using HTTP REST API requests. When using the REST API, you should follow the same best practices that are part of the SDKs. Allow for timeouts and retries on slow requests, and multiple connections to allow fetching of object data in parallel. For information about using the REST API, see the Amazon Simple Storage Service API Reference.