Point-to-Point
Point-to-Point
Section titled “Point-to-Point”Two nodes, both write, both sync. The simplest topology — one --peer flag each.
Node A ←→ Node BWhen to Use
Section titled “When to Use”- Simple active-active replica (2 servers)
- Dev/test setup
- Read scale-out with write scale-out (both nodes accept writes)
# Node A./hook-sync-go -id node1 -db node1.db -listen :9001 \ -peer http://localhost:9002
# Node B./hook-sync-go -id node2 -db node2.db -listen :9002 \ -peer http://localhost:9001// Node Aconst mgr = attach(db, { id: "node1", peers: ["http://localhost:9002"], batchMs: 50,}, ["items"]);
// Node B — change port to 9002, peer to 9001// Node Aconst mgr = attach(db, { id: "node1", peers: ["http://localhost:9002"], batchMs: 50,}, ["items"]);
// Node B — change port to 9002, peer to 9001How It Works
Section titled “How It Works”- Node A writes to SQLite → trigger captures to
_changes - Background timer ships changes to Node B every 50ms
- Node B applies with
INSERT OR REPLACE+ timestamp check - Node B returns ACK → Node A deletes from
_changes - Same flow in reverse (Node B → Node A)
Both nodes accept writes independently. Conflicts resolve via last-write-wins by updated_at timestamp on reconnect.
Characteristics
Section titled “Characteristics”| Property | Value |
|---|---|
| Connections | 1 |
| Hops | 1 |
| Redundancy | None |
| SPOF | No |
| Write penalty | 0% (sync is background) |
| Sync latency | Batch interval (50ms default) |
Benchmark
Section titled “Benchmark”10 runs × 100 concurrent requests per node (200 total per run):
| Runtime | QPS median | QPS min | QPS max | Integrity |
|---|---|---|---|---|
| Go | 9,149 | 3,705 | 15,063 | 10/10 PASS |
| Bun | 10,476 | 3,004 | 14,159 | 10/10 PASS |
| Node | 8,393 | 3,458 | 10,068 | 10/10 PASS |
Run with: bash bench-dual-ack.sh