본문으로 건너뛰기
AI NEWS JOURNAL
Hacker News Show HNAI NEWS / JOURNAL

Show HN: Pgxio – a tiny PostgreSQL layer inside Nginx

I built the first version of this stuff a decade ago as ethanolus (c2h5oh). And I've used it for most of my projects as a backend layer since then.The main motive is to eliminate unnecessary complexity from backend layers.How it works: a rust nginx module calls postgresql functions via non-blocking libpq io. There is an optional patch for libpq. It provides zero-copy for nginx-chained memory buffers - to avoid request body copies between nginx and libpq.Pgxio supports http2 and websockets. Realtime listen/notify updates from postgres without polling.How to try - code on github. Tested on Debian - FreeBSD validation in progress.It's alpha - so any feedback is welcome. Comments URL: https://news.ycombinator.com/item?id=50425203 Points: 1 # Comments: 0

번역 서비스가 일시 중지되어 원문을 표시합니다.

A small SQL-first REST and WebSocket backend, implemented as a Rust Nginx dynamic module with nonblocking libpq. Publish explicit PostgreSQL functions, authenticate requests with JWTs, and subscribe to authorized invalidation signals. Experimental source preview. This is not a production-ready release. Six Linux ARM64 platform cells have passed: Debian 13 and Ubuntu 24.04/26.04, with stock and patched libpq. FreeBSD and amd64 validation remain incomplete; see the tested revision and platform status. There are no release binaries or published SDK packages. All GitHub workflows remain manual while validation continues. Early performance results Up to 3.9× PostgREST's throughput, with about 60% lower API memory in historical local RPC benchmarks. Across the matched cases, observed throughput was 1.7–3.9× PostgREST 14.17. These shared-host measurements used one API core, four PostgreSQL cores and equivalent SQL/JWT fixtures; they are not a guarantee for this unbenchmarked source preview or a ranking of all backend solutions. See the results, cache settings and limitations. Run locally Requires Docker with Compose and Python 3. The image builds Nginx and its module together; do not load the module into an arbitrary distribution Nginx binary. The Docker build also runs its embedded Rust checks. bin/pgxio init bin/pgxio up bin/pgxio check curl http://localhost:8080/v1/list_tasks \ -H "Authorization: Bearer $(bin/pgxio token alice)" \ -H 'Content-Type: application/json' --data '{}' Initialization creates ignored development credentials. The API listens on loopback port 8080. Development HMAC tokens are for local use only. The example SQL initializes a new database volume; restarting does not migrate existing data. bin/pgxio down preserves the database volume. Define SQL endpoints The included example exposes web.function(jsonb) RETURNS jsonb functions through explicit routes. Unlisted functions are not addressable. Include pgxio.conf inside Nginx's http {} block: pgxio_issuer pgxio-dev; pgxio_audience pgxio; pgxio_endpoint list_tasks web.list_tasks read_only; pgxio_endpoint create_task web.create_task; pgxio_stream tasks web.authorize_tasks; PostgreSQL validates incoming JSON syntax. Your SQL must enforce field types, required fields, ranges, ownership and permissions. Optional JSON Schema checking is available with pgxio_contract, pgxio_validate_input on, and pgxio_validate_output on; both validation flags default to off. Contract metadata can enrich OpenAPI and generate client types without enabling checks. Responses are released only after successful COMMIT. The example SQL separates owner, executor and runtime roles. The runtime has no direct private-table grants. Follow the security boundaries when adapting these functions. WebSockets and clients /v1/events carries authenticated, authorized invalidation signals: clients refetch snapshots through REST. Signals are ephemeral; this is not durable change-data capture, replay, or a message queue. See the protocol. The repository contains TypeScript and Python/Django clients, plus generated example types. They are source packages in this preview, not npm or PyPI releases. python3 scripts/generate.py examples/contract.json examples/generated python3 -m pip install './sdk/python[django]' Deployment and development Deployment and configuration: JWT/JWKS, TLS termination, Nginx settings, migrations, connection pools and optional schema enforcement. Architecture and security. Native builds and platform validation status. Benchmark methodology and exploratory results; reproduction tools. Contributing and private vulnerability reports. The default image uses stock libpq. An optional experimental borrowed-buffer client is built from a checksum-verified PostgreSQL base with the bundled patches applied. It needs no patched PostgreSQL server. Optional zero-copy request-body forwarding: patched libpq sends eligible REST payloads directly from Nginx buffers, avoiding intermediate body copies in Rust and libpq. This describes application-level input forwarding; responses, TLS encryption, and kernel networking still involve copies. pgxio_libpq_buf auto copies with stock libpq; patched builds borrow only eligible large plaintext inputs. copy and forced borrowed modes are also available. The project needs complete platform validation, sustained soak/fuzz testing and independent security review. Minimum RAM, production capacity, managed Supabase compatibility and broad competitor speedup claims have not been established. pgxio is a revival of c2h5oh. Source is distributed under the BSD 3-Clause license. Vendored jsmn benchmark code retains its MIT notice; PostgreSQL fork sources retain their upstream license. No PostgreSQL or Nginx endorsement is implied.

자료 출처

원문 읽기 ↗

관련 주제

← 전체 소식 이어 읽기