This document explains the technical implementation of the automatic peer discovery mechanism in Stigix.
Stigix instances in the same Proof of Concept (PoC) automatically find each other using a central Registry Worker (running on Cloudflare). This eliminates the need to manually enter IP addresses for every peer.
To ensure security and isolation between different clients, Stigix uses a Stateless Hash mechanism.
Every instance calculates a unique X-PoC-Key at startup:
- Input: Secure Hash derived from Shared Prisma Credentials and an internal salt.
- Algorithm: Standard cryptographic hash (transitioning to a stronger variant for production).
- Benefit: No local identity file (
identity.json) is required. If your environment is correctly configured with your Prisma credentials, you are automatically authorized.
- The first instance that registers for a given
TSG_ID"claims" that ID with its specific hash. - The Worker stores this hash as the reference for that PoC.
- Any subsequent instance trying to join that PoC must provide the exact same hash.
The RegistryManager handles the background synchronization with adaptive polling.
| Event | Frequency (Peer Local) | Frequency (Remote) | Description |
|---|---|---|---|
| Heartbeat | 60 seconds (1m) | 300 seconds (5m) | Updates Private IP and capabilities. Fast on local, slow on Cloudflare to save quota. |
| Discovery | 30 seconds | 30 seconds | Fetches the latest list of peers and shared targets. |
| Failover Check | Every Hearbeat | N/A | If a local heartbeat fails, the node immediately resets to Cloudflare Bootstrap. |
| TTL (Expire) | 300 seconds (5m) | 300 seconds (5m) | Cloudflare automatically prunes inactive peers after 5 minutes of silence. |
| Leader Lease | N/A | 900 seconds (15m) | The leadership record lasts 15 minutes unless refreshed by the leader. |
To ensure robustness during leader transitions, Stigix uses a Bootstrap Snapshot mechanism.
- Bootstrap Layer: Permanently fixed to the
STIGIX_REGISTRY_URLprovided in.envat startup. Used for high-level "political" signals (e.g., announcing a new leader). - Service Layer: Dynamically switches between Local Leader IPs and Cloudflare based on availability.
- Startup: The instance "snapshots" the Cloudflare URL from
.env. - Transition: If you switch a node to
leader, it calls Cloudflare securely using its snapshot, even if its local registry configuration was pointed at an old IP. - Healing: Peers detect the missing old leader, revert to the Cloudflare snapshot, find the new leader, and reconnect.
Tip
Implementation Tutorial: For a step-by-step guide on how to set up your site and propagate targets from a Leader to all Spokes, see the Implementation Guide.
Verify the local status via:
curl http://localhost:5000/api/registry/status- 403 Forbidden: Invalid PoC Key (Check Prisma Credentials in
.env). - Isolation/No Leader: Ensure at least one Hub is set to
STIGIX_REGISTRY_MODE=leader. - Sync Lag: Total convergence across all sites typically takes 60 to 90 seconds.