graph-node icon indicating copy to clipboard operation
graph-node copied to clipboard

feat: Implement dynamic weighted RPC load balancing for enhanced resilience

Open DaMandal0rian opened this issue 5 months ago • 0 comments

Summary

This PR introduces dynamic weight adjustment for RPC providers, improving failover and resilience by adapting to real-time provider health. The system now dynamically adjusts provider selection weights based on health metrics including latency, error rates, and consecutive failures.

This enhancement builds upon the static weighted RPC steering implemented in #6126, making the RPC management more adaptive and robust.

Changes

Core Implementation

  • Health Monitoring Module (chain/ethereum/src/health.rs): New module to track RPC provider health metrics
    • Monitors provider latency with exponential moving average
    • Tracks error rates and consecutive failures
    • Calculates health scores for weight adjustment

Integration Points

  • Dynamic Weight Adjustment (chain/ethereum/src/network.rs): Integrated health metrics into provider selection logic

    • Provider weights are now dynamically adjusted based on health scores
    • Traffic is automatically steered away from underperforming endpoints
    • Maintains compatibility with existing weighted selection algorithm
  • Health Checker Initialization (node/src/network_setup.rs): Setup and management of health checkers for Ethereum RPC adapters

    • Initializes health monitoring for each RPC provider
    • Manages lifecycle of health check processes

Dependencies

  • Added tokio dependency to chain/ethereum and node crates for asynchronous health checks

Testing

  • Updated test cases in chain/ethereum/src/network.rs to accommodate dynamic weighting behavior

Related Issues

Builds on #6126 - Weighted RPC load balancing

Test Plan

  • [ ] Unit tests pass with dynamic weight adjustments
  • [ ] Integration tests verify failover behavior
  • [ ] Manual testing with multiple RPC providers shows proper weight adjustment
  • [ ] Verify health metrics correctly influence provider selection
  • [ ] Confirm graceful degradation when providers become unhealthy

🤖 Generated with Claude Code

DaMandal0rian avatar Aug 24 '25 17:08 DaMandal0rian