Can a bucket be your system of record? The answer depends on which failure you are worried about. Eleven nines of durability answers "will the bytes survive hardware loss?" It says nothing about two writers racing on one key, or a job that overwrites last night's good file with tonight's bad one. This guide separates those failures and maps each to an S3 control, based on AWS documentation.
Four questions decide it, and durability answers only one
Before choosing S3 over a database, ask:
- Will stored bytes survive infrastructure failure? The durability question.
- Will a reader see the latest write? The consistency question.
- When two writers collide, who wins, and does the loser find out? The concurrency question.
- Can a person or a buggy job destroy good data, and can it be recovered? The retention question.
S3 answers the first two by default. The last two are answered only if you configure or code for them. That gap is why "S3 is a database" is an illusion, even though S3 is a very good place to keep data.
Eleven nines protects against the platform, not against you
AWS describes S3 as designed for 99.999999999% (11 nines) of data durability, and its FAQ lists versioning, replication and Object Lock as optional features that add protection beyond that. The word "optional" matters. For a pipeline or a service, the failure that matters is rarely a lost disk. It is an authorized job doing the wrong thing with valid credentials. If an IAM role can PutObject over a key, S3 will faithfully and durably store the wrong content.
Strong consistency tells you what a read sees, not which write wins
The consistency story is good. S3 provides strong read-after-write consistency for PUT and DELETE requests in all Regions, and list operations are strongly consistent too, so a listing right after a write reflects it. That removed a whole class of older workarounds built to bolt consistency onto big data workloads.
But consistency is not coordination. For simultaneous writes to the same key, S3 uses last-writer-wins semantics: the request with the latest timestamp wins. A write to a single key is atomic, so a concurrent read returns either the old or the new object, never a partial one. Two limits follow from the documentation:
- Bucket configuration is eventually consistent. Do not assume a policy or lifecycle change takes effect instantly.
- The atomic unit is one key. S3 has no multi-object transactions. Anything that spans several objects, such as a data file plus the manifest that describes it, needs a commit protocol you design yourself.
Conditional writes turn last-writer-wins into a decision you make
S3 supports preconditions on writes through the If-None-Match and If-Match headers. They cover two patterns:
- Create-once.
If-None-Match: *succeeds only if the key does not already exist. This suits "this batch output must exist exactly once". - Compare-and-swap.
If-Matchuploads only if the ETag you supply matches the object's current ETag. This suits a small shared state object, such as a cursor or registry file, that several workers update.
The create-once form is a single CLI call:
aws s3api put-object \
--bucket amzn-s3-demo-bucket \
--key batches/2026-11-12/output.parquet \
--body output.parquet \
--if-none-match "*"
If the key exists, S3 returns 412 Precondition Failed. A rerun that hits 412 should read it as "already done" and stop, not retry. This is the idempotency discipline of any pipeline rerun, enforced by the store instead of by convention.
A second error needs separate handling. If a conflicting operation is in flight, S3 returns 409 ConditionalRequestConflict, and for If-Match the documented next step is to fetch the object's ETag again and retry. A compare-and-swap loop therefore treats the two codes differently:
- Read the object and keep its ETag.
- Compute the new content.
- Write with
If-Matchset to that ETag. - On 412, someone else changed the object. Re-read and recompute.
- On 409, a write was in flight. Re-fetch the ETag and retry, with a bounded number of attempts.
One permission detail is easy to miss: a role using If-Match needs s3:GetObject as well as s3:PutObject. A write-only role that works for plain puts can fail once the header is added.
Make the header mandatory, or the guarantee is only a convention
A conditional write helps only if every writer uses it, because a script that sends a plain PutObject bypasses the whole scheme. S3 can enforce it: the condition keys s3:if-match and s3:if-none-match can be used in a bucket policy. The following deny statement for a create-once prefix is adapted from the pattern in the S3 documentation on enforcing conditional writes, so test it in a sandbox before applying it:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "RequireIfNoneMatchOnBatches",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::amzn-s3-demo-bucket/batches/*",
"Condition": {
"Null": { "s3:if-none-match": "true" },
"Bool": { "s3:ObjectCreationOperation": "true" }
}
}
]
}
The Null condition matches when the header is absent. The s3:ObjectCreationOperation condition is essential: multipart uploads call CreateMultipartUpload, UploadPart and UploadPartCopy, which do not accept conditional headers, so without that exemption the policy would block large uploads. Only the final CompleteMultipartUpload carries the header.
Enforcement moves a team convention into the platform, and it has costs:
- Every legitimate writer on that prefix must send the header, including backfill scripts and tools, so audit them first.
- A deny applies to every principal it names, including administrators, so plan how you perform maintenance on that prefix.
- Copy operations into a bucket or prefix with an enforcing policy do not work. A
CopyObjectwithout the header fails with403 Access Denied, and one with the header fails with501 Not Implemented, so copy-based jobs need a different path.
Versioning and Object Lock cover the mistake you have not made yet
Conditional writes stop collisions. They do not undo a bad but valid write. The controls for that are versioning and Object Lock. With versioning on, S3 keeps every version, including the results of simultaneous writes, so a clobbered file can be recovered. Object Lock goes further and prevents an object version from being deleted or overwritten for a retention period you define, or indefinitely.
Both cost something. Versioning keeps old versions, which means storage you pay for and a recovery procedure you need to have tested. Object Lock is aimed at write-once-read-many (WORM) requirements, and an immutable object you wrote incorrectly is also immutable. Use it on the committed outputs of a pipeline, not on scratch prefixes.
Failure modes mapped to controls
| Failure | Control | Remaining gap |
|---|---|---|
| Hardware loss | 11 nines durability (default) | Does not cover human or job error |
| Stale read | Strong read-after-write consistency (default) | Bucket configuration changes are eventually consistent |
| Two writers on one key | If-None-Match or If-Match | Only protects writers that send the header |
| Writers that skip the header | Bucket policy enforcement | Breaks copies and unaudited writers |
| Valid but wrong overwrite | Versioning | Restore must be rehearsed |
| Deletion or overwrite of committed data | Object Lock | Immutable mistakes stay immutable |
| Multi-object commit | Your own protocol, for example a manifest written last | No transactions across keys |
A checklist before a bucket becomes the source of truth
- Name the unit of atomicity. If a logical commit spans several objects, decide which single object (a manifest, for example) marks it complete.
- Use
If-None-Match: *for outputs that must exist once, and treat 412 as "already happened". - Use
If-Matchloops for shared state objects, with distinct handling for 412 and 409 and a retry cap. - Grant
s3:GetObjectalongsides3:PutObjectto roles that useIf-Match. - Enforce the headers with a bucket policy on the prefixes that need them, after auditing every writer and exempting the multipart operations.
- Turn on versioning and rehearse a restore from a prior version before you need one.
- Decide per prefix whether Object Lock's immutability is worth its inflexibility.
Where to stay cautious
S3 has no query engine or secondary indexes. If the access pattern is "find records by attribute", a bucket alone is the wrong shape, and a warehouse or a table format over the bucket belongs in the design. Everything above also describes Amazon S3 specifically. S3-compatible stores differ in how they handle conditional headers and concurrent writes, so if you are not on AWS, test concurrent writers rather than assuming parity.
A qualified recommendation: use S3 as the system of record when your data is naturally immutable objects or batches, and wrap it with create-once or compare-and-swap semantics, versioning and enforced headers. Reach for a database when you need multi-record transactions or attribute lookups. In both cases, check current behavior in the AWS documentation before you build on it.
Comments
Post a Comment