# Unified kernel, protocol hooks and gateways

> How session wire hooks and stateless service gateways converge on PostgreSQL 19.0 tables, encryption and replication.

---

LLMS index: [llms.txt](/llms.txt)

---

## Two classes of wire protocols {#protocol-classes}

PostgreSQL runs one backend process per client connection. Mimus therefore separates wire protocols into two classes so only stateful database sessions touch the kernel:

| Dimension | Session database protocols | Service API protocols |
| --- | --- | --- |
| Protocols | PostgreSQL (`5432`), MySQL (`3306`), MSSQL (`1433`) | MongoDB (`27017`), Redis (`6379`), etcd (`2379`), S3 (`9000`) |
| Connection shape | Stateful session: transactions, session GUCs, temp tables, SQL dialect | Thousands of pooled requests, long-lived watches, HTTP/gRPC/RESP streams |
| Entry path | Postmaster hands the socket to a backend process driven by an extension hook | Stateless external gateway multiplexes client sockets onto a small SQL pool |
| Kernel patches | Yes: OpenHalo protocol hook (`300`/`301`) and Babelfish TDS/T-SQL (`400`/`401`) | None required: data models and transactional semantics live in SQL/C extensions |

## From connection to physical table {#connections}

![Mimus 19.0.1 kernel stack: native PostgreSQL 5432 and one session compatibility listener over nine PostgreSQL 19.0 patch layers with PG TDE and pgEdge Spock](/images/arch-en-light.svg)
{.mimus-diagram .only-light}

![Mimus 19.0.1 kernel stack: native PostgreSQL 5432 and one session compatibility listener over nine PostgreSQL 19.0 patch layers with PG TDE and pgEdge Spock](/images/arch-en-dark.svg)
{.mimus-diagram .only-dark}

Every Mimus instance accepts native PostgreSQL connections on port `5432`. Adding `pg_mysql` opens MySQL wire connections; adding `babelfishpg_tds` and its companion T-SQL extensions opens MSSQL TDS connections. Each compatibility listener maps logical databases onto PostgreSQL schemas so administrators can inspect physical tables, roles, indexes and backups directly from `psql`.

Choose **at most one** compatibility protocol per instance (`MySQL`, `MSSQL`, or `MongoDB`). All databases inside one `PGDATA` directory share server processes and `shared_preload_libraries`. Workloads needing both MySQL and MSSQL run on two separate instances.

## Single-node MongoDB gateway {#documentdb}

In `19.0.1-r4` acceptance on Debian 13 amd64, Mimus verified single-node DocumentDB 1.2 paired with its standalone MongoDB wire gateway (`27017`). MongoDB drivers connect to the gateway while BSON documents live inside PostgreSQL tables managed via `5432`. Both logical restore strategies—excluding `cron` via `pg_restore -N cron`, or pausing `pg_cron`, replacing default jobs in one transaction, and restoring full job history—returned all 63 documents under the original collection name in PyMongo checks.

## Storage, replication and extensions {#extensions}

`pg_tde` encrypts relation pages, indexes, TOAST tables and WAL locally on disk; `spock` replicates logical row changes across writable nodes; extensions such as `PostGIS`, `pgvector`, `VectorChord`, `orafce` and `pg_cron` operate on the same catalog and storage engine. When combining encrypted storage with bidirectional replication, configure a key provider and create encrypted relations on each node independently. See the [Kernel Patch Manifest](/docs/reference/patches/) for layer-by-layer patch boundaries.

---

Backlinks:

- [One kernel, many protocols](/blog/one-kernel-many-protocols/)
- [Architecture](/docs/etcd/architecture/)
- [MongoDB](/docs/mongo/)
- [DocumentDB and the gateway](/docs/mongo/architecture/)
- [Compatibility](/docs/mongo/compatibility/)
- [Try it with Pigsty](/docs/mongo/quickstart/)
- [Migration and operations](/docs/mssql/operations/)
- [MySQL](/docs/mysql/)
- [Architecture](/docs/redis/architecture/)
- [Base · PostgreSQL 19.0](/docs/reference/patches/base/)
- [Verification Matrix](/docs/reference/verification/)
- [Architecture](/docs/s3/architecture/)
- [Mimus 19.0.1 (r4 candidate)](/release/19.0.1/)
