Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 10s
Blockchain Synchronization Verification / sync-verification (push) Failing after 3s
CLI Tests / test-cli (push) Failing after 4s
Documentation Validation / validate-docs (push) Successful in 8s
Documentation Validation / validate-policies-strict (push) Successful in 4s
Integration Tests / test-service-integration (push) Successful in 38s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 2s
P2P Network Verification / p2p-verification (push) Successful in 3s
Security Scanning / security-scan (push) Successful in 40s
Smart Contract Tests / test-solidity (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Successful in 15s
Smart Contract Tests / lint-solidity (push) Successful in 8s
- Relocate blockchain-event-bridge README content to docs/apps/blockchain/blockchain-event-bridge.md - Relocate blockchain-explorer README content to docs/apps/blockchain/blockchain-explorer.md - Replace app READMEs with redirect notices pointing to new documentation location - Consolidate documentation in central docs/ directory for better organization
4.3 KiB
4.3 KiB
Multi-Region Load Balancer
Status
✅ Operational
Overview
Load balancing service for distributing traffic across multiple regions and ensuring high availability and optimal performance.
Architecture
Core Components
- Load Balancer: Distributes traffic across regions
- Health Checker: Monitors regional health status
- Traffic Router: Routes traffic based on load and latency
- Failover Manager: Handles failover between regions
- Configuration Manager: Manages load balancing rules
Quick Start (End Users)
Prerequisites
- Python 3.13+
- Multiple regional endpoints
- DNS configuration for load balancing
Installation
cd /opt/aitbc/apps/multi-region-load-balancer
.venv/bin/pip install -r requirements.txt
Configuration
Set environment variables in .env:
REGIONAL_ENDPOINTS=us-east:https://us.example.com,eu-west:https://eu.example.com
LOAD_BALANCING_STRATEGY=round_robin|least_latency|weighted
HEALTH_CHECK_INTERVAL=30
FAILOVER_ENABLED=true
Running the Service
.venv/bin/python main.py
Developer Guide
Development Setup
- Clone the repository
- Create virtual environment:
python -m venv .venv - Install dependencies:
pip install -r requirements.txt - Configure regional endpoints
- Run tests:
pytest tests/
Project Structure
multi-region-load-balancer/
├── src/
│ ├── load_balancer/ # Load balancing logic
│ ├── health_checker/ # Regional health monitoring
│ ├── traffic_router/ # Traffic routing
│ ├── failover_manager/ # Failover management
│ └── config_manager/ # Configuration management
├── tests/ # Test suite
└── pyproject.toml # Project configuration
Testing
# Run all tests
pytest tests/
# Run load balancer tests
pytest tests/test_load_balancer.py
# Run failover tests
pytest tests/test_failover.py
API Reference
Load Balancing
Get Load Balancer Status
GET /api/v1/lb/status
Configure Load Balancing Strategy
PUT /api/v1/lb/strategy
Content-Type: application/json
{
"strategy": "round_robin|least_latency|weighted",
"parameters": {}
}
Get Regional Status
GET /api/v1/lb/regions
Health Checks
Run Health Check
POST /api/v1/lb/health/check
Content-Type: application/json
{
"region": "us-east"
}
Get Health History
GET /api/v1/lb/health/history?region=us-east
Failover
Trigger Manual Failover
POST /api/v1/lb/failover/trigger
Content-Type: application/json
{
"from_region": "us-east",
"to_region": "eu-west"
}
Get Failover Status
GET /api/v1/lb/failover/status
Configuration
Add Regional Endpoint
POST /api/v1/lb/regions
Content-Type: application/json
{
"region": "us-west",
"endpoint": "https://us-west.example.com",
"weight": 1.0
}
Remove Regional Endpoint
DELETE /api/v1/lb/regions/{region}
Configuration
Environment Variables
REGIONAL_ENDPOINTS: Comma-separated regional endpointsLOAD_BALANCING_STRATEGY: Strategy for load distributionHEALTH_CHECK_INTERVAL: Interval for health checks (default: 30s)FAILOVER_ENABLED: Enable automatic failoverFAILOVER_THRESHOLD: Threshold for triggering failover
Load Balancing Strategies
- Round Robin: Distributes traffic evenly across regions
- Least Latency: Routes to region with lowest latency
- Weighted: Uses configured weights for distribution
Health Check Parameters
- Check Interval: Frequency of health checks
- Timeout: Timeout for health check responses
- Failure Threshold: Number of failures before marking region down
Troubleshooting
Load balancing not working: Verify regional endpoints and strategy configuration.
Failover not triggering: Check health check configuration and thresholds.
High latency: Review regional health and network connectivity.
Uneven distribution: Check weights and load balancing strategy.
Security Notes
- Use TLS for all regional connections
- Implement authentication for load balancer API
- Monitor for DDoS attacks
- Regularly review regional access
- Implement rate limiting