# High Availability Architecture This document outlines the **high availability design** for the application infrastructure. Goals: * Primary hosting in **Microsoft Azure** * Automatic failover to **on-premise infrastructure** * Minimal downtime * Disaster recovery backups through **CBM Technology** / **Rader Solutions** --- # 1. Architecture Overview ```mermaid flowchart TB A[Architecture Overview] A --> B[Primary Cloud Azure] A --> C[Secondary On Prem] A --> D[Tertiary CBM Backup] B --> B1[Azure Application Gateway] B --> B2[Main Application Server] B --> B3[Primary Database] B --> B4[External Access with IP Restrictions] C --> C1[Replica Application Server] C --> C2[Database Replica] C --> C3[File Storage Replica] C --> C4[Used During Internet Loss] D --> D1[Daily Snapshots of Azure Primary] D --> D2[Disaster Recovery Scenario] ``` --- # 2. Architecture Flow Diagram ```mermaid flowchart LR PC[User PC] FW[On Prem Firewall Reverse Proxy] VPN[Site to Site VPN] INT[Internet] AZGW[Azure Application Gateway] AZAPP[Azure Application Server] AZDB[(Primary Database Azure)] OPDB[(Replica Database On Prem)] OPAPP[On Prem Application Server] PC --> FW FW --> VPN VPN --> INT INT --> AZGW AZGW --> AZAPP AZAPP --> AZDB AZDB --> OPDB OPDB --> OPAPP FW --> OPAPP ``` Normal operation routes traffic to Azure. If the office internet fails, the firewall redirects users to the on-prem server. --- # 3. DNS Connection ```mermaid flowchart LR PC[User PC] GW[Gateway Firewall] DNS[app.avexmro.com] AZ[Azure Cloud Server] OP[On Prem Server] PC --> GW GW --> DNS DNS -->|WAN UP| AZ DNS -->|WAN DOWN| OP ``` Behavior: Normal operation ``` app.avexmro.com → Azure ``` Internet outage ``` app.avexmro.com → On Prem ``` WAN state detection is handled by the gateway firewall. --- # 4. Database and File Replication ```mermaid flowchart LR AZDB[(Azure Primary Database)] OPDB[(On Prem Replica Database)] AZFILES[Azure File Storage] OPFILES[On Prem File Storage] AZDB -->|Secure Replication| OPDB AZFILES -->|Continuous File Sync| OPFILES ``` Normal state ``` Azure → On Prem replication ``` Failover state ``` On Prem promoted to primary Replication paused ``` Recovery state ``` On Prem → Azure resync Azure resumes primary role ``` --- # 5. Monitoring Layer ```mermaid flowchart TB MON[Health Monitoring System] AZAPP[Azure Application Server] AZDB[Azure Database] OPAPP[On Prem Application Server] OPDB[On Prem Database] ALERT[Alerting and Failover Trigger] MON --> AZAPP MON --> AZDB MON --> OPAPP MON --> OPDB MON --> ALERT ``` Monitoring ensures: * replication health * server availability * automatic failover triggers Possible tools: * Azure Monitor * Zabbix * Uptime Kuma * Prometheus --- # 6. Failover State Machine ```mermaid flowchart TD A[Normal Operation Azure Primary] B[Internet Loss Detected] C[Local Failover Mode On Prem Primary] D[Internet Restored] E[Data Resynchronization] F[Return to Normal Azure Primary] A --> B B --> C C --> D D --> E E --> F ``` Failover sequence: 1. Azure operates as primary 2. Internet outage detected 3. On-prem database promoted 4. Office operates locally 5. Internet restored 6. Data resynchronizes to Azure 7. Azure resumes primary role --- # Reliability Model Expected behavior during failure scenarios: | Event | Result | | ---------------------- | -------------------------- | | Azure VM failure | Azure HA handles | | Azure maintenance | No downtime | | Office internet outage | Automatic on-prem failover | | Local server failure | Cloud still available | | Database corruption | Restore from CBM backup | | Company power outage | Service interruption | ---