Traffic Shaping for Cost Optimization
Overview
Traffic shaping is a dynamic bandwidth management feature that optimizes outbound data transfer costs for RPC nodes. By intelligently limiting bandwidth when nodes are fully synchronized, traffic shaping can reduce outbound data transfer by up to 85% while maintaining node synchronization.
How It Works
The traffic shaping system consists of three universal components and one protocol-specific component that work together to dynamically manage network bandwidth:
Universal Components (in assets/common/network/):
- net-rules-start.sh: Configures nftables and tc (traffic control) to apply bandwidth limits
- net-rules-stop.sh: Removes all traffic shaping rules to restore unrestricted bandwidth
- net-rules.service: Systemd service that manages the traffic shaping lifecycle
Protocol-Specific Component (in the blueprint's user-data/ directory, resolved from node_modules/):
4. syncchecker.sh: Monitors node synchronization status, controls traffic shaping on/off, and reports metrics to CloudWatch
The system operates in a continuous cycle: when a node is fully synchronized (blocks/slots behind = 0), traffic shaping is automatically enabled to limit outbound bandwidth. If the node falls behind by more than the configured threshold (default: 10 blocks), traffic shaping is automatically disabled until the node catches up. This ensures nodes stay synchronized while minimizing data transfer costs during normal operation.
Examples of traffic limits
- 20 Mbit/s limit: ~0.2 TiB/month
- 40 Mbit/s limit: ~0.4 TiB/month
- 100 Mbit/s limit: ~1 TiB/month
When to Use Traffic Shaping
Recommended for:
- RPC nodes serving read-only queries
- Protocols with fast block times (<10 seconds) like Solana, BSC, Polygon
- Cost-sensitive deployments where data transfer is a significant expense
- High-traffic nodes with many peer connections
NOT recommended for:
- Validator or consensus nodes (will compromise performance and rewards)
- Nodes in critical infrastructure where cost is secondary to performance
See Also
- Configuration Reference - Traffic shaping environment variables
- Deployment Guide - Enabling traffic shaping in deployments
- Troubleshooting - Traffic shaping troubleshooting
- Adding New Protocols - Implementing traffic shaping for new protocols