Limits
Gateway limits bound request frames, reply frames, and PostgreSQL wire buffers in the pgredis Go process. Extension limits bound temporary workspace allocations, shared-memory rings, and session tables inside PostgreSQL 18. Neither replaces OS or PostgreSQL cluster-wide memory limits (shared_buffers, work_mem, container cgroup limits).
Gateway buffer limits
| Resource | Flag | Default limit |
|---|---|---|
| Single bulk argument | -max-bulk-bytes | 512 MiB (536,870,912 bytes) |
| Total argument bytes in one request frame | -max-frame-bytes | 1 GiB + 1 MiB (1,074,790,400 bytes) |
Unauthenticated request header (AUTH pending) | Built-in | 10 arguments, 16,384 bytes per bulk argument |
Complete wire reply (including EXEC array) | -max-reply-bytes | 1 GiB + 1 MiB (1,074,790,400 bytes) |
| Shared live input payload and bookkeeping | -max-input-bytes | 2 GiB (2,147,483,648 bytes) |
| Shared live output payload and workspace | -max-output-bytes | 2 GiB (2,147,483,648 bytes) |
| Shared PostgreSQL receive buffer budget | -max-pg-read-bytes | 2 GiB (2,147,483,648 bytes) |
| Single PostgreSQL wire message body | -max-pg-message-bytes | 1 GiB - 2 B (1,073,741,822 bytes) |
- Local
pgxread-budget patch: Duringmake build,scripts/prepare_pgx.pyappliespatches/pgx-v5.11.0-read-budget.patchto the Go driver so oversized PostgreSQL wire messages and shared-max-pg-read-bytesbudgets are enforced before allocating full message bodies in memory. - Post-commit output rejection: A mutating SQL statement can commit inside PostgreSQL before the gateway rejects an oversized reply against
-max-reply-bytesor-max-output-bytes. Callers that lose a connection or receive an output-budget error must treat the write outcome asUNKNOWN.
Extension workspace and session limits
| Component | Default limit | Behavior when exceeded |
|---|---|---|
| Per-backend C workspace and reply budget | 2 GiB | Raises a PostgreSQL error and rolls back the statement or savepoint. |
Shared preload memory budget (shared_preload_libraries) | 2 GiB | Bounds shared allocations across backends. |
MONITOR shared-memory ring | 4 MiB / 4,096 entries | Drops stalled MONITOR cursors that fall behind the ring head. |
| Pub/Sub queue per client | 1 MiB / 1,024 frames | Marks the session failed and closes the subscriber connection. |
| Total retained Pub/Sub payload | 64 MiB (4,096 sessions, 16,384 subscriptions) | Rejects new publications/registrations and fails overflowing routes. |
In SET ... GET and GETSET, the C extension releases the temporary replacement copy as soon as storage consumes it and before constructing the old-value reply, allowing full 512 MiB replacements within the default 2 GiB backend budget.
Mutation counter compaction
pg_redis tracks logical key mutations across backends using per-backend counter rows so concurrent writers do not contend on a single sequence row:
- Once the counter table reaches 64 rows, the background maintenance worker compacts up to 64 unlocked rows per pass into a single retained row while preserving the exact SQL
SUM. - Rows locked by active or prepared transactions (
PREPARE TRANSACTION) are skipped, and any batch whose sum would overflowbigintis left untouched. - Compaction bounds the number of rows modified per maintenance pass; dead row versions are reclaimed by standard PostgreSQL
VACUUM.
Verified 512 MiB capacity baseline
On Linux (3fc740ca5, 2026-10-15, 4 CPUs, 8 GiB RAM, no swap, PostgreSQL 18.6), the installed gateway and extension passed the full 512 MiB String suite across native and redis-acl authentication modes in both RESP2 and RESP3:
- Verified byte-for-byte across 16 large write/replace requests (
SET,SET ... GET,GETSET), 24 large replies, 32 direct SQL state observations, and clean PostgreSQL restart readbacks without OOM. - All tested 512 MiB keys had no TTL; large-value crash recovery with finite TTLs and multi-client concurrent 512 MiB streams require separate evaluation. See Status for current performance and test coverage.
