FastestPingRoutingStrategy
Overview
The FastestPingRoutingStrategy
selects the gateway with the lowest latency by performing HEAD requests to all available gateways and choosing the one that responds fastest. This strategy optimizes for performance by dynamically selecting the most responsive gateway for each request.
How It Works
- Ping All Gateways: Send HEAD requests to all available gateways for the provided path and subdomain
- Measure Response Times: Records the time taken for each gateway to respond
- Select Fastest: Choose the gateway with the lowest response time
Basic Usage
Parameters
Parameter | Type | Default | Description |
---|---|---|---|
timeoutMs | number | 500 | Timeout for ping requests in milliseconds |
maxConcurrency | number | 3 | Number that determines how many HEAD checks to send at once |
logger | Logger | defaultLogger | Optional logger instance |
Related
- PreferredWithFallbackRoutingStrategy: Static gateway configuration
- RoundRobinRoutingStrategy: Even distribution across gateways
- RandomRoutingStrategy: Randomized gateway selection
- StaticRoutingStrategy: Always use a single, fixed gateway