DIM · Dagon Inference Marketplace

Operating and monitoring

The gateway is deliberately quiet: it never logs request content, credentials or upstream errors, and the CLI prints only lifecycle lines. You monitor it from the outside, through the same signed documents buyers and indexers read, plus a local control socket.

Lifecycle lines

Line Meaning
Gateway listening on port N The listener is bound.
Gateway ready on port N The ledger is open and recovered; Holds are admitted. Wait for this before declaring a deploy healthy.
Gateway drained This generation finished every admitted stream and released the ledger (Linux managed mode).
Gateway startup failed; check --config, key files, route configuration and Solana RPC availability Exit 1. See the configuration reference for what fails startup.
Gateway shutdown failed Exit 1 after SIGINT/SIGTERM.

Run it under a supervisor (systemd or similar) as an unprivileged user, with the keys and ledger on private local storage.

The control socket (Linux)

The managed gateway listens on a 0600 Unix socket at <ledgerPath>.deploy.sock. Query or change its state from the same host:

bun services/gateway/src/cli.ts --config gateway/gateway.json --control status
bun services/gateway/src/cli.ts --config gateway/gateway.json --control maintenance
bun services/gateway/src/cli.ts --config gateway/gateway.json --control resume

Each prints {"state": ..., "in_flight": N} where state is ready, maintenance or draining.

  • maintenance refuses new Holds with 503 gateway_draining and Retry-After: 1, advertises headroom: 0, waits for admitted streams, and persists across restarts. Receipt lookup and voucher posts keep working, so buyers can still settle.
  • resume removes the marker and restores headroom.

What to watch

Signal How Healthy
Listing curl -s https://gpu.example.com/.well-known/inference-marketplace.json or the self-check Verifies under your seller key; matches the routes you intend to sell.
Capacity curl -s https://gpu.example.com/im/v1/capacity observed_at within a second or two of now; headroom rarely 0 outside maintenance. Persistent headroom: 0 means buyers are getting 429 no_headroom.
Generation state --control status ready; in_flight tracks your load.
Indexer view GET <indexer>/v1/routes/<route_id> Non-null capacity; your latest listing. A null capacity means the indexer could not fetch or verify a fresh report in the last 120 s.
Independent measurements The same response's observations (one latest window per pinned operator) availability near 10,000 basis points; error_rate 0 at the concurrency levels you advertise. See observations.
Settler SOL solana balance "$(solana-keygen pubkey gateway/keys/settler.json)" --url devnet Enough for many redemptions; an empty settler defers settlement.
Payouts spl-token balance --address PAYOUT_TOKEN_ACCOUNT --url devnet Rising with acknowledged vouchers.
Clock NTP status on the gateway host Synchronized. Capacity, Holds, receipts and indexer freshness all use unix seconds.
Ledger disk Free space on the ledger volume The ledger must retain replay history (every admitted request_id and lane counter), so it grows with traffic; clean opens took 7.5 ms at 1,000 claims, 68 ms at 10,000 and 319 ms at 50,000 on the reference host.

Embedding hooks

If you embed the gateway (startGateway with your own GatewayOptions), three synchronous, metadata-only hooks feed your metrics system. They cannot change a payment decision and never see request content:

Hook Receives
onAdmission accepted with timing breakdown (Hold verification, body read, accounting), or the refusal code (no_headroom, ingress_busy, or a 402 code).
onJournal When each claim became durable and how long it took.
onReceipt {id, routeId, status, chargeMicros} for every persisted receipt.

The CLI does not expose hooks; use them through the embedding API.

Backups

  • Back up the three key files. Losing the listing key means a new seller ID and new route IDs; losing the settler key means rotating it before you can pay fees for new redemptions.
  • Back up the closed ledger: the SQLite database, its WAL if present and, on Linux, the .claims journal, together. Never copy a live WAL, and never run two gateways or two settlers against copies of one ledger. The ledger contains replayable signed transaction bytes (not signing keys); keep backups private.

Performance notes

  • The declared load is eight concurrent streams per gateway instance, where the measured per-sample added first-chunk p99 was 2.21–3.77 ms on a dedicated host with six idle-polled CPUs. Without dedicated idle-polled CPUs or guest halt-polling, KVM guests resume cold and add latency.

  • Hosts whose clocksource is hpet or acpi_pm cannot meet that budget. Check:

    cat /sys/devices/system/clocksource/clocksource0/current_clocksource
  • Every completion byte waits for its claim's fdatasync, so a slow disk flush delays the whole group of streams waiting on it. Put the ledger on fast local storage.

For upgrades, maintenance windows and key rotation, see rolling deploys and key rotation.