Skip to content
Stribog

Storage

All writing

Object Storage vs File System: When Each Is the Wrong Choice

Object storage vs file system is a semantics decision: core S3 has no atomic rename, append or writer lock, and NFS weakens locks. Choose per workload.

By 13 min read

A team moves a service off a hyperscaler and onto its own hardware. The plan: everything that sat on a shared volume goes into an S3-compatible bucket, because object storage is the cheap tier and the cluster already runs one. A FUSE mount papers over the difference. Weeks later, a nightly job that wrote a temporary file and renamed it into place starts producing half-visible results, a log shipper that appended to a file throws I/O errors, and an embedded database that someone parked on the mount corrupts itself. None is a storage-engine bug. Each is the application relying on a guarantee the new interface never made.

The comparison everyone writes, and the one that costs money

The standard comparison of object storage vs file storage covers namespace shape (flat keys against a directory tree), metadata (rich per-object headers against inode attributes) and scale (billions of objects against a filesystem's metadata server). It is accurate as far as it goes. It just does not predict any of the failures above.

What predicts them is the list of primitives the code silently assumes. Does it overwrite bytes in the middle of a file? Append to the end? Commit work by renaming a temporary file over the final name? Take a lock so two writers cannot interleave? Call fsync and trust that the bytes are on stable storage when it returns? Each of those is a promise a POSIX filesystem makes and the S3 API does not — and, going the other way, the object API has its own promises (whole-object atomicity, conditional creation, HTTP reach) that a shared filesystem delivers badly. The money is lost in the mismatch, not in the per-terabyte price.

What an object store actually promises

The S3 API has a precise contract, and it is worth stating it the way AWS documents it for its own service, because every S3-compatible engine is measured against that document and none is obliged to match it exactly. Amazon S3 provides strong read-after-write consistency for PUT and DELETE of objects in all AWS Regions. Updates to a single key are atomic: a reader racing a writer gets either the old object or the new one, never a partial or corrupt one.

The same page states the limits just as plainly. S3 does not support locking for concurrent writers; if two PUTs to the same key arrive together, the one with the latest timestamp wins. Updates are key-based, and there is no way to make an atomic update across keys. Outside AWS's S3 Express One Zone storage class — the only place Mountpoint, below, can append or rename atomically — there is no rename and no append, and no way to change bytes in the middle of an object: a "modify" is a full replacement. Large objects are assembled with multipart upload, which AWS caps at 10,000 parts of 5 MiB to 5 GiB each, with no minimum on the last part.

One primitive was added that changes what an object store can coordinate. With a conditional write, If-None-Match: * makes a PUT succeed with 200 OK only if no object with that key exists; otherwise it fails with 412 Precondition Failed. When several conditional writes race for the same key, the first to finish succeeds. AWS also documents a 409 Conflict when a delete of the object succeeds before a conditional write to it completes. That is a real put-if-absent: enough to let exactly one writer claim a name.

What a filesystem promises, and where network filesystems weaken it

A local POSIX filesystem gives applications the primitives they have relied on for decades: write at any offset, append, rename a file over another in one step, take advisory locks, and fsync a file and its directory so a crash cannot undo a commit. Rename-as-commit is the pattern most software uses without naming it — write a temporary file, flush it, rename it over the real name — and readers see either the old file or the new one.

Put the filesystem behind a network and the same calls still succeed, but some guarantees soften. SQLite's documentation is blunt about it: SQLite relies on exclusive locks for writes, those have been known to operate incorrectly on some network filesystems, and that has led to database corruption. Its corruption guide adds that some filesystems have bugs in their locking logic, "especially true of network filesystems and NFS in particular."

PostgreSQL supports NFS, with conditions its documentation spells out. The only firm requirement is a hard mount — and with hard, processes can hang indefinitely on network problems, so the setup needs careful monitoring. The sync mount option is not required, but the sync export option on the server is strongly recommended: without it, an fsync on the client is not guaranteed to reach permanent storage on the server, which can cause corruption similar to running with fsync off.

text
# NFS server, /etc/exports — sync export, so a client fsync reaches disk
/srv/pgdata  <CLIENT_SUBNET>(rw,sync,no_subtree_check)

# PostgreSQL host, /etc/fstab — hard mount (the one firm requirement)
<NFS_SERVER>:/srv/pgdata  /var/lib/postgresql  nfs  hard,vers=4.2  0  0
Excerpt: the two lines PostgreSQL's NFS guidance turns into. Substitute your server, path and client subnet for the placeholders.

CephFS sits closer to local semantics. Its POSIX page says it aims to adhere to POSIX wherever possible and relaxes strictly less than NFS on multi-client consistency. When clients on several hosts have a file open and at least one is writing, caching stops, so a read on any host returns the data of a write(2) that has returned on another host, whether or not the writer called fsync; shared writable mmap and LazyIO are the named exceptions. The same page is honest about the edge: in shared simultaneous-writer situations, a write that crosses object boundaries is not necessarily atomic.

Five ways a filesystem workload breaks on an S3 endpoint

FUSE clients make a bucket look like a directory, so the application keeps its assumptions. The two most-used clients document exactly where the illusion ends. s3fs-fuse lists random writes or appends requiring a rewrite of the entire object, slow directory listing because of network latency, no atomic renames of files or directories, no coordination between multiple clients mounting the same bucket, and no hard links. Mountpoint for Amazon S3's semantics document is narrower and stricter. Those limits come from the S3 API's shape, so they describe what any S3 backend looks like through these clients; timings such as listing speed will differ on a self-hosted endpoint.

  1. Random and in-place writes. Under Mountpoint, all writes must be sequential; a write after seeking anywhere other than the end of the previous write fails. Overwriting an existing file needs the --allow-overwrite flag and an O_TRUNC open, and the rewrite still starts at offset zero. Under s3fs the write succeeds, but by rewriting the whole object — fine for a config file, ruinous for a large file updated in small pieces.
  2. Appends. Mountpoint supports appending only for S3 Express One Zone objects, with --incremental-upload set. Everywhere else, the log shipper's O_APPEND fails under Mountpoint or, through s3fs, rewrites the entire object.
  3. Rename as commit. Mountpoint does not support directory rename on any S3 bucket type and supports atomic file rename only on S3 Express One Zone. s3fs documents no atomic renames of files or directories. The "write a temp file, rename it into place" commit stops being a commit.
  4. Directory operations. s3fs documents metadata operations such as directory listing as slow because of network latency, even with its metadata cache. Tree-walking and polling tools pay on every pass.
  5. Multiple writers. With no coordination between clients and last-writer-wins on the server, two processes writing the same path silently overwrite each other. Mountpoint also has no hard or symbolic links, which breaks the tools that use links for atomic swaps.

The analytics ecosystem learned this the hard way and wrote it down. Hadoop's S3A connector docs (the "stable" page, versioned 3.3.5 and published in 2023) state that S3 has relaxed some of the constraints classic POSIX filesystems promise, that directory renames are not atomic and can fail partway through, and that callers cannot safely rely on atomic renames as part of a commit algorithm. The time to rename a directory is proportional to the number and size of the files beneath it. Delta Lake's storage documentation makes the same point from the table-format side: only one writer must be able to create a file at the final destination, S3 does not provide that mutual exclusion, and its multi-cluster S3 mode — labelled experimental — uses DynamoDB to supply it. That page does not discuss S3 conditional writes, so do not read it as saying Delta has adopted them.

The lesson is not "never use object storage for analytics". It is that a correct commit protocol on S3 has to be designed for S3 — an external lock, or put-if-absent on one manifest key — not inherited from a filesystem through a mount.

The cases where file storage is the wrong answer

The reverse mistake is less discussed. Build artefacts, backups, log archives, ML training sets and media files share a shape: written once as a whole, never modified, read by many consumers, often from outside the cluster. None of them needs rename, append or locks. A shared filesystem buys semantics they never use, at a cost that grows with the fleet.

  • Contention on metadata. Every reader of a shared filesystem goes through the same metadata path to open, stat and list. A many-reader dataset turns that path into the bottleneck; an object store serves each GET independently.
  • The single server as a failure domain. A plain NFS export is one server. When it stops, every mount stalls — and with the hard mounts databases require, the processes behind those mounts hang rather than fail.
  • Reach. A filesystem needs a mount, a kernel client and a network path to the storage. An object is an HTTPS URL that a CI runner, a CDN origin or a partner can fetch with a scoped credential.
  • Retention evidence. Object versioning and Object Lock give write-once retention at the API, which is the property backups need; how to use it well is covered in immutable backups with Object Lock.

If the workload's natural unit is a whole file written once, object storage is not the cheap compromise. It is the correct contract, and the filesystem is the compromise.

Classify the workload by the primitive it needs

Read the code, not the diagram. grep for rename, O_APPEND, flock, fcntl, fsync and mmap, and look at how the application commits work. The answers route it to one of three interfaces. This is also where block storage vs object storage gets decided: block is the right answer when a single writer needs a private, local-semantics filesystem underneath — the database case.

Route by the primitive the code relies on. The wrong edge does not error at deploy time; it fails under load or at the first crash.
  • Block (RBD, one writer): relational databases, embedded databases such as SQLite, message-broker logs, anything that does random writes and trusts fsync. One pod, one volume.
  • File (CephFS, NFS): shared home directories, legacy applications that rename-commit or append, CMS upload directories, build caches shared between pods. Several writers, POSIX calls.
  • Object (S3 API): artefacts, backups, archives, datasets, media, table formats with an S3-aware commit protocol. Whole-object writes, many readers, HTTP reach.

Before committing a workload to an object store that has to coordinate writers, probe the engine for put-if-absent rather than trusting its compatibility matrix. The script below issues two conditional PUTs on one key with the AWS CLI; the second must be rejected.

bash
#!/usr/bin/env bash
# Does this S3-compatible endpoint honour put-if-absent (If-None-Match: *)?
set -euo pipefail

ENDPOINT="${S3_ENDPOINT:-http://localhost:8333}"
BUCKET="${S3_BUCKET:-probe}"
KEY="probe/put-if-absent-$(date +%s)"
BODY="$(mktemp)"
trap 'rm -f "$BODY"' EXIT
echo "probe" > "$BODY"

put() {
  aws s3api put-object --endpoint-url "$ENDPOINT" --bucket "$BUCKET" \
    --key "$KEY" --body "$BODY" --if-none-match '*' 2>&1
}

if ! out=$(put); then
  echo "FAIL: first conditional PUT rejected:"
  echo "$out"
  exit 1
fi

if out=$(put); then
  echo "UNSAFE: second PUT succeeded; the header was ignored"
  exit 2
fi

case "$out" in
  *PreconditionFailed*|*412*) echo "OK: 412, put-if-absent honoured" ;;
  *Conflict*|*409*) echo "RETRY: 409 conflict, rerun the probe" ;;
  *) echo "UNKNOWN rejection:"; echo "$out"; exit 3 ;;
esac
Probe an S3-compatible endpoint for If-None-Match support. Set S3_ENDPOINT and S3_BUCKET; needs AWS CLI v2 and credentials for the endpoint.

The commit pattern itself differs between the two worlds. On a local filesystem, it is temp file, fsync, os.replace, then fsync of the directory so the rename survives a crash. On S3, there is nothing to rename: write the final key once, conditionally. Only a 412 means someone else committed first. A 409 is the conflicting in-flight operation described above, such as a delete landing before the conditional PUT completes; AWS says to retry the PUT, as the probe does.

python
#!/usr/bin/env python3
"""Commit a file once: POSIX rename-as-commit vs S3 put-if-absent."""
import argparse
import os
import tempfile
import time


def posix_commit(path: str, data: bytes) -> bool:
    directory = os.path.dirname(os.path.abspath(path))
    fd, tmp = tempfile.mkstemp(dir=directory, prefix=".tmp-")
    try:
        with os.fdopen(fd, "wb") as f:
            f.write(data)
            f.flush()
            os.fsync(f.fileno())
        os.replace(tmp, path)  # readers see old or new, never partial
    except BaseException:
        if os.path.exists(tmp):
            os.unlink(tmp)
        raise
    dfd = os.open(directory, os.O_RDONLY)
    try:
        os.fsync(dfd)  # make the rename itself durable
    finally:
        os.close(dfd)
    return True


def s3_commit(
    endpoint: str, bucket: str, key: str, data: bytes, attempts: int = 4
) -> bool:
    import boto3
    from botocore.exceptions import ClientError

    s3 = boto3.client("s3", endpoint_url=endpoint)
    for attempt in range(attempts):
        try:
            s3.put_object(Bucket=bucket, Key=key, Body=data, IfNoneMatch="*")
            return True
        except ClientError as err:
            status = err.response["ResponseMetadata"]["HTTPStatusCode"]
            if status == 412:
                return False  # another writer committed this key first
            if status == 409 and attempt + 1 < attempts:
                time.sleep(2**attempt)  # in-flight conflict: retry the PUT
                continue
            raise
    raise RuntimeError("unreachable")


def main() -> None:
    p = argparse.ArgumentParser(description=__doc__)
    p.add_argument("target", help="file path, or S3 key with --bucket")
    p.add_argument("--bucket")
    p.add_argument("--endpoint", default=os.environ.get("S3_ENDPOINT"))
    args = p.parse_args()
    data = b"committed\n"
    if args.bucket:
        ok = s3_commit(args.endpoint, args.bucket, args.target, data)
    else:
        ok = posix_commit(args.target, data)
    print("committed" if ok else "lost the race")


if __name__ == "__main__":
    main()
The same commit, two contracts. The S3 path needs boto3 and an endpoint that honours IfNoneMatch.

One cluster, three interfaces: Ceph and SeaweedFS on owned hardware

On a hyperscaler, file and object are separate products with separate bills, so the decision feels like a platform choice. On owned hardware it usually is not. A single Ceph cluster serves RBD block devices, the CephFS filesystem and the RGW object gateway — which Ceph documents as an object interface built on librados — from one RADOS cluster. SeaweedFS's README describes one cluster serving an S3 object store and a file system, with the same data reachable as a FUSE mount and over WebDAV, SFTP, HDFS and HTTP. The README calls the filer a POSIX file system; treat how much of POSIX the FUSE mount covers as something to test against your workload, not a checkbox.

On owned hardware the interfaces sit side by side on one cluster. The choice is per workload, so make it per workload.

Kubernetes makes the routing explicit through access modes. ReadWriteMany lets many nodes mount a volume read-write — the CephFS case. ReadWriteOnce is per node, and can still let several pods on that node write the same volume. ReadWriteOncePod, stable since v1.29 and supported only for CSI volumes, restricts read-write access to a single pod across the whole cluster — the guarantee a database actually wants. The block-storage comparison covers which CSI driver to run; the claims below use the StorageClass names from Rook's examples.

yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: shared-uploads
  namespace: media
spec:
  accessModes: ["ReadWriteMany"]
  storageClassName: rook-cephfs
  resources:
    requests:
      storage: 200Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pgdata
  namespace: db
spec:
  accessModes: ["ReadWriteOncePod"]
  storageClassName: rook-ceph-block
  resources:
    requests:
      storage: 100Gi
Two claims, two contracts. Substitute your StorageClass names, and confirm your ceph-csi release advertises ReadWriteOncePod.

The database belongs on the second claim, never on a shared mount or a bucket; operators such as the one in PostgreSQL on Kubernetes with CloudNativePG then ship base backups and WAL to the object interface — each primitive used where it fits.

Audit, exit ramps and the long game

The semantics choice is also an evidence choice. Object versioning and Object Lock give retention the storage API itself enforces and reports on — what an auditor asks for when backups are in scope. Filesystem snapshots are real protection, but their evidence lives in the storage administrator's tooling, not a shared API. A backup strategy such as the one in Kubernetes disaster recovery with Velero usually lands on object storage for exactly that reason.

Exit cost follows the interface. Data behind the S3 API moves between engines with standard tooling, because the API is the contract; the MinIO community repository was archived on 25 April 2026, and an application that spoke plain S3 rather than one engine's extensions can follow its data to a replacement — the MinIO exit comparison covers the replacements. Data behind POSIX moves with rsync and any filesystem, which is its own form of portability. What does not move is an application written against one contract and silently running on the other: that is lock-in to an accident.

Engines will be relicensed, forked and archived on a decade's horizon. The semantics — rename is atomic here, PUT is atomic there, a lock means something only on this side — outlive every one of them. Record, per workload, which primitive it depends on; that record lets a team change the engine underneath without changing the answer.

§FAQ/Common questions

Frequently asked

What is the difference between object storage and a file system?

A file system lets applications write at any offset, append, rename atomically, lock files and fsync. The S3 object API offers atomic whole-object replace and conditional creation (If-None-Match), but on general-purpose buckets no rename or append, and no partial write or lock between writers. Atomic RenameObject and append exist only for objects in the S3 Express One Zone storage class. As AWS documents S3, concurrent PUTs to one key resolve as latest-timestamp-wins.

Can I run SQLite or PostgreSQL on NFS?

SQLite warns that its write locks have operated incorrectly on some network filesystems, causing corruption, and names NFS in particular. PostgreSQL supports NFS if it is mounted hard, and strongly recommends the sync export option so a client fsync reaches permanent storage. A block volume with a single writer avoids both problems.

Is rename atomic on S3 or through s3fs and Mountpoint?

Not on general-purpose buckets, which have no rename. s3fs documents no atomic renames of files or directories, and Mountpoint for Amazon S3 supports atomic file rename only on S3 Express One Zone and directory rename on no bucket type. Hadoop's S3A docs warn that callers cannot rely on atomic renames as part of a commit algorithm.

When should I choose block storage vs object storage?

Choose block when one writer needs local filesystem semantics underneath it — databases, broker logs, anything doing random writes and trusting fsync — ideally as a ReadWriteOncePod volume. Choose object for whole files written once and read by many: backups, artefacts, datasets and media served over HTTP.

object storage vs file systemfile system vs object storageobject storage vs file storageblock storage vs object storages3 atomic rename posix semanticss3 conditional writes if-none-match

Executive Briefing

Thirty minutes to clarify your infrastructure risk

Walk us through your vendor footprint and regulatory constraints. We will tell you honestly where sovereignty creates leverage — and where it does not. No pitch deck. No obligation.