Skip to content

pgs3: in-process S3

The alternative that serves S3 from PostgreSQL background workers, compared with pgsilo.

pgs3 is an alternative S3 implementation for PostgreSQL written in Rust with pgrx (0.19.2) under the Apache-2.0 licence. Instead of running an external Go gateway in front of PostgreSQL as pgsilo does, pgs3 loads into PostgreSQL via shared_preload_libraries and serves path-style S3 HTTP requests directly from PostgreSQL background workers.

Note

pgs3 is an early alpha (v0.1.1, commit d841238, 2026-09-03). Its functional and Ceph compatibility suites pass, but small-object latency/throughput and the 100,000-object bucket Fork target do not meet its release gates. Mimus documents pgsilo as the primary S3 path and summarizes pgs3 here for comparison.

How pgs3 works

pgs3 splits protocol framing from storage semantics across two layers inside the PostgreSQL server process:

  1. PostgreSQL background workers (Rust) own the HTTP listener (pgs3.listen_addr, pgs3.port, pgs3.workers), verify SigV4 headers and presigned URLs, parse aws-chunked streaming payloads, and invoke SQL functions over SPI in short transactions.
  2. SQL semantic layer defines buckets, permanently versioned objects, delete markers, multipart uploads, content-addressed canonical blobs (pgs3.blob) and chunk extents (blob_extent).

Because identical payloads reference the same canonical blob rows, CopyObject, historical version Restore, and metadata-only bucket Fork share physical bytes through reference counts rather than copying payload bytes. Access keys map to unprivileged PostgreSQL roles, and PostgreSQL row-level security (RLS) enforces tenant isolation inside the database.

pgs3 vs pgsilo

The pgsilo PRD evaluated the in-process background-worker and deduplicating-blob model before choosing an external stateless Silo gateway (ObjectLayer). The two designs make opposite trade-offs:

Dimensionpgsilo (Silo PostgreSQL backend)pgs3 (Rust/pgrx extension)
StatusMVP in progress (feat/pg-backend @ 1d387725c, schema 14)Research / early alpha (v0.1.1, d841238)
LicenceAGPL-3.0-or-laterApache-2.0
Process modelExternal stateless Go gateway (silo server) connecting over pgx poolsIn-process PostgreSQL background workers (shared_preload_libraries = 'pgs3')
PostgreSQL versionsStock PostgreSQL 16–18 (no extension binary required on the DB host)PostgreSQL 17 and 18 (16 best-effort); requires installing the pgs3 C/Rust extension
Addressing and TLSPath-style and virtual-host style; native TLS terminationPath-style only; cleartext HTTP only (requires an external TLS reverse proxy)
Authentication and authorizationS3 IAM users, groups, policies, service accounts, Basic AssumeRole STS, plus optional IAM AND PostgreSQL native authorizationSigV4 access keys mapped to PostgreSQL roles; PostgreSQL GRANT and default-deny RLS (no IAM policy language or STS)
Object storage modelDedicated per-version bytea segments (8 MiB default); no cross-object deduplicationContent-addressed canonical blobs (pgs3.blob) and chunk extents with reference-counted deduplication
Encryption, Lifecycle, Object Lock, QuotaSSE-C and static-key SSE-S3; Preview lifecycle, Object Lock and hard bucket quotasNot implemented
Protocol extensionsObject annotations (?annotation), ZIP member extraction (x-minio-extract), force bucket delete, silo_api SQL functionsSQL historical version Restore and metadata-only bucket Fork
Failure and resource isolationGateway CPU/memory is isolated from the PostgreSQL server; gateway limits concurrency to 32 connections by defaultBackground workers share CPU, memory, I/O and connection slots with the PostgreSQL instance

Current status and validation (v0.1.1)

At v0.1.1 (validated 2026-08-31 on an 18-core Apple M5 Max Docker Desktop arm64 environment with PostgreSQL 17.10 and 18, fsync=on, synchronous_commit=on, 16 workers and 4 MiB default chunk size):

  • Passing gates:
    • PostgreSQL 17 and 18 SQL semantics, package runtime and 0.1.0 -> 0.1.1 extension upgrade.
    • Client matrix on PostgreSQL 17 and 18: AWS CLI (s3 and s3api), boto3, rclone, DuckDB httpfs, and a privileged s3fs FUSE mount (including a 100 MiB, 13-part multipart upload).
    • Selected Ceph s3-tests compatibility suite: 195/195 pass (from 209 candidate cases with 14 documented exclusions).
    • Crash recovery (SIGKILL), pending blob garbage collection, live SIGHUP reload, hot-standby GET/LIST with write rejection, and deterministic malformed-request fuzz suites.
    • 8 MiB staged PUT throughput (167.894 MiB/s, p50 47.40 ms, target ≥ 150 MiB/s) and 100k-object LIST / delimiter LIST (2.358 ms / 9.487 ms, targets < 5 ms / < 10 ms).
  • Failing performance gates:
    • Small-object GET (Gate 12): p50 up to 3.342 ms (target < 0.5 ms) and minimum rate 3,989.933 ops/s at 16 KiB (target ≥ 30,000 ops/s). Content-addressed deduplication requires an extra indexed lookup into pgs3.blob on every small read.
    • Small-object PUT (Gate 13): minimum rate 1,555.986 ops/s at 4 KiB (target ≥ 5,000 ops/s).
    • 100,000-object bucket Fork (Gate 16): 1,944.071 ms on the authoritative golden image (target < 1,000 ms), emitting 154,178,689 bytes of WAL to update reference counts.

Deliberate exclusions and limitations

  • No built-in TLS or virtual-host addressing: pgs3 listens on cleartext HTTP and serves one configured database (pgs3.target_database). Production deployments must terminate TLS in an external reverse proxy (nginx, HAProxy) that preserves the signed path and headers.
  • No IAM policy language, ACLs, lifecycle or encryption: access control relies entirely on PostgreSQL roles, grants and RLS. Because SigV4 verification requires the secret key, secrets are stored reversibly in the database catalog; backups must be treated as credential-bearing material.
  • Whole-object GET buffering: full-object GET currently materializes the response through a single SQL bytea and Rust Vec before writing to the socket. Until response streaming is added, deployments must cap object sizes well below the 5 GiB HTTP parser ceiling.
  • Composite checksums: SHA-256 COMPOSITE multipart checksums are verified and stored; non-SHA multipart selections (such as CRC32) verify per-part checksums but do not validate or persist a final composite checksum.

Source code, build instructions and design records (D001–D027) are available at github.com/pgsty/pgs3.

Scan to open this page
https://mimus.pgsty.com/docs/s3/pgs3/