Sub topic 5
Regions, durability and availability
This chapter explains where S3 data physically lives, what "eleven nines of durability" means, and how durability differs from availability. It assumes you have read the earlier chapters on buckets and objects and know the basics of HTTP status codes. It also assumes you can read short Python scripts.
Regions and Availability Zones
An AWS Region is a geographic area, such as eu-west-1 (Ireland) or us-east-1 (N. Virginia). Each Region contains several Availability Zones (AZs). An AZ is one or more data centers with independent power, cooling and networking. AZs in a Region are physically separate but connected by fast, low-latency links.
A bucket belongs to exactly one Region, which you choose when you create it. Objects in the bucket stay in that Region unless you copy or replicate them elsewhere. S3 does not move data between Regions on its own.
You do not choose an AZ for a bucket. S3 manages placement inside the Region for you. The one exception is the One Zone storage classes, covered below.
Choosing a Region
These factors usually decide the Region:
- Data residency and compliance. Laws or contracts may require data to stay in a country or economic area. This factor overrides the others.
- Latency. Put the bucket close to the users or compute that read it most. An EC2 instance in
eu-west-1reading from a bucket inap-southeast-2pays for the distance in every request. - Cost. Storage prices, request prices and data transfer prices differ between Regions. Data transfer between Regions is billed. Transfer from S3 to EC2 in the same Region is free.
- Feature and service availability. Newer features and storage classes can arrive in some Regions before others.
- Opt-in Regions. Some Regions, such as
af-south-1, are disabled by default. You must enable them in the account before creating resources there.
> Keep compute and data in the same Region unless you have a reason not to. Cross-Region reads add both latency and transfer charges.
Regions in practice
Requests are sent to a Regional endpoint such as s3.eu-west-1.amazonaws.com. The SDK and CLI pick the endpoint from the configured Region. If your client is configured for the wrong Region, you can see errors such as 301 PermanentRedirect or AuthorizationHeaderMalformed. The cause is a request signed for one Region and sent to a bucket in another.
You can ask S3 which Region a bucket is in. The HeadBucket response includes an x-amz-bucket-region header:
import boto3
s3 = boto3.client("s3")
bucket = "my-example-bucket-123456789012"
response = s3.head_bucket(Bucket=bucket)
headers = response["ResponseMetadata"]["HTTPHeaders"]
print(headers["x-amz-bucket-region"])get_bucket_location also exists, but it returns None for us-east-1, which surprises people. head_bucket avoids that special case.
Where an object physically lives
For S3 Standard, Standard-IA, Intelligent-Tiering and the Glacier classes other than One Zone-IA, S3 stores each object redundantly across at least three AZs in the Region. When you upload an object, S3 does not report success until the data is stored redundantly across those AZs.
The previous fence is intentionally not used. The diagram follows.
Because the data is spread across AZs, the loss of one AZ does not lose the object and does not stop reads. The Region as a whole is still a single failure domain for your bucket. If an entire Region is unavailable, so is the bucket. Surviving that needs replication to a second Region, which a later chapter covers.
Durability: not losing data
Durability is the probability that an object you stored is still intact when you read it later. S3 is designed for 99.999999999% (eleven nines) of durability over a year. AWS gives an example: if you store 10,000,000 objects, you can expect to lose a single object about once every 10,000 years.
Two points about this number:
- It is a design target for the service, not a contractual guarantee. The S3 service level agreement covers availability, not durability.
- It describes loss from hardware failure, corruption and AZ-level events. S3 keeps redundant copies, checks data with checksums, and repairs a copy when it detects damage.
What durability does not protect
Eleven nines applies to what S3 stores. It does not apply to what you ask S3 to do. S3 durably stores:
- An overwrite that replaced good data with bad data.
- A
DeleteObjectcall you made by mistake. - A lifecycle rule that expired objects you wanted to keep.
- A script that deleted a whole prefix.
In each case S3 faithfully does what it was told. Protection against these errors comes from other features:
| Risk | Mitigation | Covered in |
|---|---|---|
| Accidental overwrite or delete | Versioning | Versioning chapter |
| Malicious or bulk deletion | Versioning with MFA Delete, S3 Object Lock, tight IAM policies | Access control chapter |
| Loss of an entire Region | Cross-Region replication | Replication chapter |
| Loss of an account or credentials | Replication to a separate account | Replication chapter |
Availability: being able to read and write
Availability is the fraction of time S3 can serve your requests. An object can be durable and still temporarily unreachable, for example during a service disruption. Availability is a property of the storage class.
| Storage class | AZs used | Designed availability | SLA commitment |
|---|---|---|---|
| S3 Standard | 3 or more | 99.99% | 99.9% |
| S3 Standard-IA | 3 or more | 99.9% | 99% |
| S3 One Zone-IA | 1 | 99.5% | 99% |
The difference between 99.99% and 99.9% looks small. Over a year, 99.99% allows about 53 minutes of unavailability and 99.9% allows about 8.8 hours. The SLA figures are lower than the design figures because the SLA is what AWS pays service credits against.
One Zone classes
S3 One Zone-IA stores data in a single AZ. The data is still stored redundantly inside that AZ and has the same eleven-nines design target. The trade-off is that it cannot survive loss of the AZ itself. If the AZ is destroyed, for example by fire or flood, the data is lost. Use One Zone classes only for data you can recreate, such as thumbnails derived from originals, or for secondary copies.
Handling transient failures
Individual requests can fail even when the service is healthy overall. S3 can return 503 Slow Down when a prefix receives a very high request rate, and 500 Internal Error occasionally. S3 supports at least 3,500 write requests and 5,500 read requests per second per prefix, and spreading load across prefixes raises the total. A well-written client retries with exponential backoff. boto3 does this by default, and you can raise the attempt count:
import boto3
from botocore.config import Config
config = Config(
region_name="eu-west-1",
retries={"max_attempts": 10, "mode": "standard"},
)
s3 = boto3.client("s3", config=config)
response = s3.list_objects_v2(Bucket="my-example-bucket-123456789012", Prefix="reports/")
print(response["KeyCount"])This also pins the client to eu-west-1, so the request goes to the right Regional endpoint.
Common mistakes
- Treating eleven nines as backup. Durability does not replace versioning or replication. A deleted object is gone, durably.
- Assuming a bucket spans Regions. A bucket has one Region. Data in another Region means a second bucket and a replication or copy step.
- Choosing a Region by default. CLI profiles and SDKs often fall back to
us-east-1. Set the Region explicitly in configuration and in automation. - Using One Zone-IA for the only copy. If the data cannot be recreated, keep it in a multi-AZ class.
- Ignoring cross-Region costs. Data leaving a Region is billed per GB, so a design that reads from another Region on every request becomes expensive.
Exercise
A team stores customer invoices in S3 Standard in eu-west-1. An engineer runs a cleanup script with a wrong prefix and deletes 4,000 invoices. A colleague says the eleven nines of durability means the invoices can be recovered. Is the colleague right, and what should the team have enabled?
Show answer
The colleague is wrong. Durability covers loss from hardware failure and corruption, not deletes that a client requests. S3 durably removed the objects as instructed. Versioning would have kept earlier versions, so a delete only adds a delete marker that can be removed. Replication to another bucket, ideally in another account, and restrictive IAM permissions on delete would add further protection.
Exercise
You must store thumbnails that a batch job can regenerate from original images, and you want the lowest cost. Which of S3 Standard-IA and S3 One Zone-IA is appropriate, and what risk do you accept?
Show answer
S3 One Zone-IA is appropriate because the data can be recreated. The risk is that all copies sit in one Availability Zone, so losing that zone loses the thumbnails, and its designed availability (99.5%) is lower than Standard. The loss is acceptable because the batch job can regenerate the data.