Engineering guarantees
How HydroGo keeps data correct when networks, processes and third parties misbehave: outbox, idempotency, retries, dead letters, tenant isolation and a hash-chained audit log.
This page names the mechanisms HydroGo uses to stay correct under failure. Each row says what the mechanism does and where it lives, so you can check it in the code or the linked decision record.
Consistency and delivery
| Mechanism | What it does |
|---|---|
| Transactional outbox | Events such as content.updated and site.updated, and webhook deliveries, are written to the outbox_events table inside the same database transaction as the change. A worker delivers them afterwards, so a crash never leaves a change without its event (decision 0009). |
| Idempotent checkout | A client-supplied idempotency key is bound to the cart that used it. Retrying the same checkout returns the same order; reusing the key for a different cart is rejected with a conflict. |
| Retries with exponential backoff | The notification outbox doubles its delay after every failed attempt, starting at 1 second and capped at 1 hour by default. The mail transport retries with bounded exponential backoff too. |
| Leased jobs and dead letters | Background jobs are claimed with a lease and then acknowledged, or returned with a retry time. Jobs that keep failing are set aside as dead letters for operator review and can be requeued from the admin. |
| Reconciliation | hydro commerce reconcile, and a background sweep that runs every five minutes, look for stale pending orders, payment notifications that arrived without flipping an order, and stock-reservation drift. |
| Stampede protection | Concurrent public reads of the same content share one lookup instead of each hitting the database. |
Isolation and integrity
| Mechanism | What it does |
|---|---|
| Tenant isolation | Application-layer tenant-scoped query filters (RequireTenantScope) across SQLite, MySQL, and PostgreSQL, backed on PostgreSQL by forced row-level security (RLS) that fails closed (decision 0032). |
| Hash-chained audit log | Every audit event is linked into a per-tenant hash chain (prev_hash, chain_hash). hydro audit verify recomputes the chains and exits non-zero when they do not add up; a head printed earlier can be used as an anchor to prove the chain was not truncated. |
Architecture
| Mechanism | What it does |
|---|---|
| Single binary | The server, the embedded Svelte admin and the static assets compile into one executable. |
| Database abstraction | One data layer over SQLite, PostgreSQL and MySQL, with a migration per dialect. |
| Compile-time safety | Written in Go: type errors are caught when the binary is built, not while it serves requests. |
| Provider interfaces and add-on modules | Payment, shipping and invoicing sit behind small interfaces. Add-on modules plug in at build time and own their config sections through config extensions (decision 0036); core runs without them. |
AI-native control plane
hydro mcp serves the Model Context Protocol over stdio, and the HTTP/SSE endpoint exposes the same tools (schema_list, schema_apply, content_query, content_mutate). Tool calls run inside the caller's tenant scope and are recorded in the audit log. See the MCP guide.
Performance benchmarks & test conditions
All benchmarks below were measured on an Oracle Cloud Linux ARM64 VPS (`4 vCPU aarch64`, `23 GiB RAM`) with competing application services stopped during the run. CPU percentages are reported across 4 vCPUs (400% max).
1. Staged stress test: JSON API vs Embedded HTML vs Node SSR (--capacity-profile standard)
Compiled hydro binary (48 MB at the time; the current release is ~63 MB, SQLite WAL, --capacity-profile standard -> DBMaxOpenConns=10, MaxInFlightHTTP=300), 5-second sustained stages over 127.0.0.1 loopback. Idle baseline: Go `108.3 MB` RSS, Node SSR `57.3 MB` RSS.
| Workload (What was served) | Concurrency | Throughput | Latency (p50 / p95 / p99) | CPU & RAM Footprint |
|---|---|---|---|---|
GET /healthz (Go router) | 32 | 4,925 req/s (0 err) | 5.81 / 13.21 / 17.77 ms | Go 126% CPU, 169 MB RSS |
GET /healthz (Go router) | 512 | 4,462 req/s (0 err) | 101.4 / 235.8 / 317.6 ms | Go 144% CPU, 114 MB RSS |
GET /api/v1/pages (JSON + SQLite) | 32 | 3,198 req/s (0 err) | 8.91 / 20.18 / 27.23 ms | Go 144% CPU, 115 MB RSS |
GET /api/v1/pages (JSON + SQLite) | 256 | 3,071 req/s (0 err) | 73.89 / 171.9 / 232.8 ms | Go 145% CPU, 106 MB RSS |
GET /api/v1/site/themes (JSON + SQLite) | 32 | 2,323 req/s (0 err) | 12.58 / 27.77 / 35.88 ms | Go 158% CPU, 128 MB RSS |
GET /api/v1/site/themes (JSON + SQLite) | 256 | 2,132 req/s (0 err) | 105.7 / 249.5 / 329.8 ms | Go 170% CPU, 128 MB RSS |
GET / Embedded HTML (embed.FS) | 32 | 3,060 req/s (0 err) | 9.19 / 23.41 / 32.02 ms | Go 178% CPU, 133 MB RSS |
GET / Embedded HTML (embed.FS) | 256 | 2,915 req/s (0 err) | 73.34 / 202.7 / 290.0 ms | Go 185% CPU, 127 MB RSS |
GET / Node SSR (calls Themes + Pages API) | 32 | 1,604 req/s (0 err) | 18.53 / 34.91 / 45.54 ms | Go 185% / 121 MB, Node 4.6% / 89 MB |
GET / Node SSR (calls Themes + Pages API) | 256 | 1,570 req/s (0 err) | 153.9 / 254.9 / 313.1 ms | Go 181% / 108 MB, Node 12.0% / 160 MB |
At c=512 (> MaxInFlightHTTP=300 in standard profile), HydroGo intentionally sheds excess concurrent requests with 503 fast-fail backpressure (1,739 req/s served on /api/v1/pages, 888 req/s on /) instead of queuing and exhausting RAM.
2. SQLite WAL vs PostgreSQL 16 & PublicHTMLCache (wrk -t2 -c128 -d5s)
Measured with wrk (epoll, 2 threads, 128 connections, 5s, 0 non-2xx errors) on the same Oracle ARM64 VPS (--capacity-profile standard):
| Backend / Mode | Endpoint | Throughput | p50 | p99 |
|---|---|---|---|---|
| SQLite WAL | GET /healthz | 4,724 req/s | 25.16 ms | 74.70 ms |
| SQLite WAL (uncached JSON) | GET /api/v1/pages?locale=en | 3,141 req/s | 37.83 ms | 116.28 ms |
| PostgreSQL 16 (uncached JSON) | GET /api/v1/pages?locale=en | 3,153 req/s | 37.82 ms | 113.56 ms |
| SQLite WAL (uncached JSON) | GET /api/v1/site/themes | 3,421 req/s | 34.76 ms | 105.17 ms |
| PostgreSQL 16 (uncached JSON) | GET /api/v1/site/themes | 3,482 req/s | 34.31 ms | 103.27 ms |
SQLite WAL (PublicHTMLCache ON) | GET / (HTML) | 5,471 req/s | 21.58 ms | 78.71 ms |
PostgreSQL 16 (PublicHTMLCache ON) | GET / (HTML) | 5,581 req/s | 21.10 ms | 76.00 ms |
3. k6 & tools/bench production-profile runs (Oracle Linux ARM64 VPS)
| Workload / Tool | Throughput | Latency / Memory | Notes |
|---|---|---|---|
k6 public/commerce reads (250 req/s) | 250 req/s | p95 0.48 ms | 0.00% error rate |
k6 public/commerce burst (19,372 reqs) | 1,500 req/s | p95 0.56 ms (max 7.9 ms) | 0.00% error rate |
tools/bench read workload | 2,499.5 req/s | - | 0% error rate |
tools/bench concurrent writes | 864.3 req/s | p95 99.96 ms | 0% error rate + 20/20 SSE |
| Go binary RSS footprint (idle / burst) | - | ~105 MB RSS idle / 108-186 MB (stress) | Go + Node SSR cgroup peak 186.5 MB |