Torn reads per publishing method: overwrite 26 of 44, parallel overwrite 3 of 22, copy 8 of 37, pointer 0 of 36

You ship a new version of a site, a model or a data set by uploading ten files into a bucket. Between the first file and the tenth, a reader can fetch some from the old release and some from the new one: a page that points at a stylesheet that is not there yet, a data file with a manifest that does not match it. Object stores do not have a transaction for ten files. So how bad is the gap, and what closes it?

We published release 2 over release 1 (and 3 over 2, up to 6) five different ways on tport.space while three readers kept fetching all ten files. A round counts as torn when the ten files disagree about the release.

How the test worked

  • Ten small files per release (asset-00.txt to asset-09.txt), each containing its release number. A reader round fetches all ten at once over presigned links, then waits 0.15 s.
  • Three readers ran the whole time; the publisher swapped the release five times per method with 2 s between swaps. About 190 reader rounds and 1,900 file reads in total, so read the percentages as rough, not as precise rates.
  • Overwrite: PUT each file in place, one at a time or ten in parallel. Stage and copy: upload to a staging prefix, then CopyObject each file onto the live key, one at a time or ten in parallel. Pointer: upload to a new folder (r2/), then PUT one small current object that names it; readers read the pointer first, then the files in that folder.
  • Run on 2026-11-16 from a Mac with boto3 1.44.3 and requests, against a private test bucket that was deleted afterwards.

The results

MethodMedian time to publishReader roundsTorn roundsShare torn
Overwrite in place, one by one3.61 s442659%
Overwrite in place, ten at once0.43 s22314%
Stage, then CopyObject one by one5.35 s511733%
Stage, then CopyObject ten at once2.82 s37822%
New folder, then switch one pointer2.96 s3600%
  • Every in-place method tore reads. Copying from a staging prefix did not fix it: the live keys still change one after another. (The publish time of the stage methods includes uploading to staging; only the copy phase is visible to readers.)
  • The pointer switch tore none in 36 rounds, 396 reads, because readers only ever follow the pointer to a folder that was complete before it was named.
  • Shorter is better, not safe. Ten parallel overwrites took 0.43 s and still tore 3 of 22 rounds.

A quick check of the numbers

A reader can be caught mid-publish for as long as the publish takes. Overwriting one by one took a median 3.61 s and we swapped every 3.61 + 2 = 5.61 s, so about 64% of the time the set was half old, half new. We measured 59% torn rounds (26 of 44). Ten at once: 0.43 / (0.43 + 2) = 18% predicted, 14% measured (3 of 22). The tear rate is the publish window divided by the interval, so the only way to get to zero is a window of zero: one object changes.

One object is atomic

Overwriting a single 8 MiB object (all A to all B and back, 6 times) while three readers fetched it gave 11 complete reads: 6 all-A, 5 all-B, 0 mixed, 0 short. Nobody saw half an object. That is the property the pointer pattern uses: the only thing that changes in place is one small object.

We also looked for stale reads: reads that started within 1.5 s after a publish returned and still saw the old release. There were none in any method, so on this test a PUT that has returned was visible to the next read. Five publishes per method is a small sample, so repeat it before relying on it for something critical.

The pointer pattern, step by step

  • Upload every file of release N to its own prefix, for example releases/N/. Nobody reads it yet.
  • Check it is complete (list the prefix and compare the count or a manifest).
  • PUT one small object, current, containing N. That is the whole switch.
  • Roll back by writing the old N again. Delete old releases later, for example with a lifecycle rule on releases/.
python
import boto3

s3 = boto3.client("s3", endpoint_url="https://s3.tport.space")

def publish(bucket, release, files):
    for name, body in files.items():
        s3.put_object(Bucket=bucket, Key=f"releases/{release}/{name}", Body=body)
    # the only in-place write: one small object
    s3.put_object(Bucket=bucket, Key="current", Body=str(release).encode(),
                  CacheControl="no-cache")

def read(bucket, name):
    release = s3.get_object(Bucket=bucket, Key="current")["Body"].read().decode()
    return s3.get_object(Bucket=bucket, Key=f"releases/{release}/{name}")["Body"].read()
  • Cost: one extra small read per page load, which you can cache for a few seconds, and old releases that need cleaning up.
  • A public static site cannot follow a pointer by itself. Do the same with one object: give every asset a hashed name (see static asset versioning), upload all of them first, and replace index.html last. index.html is then the pointer.
  • Two publishers at once? Make the pointer write conditional; conditional writes with If-Match were tested separately.
  • Serving the site from a bucket is covered in hosting a static site from a bucket.

S3-compatible buckets with no egress fees: publish a release with one small write.

Explore tport.space

Test record and sources

  • Run on 2026-11-16 against s3.tport.space (path style), boto3 1.44.3, three reader threads, ten files per release, five publishes per method, a private bucket removed afterwards. Raw counts are in the table; the script is not published.
  • Results describe tport.space on that date and a small sample; we did not test other providers.
  • Background: the S3 API replaces an object as a whole on PUT and CopyObject; there is no multi-object transaction.