forked from fl00r/go-tarantool-1.6
-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
Description
The current pool implementation supports only the round_robin balancing strategy.
It would be useful to have a strategy where:
- Only a subset of replicas is active and actually receives traffic.
- The remaining replicas act as standby and are promoted into the active subset when needed.
This allows:
- Keeping a controlled number of nodes serving traffic
- Using the remaining nodes as high-availability and capacity reserve.
Proposed functionality
Introduce a new balancing strategy (for example active_standby or priority) with the following behavior:
- The pool is configured with N connections in total.
- The size of the primary (active) subset is configurable:
- Either as a fixed number:
primaryCount = P,1 <= P <= N - Or as a fraction:
primaryShare ∈ (0, 1], converted toP = ceil(N * primaryShare)
- Either as a fixed number:
- At any point in time the strategy:
- Selects up to
Phealthy connections as the active subset. - Routes all traffic only to this active subset (e.g. round-robin within it).
- Treats the remaining healthy connections as standby (no traffic unless promoted).
- Selects up to
- If an active connection becomes unhealthy:
- It is removed from the active subset.
- A healthy standby connection is promoted into the active subset to keep its size close to
P.
- If a previously unhealthy connection becomes healthy again:
- It is added back to the pool of candidates and may be selected into the active subset according to the strategy rules.
From the caller’s perspective, the promotions and demotions are transparent.
Example configuration
Conceptual API, just as an illustration:
pool := connection_pool.New(
connection_pool.WithStrategy(
connection_pool.StrategyActiveStandby(
connection_pool.WithPrimaryPoolSize(8),
),
),
connection_pool.WithConnections([]connection_pool.Node{
{Conn: conn1},
{Conn: conn2},
{Conn: conn3},
{Conn: conn4},
{Conn: conn5},
{Conn: conn6},
{Conn: conn7},
{Conn: conn8},
{Conn: conn9},
{Conn: conn10},
}),
)tsvetiligo
Metadata
Metadata
Assignees
Labels
No labels