Skip to content

feat: Implement dynamic weighted RPC load balancing for enhanced resilience #6128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: feature/add-weighted-random-steering-load-balancing
Choose a base branch
from

Conversation

DaMandal0rian
Copy link
Contributor

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

…lience

This commit introduces dynamic weight adjustment for RPC providers, improving failover and resilience by adapting to real-time provider health.

Key changes include:
- Introduced a `Health` module (`chain/ethereum/src/health.rs`) to monitor RPC provider latency, error rates, and consecutive failures.
- Integrated health metrics into the RPC provider selection logic in `chain/ethereum/src/network.rs`.
- Dynamically adjusts provider weights based on their health scores, ensuring traffic is steered away from underperforming endpoints.
- Updated `node/src/network_setup.rs` to initialize and manage health checkers for Ethereum RPC adapters.
- Added `tokio` dependency to `chain/ethereum/Cargo.toml` and `node/Cargo.toml` for asynchronous health checks.
- Refactored test cases in `chain/ethereum/src/network.rs` to accommodate dynamic weighting.

This enhancement builds upon the existing static weighted RPC steering, allowing for more adaptive and robust RPC management.

Fixes #6126
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant