Hi folks,
We're building the backend orchestration layer for a multi-site physical access control system spanning 4 regional offices in Saudi Arabia (Riyadh HQ, Jeddah, Dammam, and NEOM site trailers — ~380 doors total, mixing BLE/NFC mobile credentials and biometric terminals).
Because of in-country data residency and audit requirements (Saudi PDPL / NCA controls), everything runs on-prem across private MPLS links rather than a public multi-tenant SaaS cloud.
Current Architecture
- HQ Core (Riyadh): 3-node Kubernetes cluster (Ubuntu 22.04), PostgreSQL 16 (primary event/audit ledger), Redis Streams, and a Go-based sync service pushing policy deltas to enterprise access controllers.
- Branch Edge Nodes: Lightweight Debian 12 gateways at each site caching active badge/mobile credential ACLs locally so doors still grant/deny in <150 ms if the MPLS WAN drops.
- Identity Source: Synced every 5 minutes from corporate Active Directory / HR offboarding webhooks.
Where We're Hitting Edge Cases
We're running into a classic CAP / revocation-propagation problem when handling offboarding or lost-phone mobile credential revocations across branches:
- Outbox / Sync Drift After WAN Drops: When a remote branch gateway loses WAN connectivity for 20–30 minutes and reconnects, replaying queued CREDENTIAL_REVOKED and ACCESS_GROUP_UPDATED deltas alongside thousands of buffered DOOR_ACCESS_EVENT logs occasionally creates out-of-order state if an employee was moved between clearance groups right before the outage.
- Audit Timestamp Skew: Offline controllers buffer entry logs locally; if NTP drifts slightly on an isolated security VLAN, reconciling entry/exit anti-passback rules across adjacent gates produces false anti-passback lockouts.
Questions for the Community
- For edge gateways that must stay authoritative offline, would you enforce monotonically versioned policy snapshots per site (e.g., an epoch/Lamport counter per branch) over idempotent event replay, or use NATS JetStream / Kafka leaf nodes at each branch?
- How are you handling time-sensitive credential revocations (e.g., terminating a contractor immediately across all sites) without blocking normal badge throughput during WAN reconnection storms?
Would love to hear patterns that have held up in production for distributed edge/IoT access setups.
Top comments (1)
I would pick versioned per site snapshots over replaying events, because applying a state with a higher version is idempotent and does not depend on arrival order, while replay breaks as soon as two changes to the same employee arrive out of order. Send revocations on their own small high priority channel, so they never queue behind thousands of buffered DOOR_ACCESS_EVENT logs after a reconnect. Upload the audit logs afterwards at lower priority. For anti passback, reconcile on a per controller sequence number rather than wall clock time, so NTP drift on the VLAN cannot create false lockouts.