Load balancing algorithm implementations. Provides weight computation for different load balancing strategies:
Load balancing algorithm implementations. Provides weight computation for different load balancing strategies: - weighted-random: Original configured weights (default) - least-connections: Route to backends with fewer active connections
(compute-algorithm-weights algorithm original-weights conn-counts weighted?)Compute weights based on the selected algorithm.
algorithm: :weighted-random or :least-connections original-weights: Vector of configured weights conn-counts: Vector of connection counts (ignored for weighted-random) weighted?: Factor in original weights for least-connections
Returns vector of effective weights.
Compute weights based on the selected algorithm. algorithm: :weighted-random or :least-connections original-weights: Vector of configured weights conn-counts: Vector of connection counts (ignored for weighted-random) weighted?: Factor in original weights for least-connections Returns vector of effective weights.
(compute-effective-weights algorithm
original-weights
conn-counts
health-statuses
drain-statuses
cb-states
weighted?)Compute final weights considering algorithm + health + drain + circuit-breaker.
This is the main entry point for weight computation.
algorithm: :weighted-random or :least-connections original-weights: Vector of configured weights conn-counts: Vector of connection counts per backend health-statuses: Vector of booleans (true = healthy) drain-statuses: Vector of booleans (true = draining) cb-states: Vector of circuit breaker states (:closed, :open, :half-open, nil) weighted?: Factor in original weights for least-connections
Returns vector of final effective weights summing to 100.
Compute final weights considering algorithm + health + drain + circuit-breaker. This is the main entry point for weight computation. algorithm: :weighted-random or :least-connections original-weights: Vector of configured weights conn-counts: Vector of connection counts per backend health-statuses: Vector of booleans (true = healthy) drain-statuses: Vector of booleans (true = draining) cb-states: Vector of circuit breaker states (:closed, :open, :half-open, nil) weighted?: Factor in original weights for least-connections Returns vector of final effective weights summing to 100.
(compute-least-conn-weights original-weights conn-counts weighted?)Compute weights for least-connections algorithm. Backends with fewer connections get higher weights.
original-weights: Vector of configured weights [w1 w2 ...] conn-counts: Vector of connection counts [c1 c2 ...] (same order as weights) weighted?: If true, factor in original weights (capacity-aware) If false, pure least-connections (ignore original weights)
Formula for weighted mode: capacity_i = original_weight_i / (1 + connections_i) effective_weight_i = capacity_i / sum(all_capacities) * 100
Formula for pure mode: inverse_i = 1 / (1 + connections_i) effective_weight_i = inverse_i / sum(all_inverses) * 100
Returns vector of effective weights summing to 100.
Compute weights for least-connections algorithm.
Backends with fewer connections get higher weights.
original-weights: Vector of configured weights [w1 w2 ...]
conn-counts: Vector of connection counts [c1 c2 ...] (same order as weights)
weighted?: If true, factor in original weights (capacity-aware)
If false, pure least-connections (ignore original weights)
Formula for weighted mode:
capacity_i = original_weight_i / (1 + connections_i)
effective_weight_i = capacity_i / sum(all_capacities) * 100
Formula for pure mode:
inverse_i = 1 / (1 + connections_i)
effective_weight_i = inverse_i / sum(all_inverses) * 100
Returns vector of effective weights summing to 100.(count-connections-by-backend conntrack-stats)Count active connections per backend from conntrack stats.
conntrack-stats: Result of (conntrack/stats-by-target conntrack-map) A sequence of {:target-ip "x.x.x.x" :connection-count n}
Returns map of ip-string -> connection-count.
Count active connections per backend from conntrack stats.
conntrack-stats: Result of (conntrack/stats-by-target conntrack-map)
A sequence of {:target-ip "x.x.x.x" :connection-count n}
Returns map of ip-string -> connection-count.(format-weight-change target-ips old-weights new-weights)Format a weight change for logging.
Format a weight change for logging.
(get-backend-connections conn-counts-map ip-string)Get connection count for a specific backend. Returns 0 if backend not found in connection map.
Get connection count for a specific backend. Returns 0 if backend not found in connection map.
(weights-differ? weights1 weights2)Check if two weight vectors are different. Used to determine if BPF map update is needed.
Check if two weight vectors are different. Used to determine if BPF map update is needed.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |