Asterisk Cluster Topology & Sync
Asterisk Cluster Topology & Sync
To guarantee high availability and seamless horizontal load distribution, Asterisk 2 tracks physical node states using an automated, database-backed heartbeat synchronization mechanism.
Cluster Synchronization & Heartbeat Lifecycle
The platform continuous tracking state flow relies on direct background polling routines updating persistent server records:
graph TD
%% Node Action
subgraph ActiveNode["Asterisk Server Instance"]
CronPoll["Local Shell Heartbeat Routine"]
SystemStats["System Metrics (CPU / Mem Load)"]
end
%% Web Service Layer
subgraph ApiController["ASP.NET Core REST Layer"]
SyncEndpoint["ServersController.cs<br/>(Heartbeat Update RPC)"]
end
%% Distributed DB Engine
subgraph DatabaseTier["Direct Proxy Data Layer"]
DB_Ast[("wb_ast External DB<br/>(Server Metrics Table)")]
end
%% Automated Sweeper
subgraph Supervisor["Background Supervisor Task"]
HealthSweep["Stale Connection Evaluator<br/>(5-Minute Auto-Offline Threshold)"]
end
%% Flow Vectors
CronPoll -->|"Query Hardware"| SystemStats
SystemStats ==>|"POST /api/Servers/Heartbeat"| SyncEndpoint
SyncEndpoint ==>|"Write LastUpdated Timestamp"| DB_Ast
HealthSweep -.->|"Poll Nodes where<br/>Now - LastUpdated > 5 Mins"| DB_Ast
HealthSweep ==>|"Set IsActive = False"| DB_Ast
%% Premium Design CSS
classDef nodeClass fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff,rx:6px,ry:6px;
classDef apiClass fill:#1e293b,stroke:#a855f7,stroke-width:2px,color:#fff,rx:6px,ry:6px;
classDef dbClass fill:#312e81,stroke:#ec4899,stroke-width:2px,color:#fff,rx:6px,ry:6px;
classDef sweepClass fill:#7f1d1d,stroke:#f87171,stroke-width:2px,color:#fff,rx:6px,ry:6px;
class ActiveNode,CronPoll,SystemStats nodeClass;
class ApiController,SyncEndpoint apiClass;
class DatabaseTier,DB_Ast dbClass;
class Supervisor,HealthSweep sweepClass;
Operational Health Protocols
1. Dynamic Load Balancing Metrics
Each registered server periodically posts performance telemetry directly to the controller layer. The load balancer analyzes these metrics to prioritize session allocation targeting servers with low CPU usage and high memory availability.
2. Automated Failover (5-Minute Threshold)
To protect active calls from routing loops caused by network isolation, the administrative framework executes an asynchronous clean-up worker. If a server node's LastUpdated timestamp falls behind the current server time by more than 5 minutes, the background logic automatically marks the node as Offline (IsActive = false), stopping further Kamailio routing dispatch assignments.
Zero-Local Database Integrity
Engineers modifying server registration boundaries must preserve Entity Framework schema structures ensuring strict read/write thread locking does not interrupt concurrent polling loops.