ChuanFF commented on code in PR #12991:
URL: https://github.com/apache/apisix/pull/12991#discussion_r2866960842
##########
apisix/balancer.lua:
##########
@@ -55,7 +57,24 @@ local function transform_node(new_nodes, node)
core.table.insert(new_nodes._priority_index, node.priority)
end
- new_nodes[node.priority][node.host .. ":" .. node.port] = node.weight
+ local weight = node.weight
+ if warm_up_conf then
+ local start_time = node.update_time
+ if start_time then
+ local time_since_start_seconds = math_max(ngx_time() - start_time,
1)
+ if time_since_start_seconds < warm_up_conf.slow_start_time_seconds
then
+ local time_factor = time_since_start_seconds /
warm_up_conf.slow_start_time_seconds
+ local ramped_weight_ratio =
math_max(warm_up_conf.min_weight_percent / 100,
+ time_factor ^ (1 / warm_up_conf.aggression))
Review Comment:
aggression has set minimum 0.01
##########
apisix/balancer.lua:
##########
@@ -178,6 +197,35 @@ local function set_balancer_opts(route, ctx)
end
+local function get_version_with_warm_up(version, up_conf)
+ if not up_conf.warm_up_conf or up_conf.warm_up_conf.finish then
+ return version
+ end
+ local warm_up_conf = up_conf.warm_up_conf
+ local warm_up_end_time = warm_up_conf.warm_up_end_time
+ if not warm_up_end_time then
+ local max_update_time = 0
+ for _, node in ipairs(up_conf.nodes) do
+ if node.update_time and node.update_time > max_update_time then
+ max_update_time = node.update_time
+ end
+ end
+ if max_update_time > 0 then
+ warm_up_end_time = max_update_time +
warm_up_conf.slow_start_time_seconds
+ warm_up_conf.warm_up_end_time = warm_up_end_time
+ end
+ end
+
+ if warm_up_end_time and ngx_time() < warm_up_end_time then
+ version = version .. math_floor(ngx_time() / warm_up_conf.interval)
Review Comment:
Adding a schema for interval < slow_start_time_seconds is difficult, and the
necessity seems rather low, right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]