Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:support slow start mode #2219

Merged
merged 13 commits into from
Nov 24, 2023
Merged

Conversation

tmsnan
Copy link
Contributor

@tmsnan tmsnan commented Nov 20, 2023

What type of PR is this?
Support slow start model

What this PR does / why we need it:

Which issue(s) this PR fixes:

Releated:
#1902
https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#config-cluster-v3-cluster-slowstartconfig

Signed-off-by: zhaonan <zhaonan06@corp.netease.com>
@tmsnan tmsnan requested a review from a team as a code owner November 20, 2023 08:10
Copy link

codecov bot commented Nov 20, 2023

Codecov Report

Attention: 26 lines in your changes are missing coverage. Please review.

Comparison is base (571f8bf) 64.49% compared to head (f530015) 64.50%.

Files Patch % Lines
internal/ir/zz_generated.deepcopy.go 0.00% 26 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2219      +/-   ##
==========================================
+ Coverage   64.49%   64.50%   +0.01%     
==========================================
  Files         111      111              
  Lines       15482    15542      +60     
==========================================
+ Hits         9985    10026      +41     
- Misses       4881     4900      +19     
  Partials      616      616              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zirain
Copy link
Contributor

zirain commented Nov 20, 2023

can you share the use case for this? add an e2e test for this if possible?
there're tons of feautes envoy support, EG won't expose all of them.
IMO, most of the edge case can be achieved by EnvoyPath?

Copy link
Contributor

@shawnh2 shawnh2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally LGTM, just some nits and please fix ci

api/v1alpha1/loadbalancer_types.go Outdated Show resolved Hide resolved
internal/xds/translator/cluster.go Outdated Show resolved Hide resolved
internal/gatewayapi/backendtrafficpolicy.go Outdated Show resolved Hide resolved
Signed-off-by: zhaonan <zhaonan06@corp.netease.com>
@tmsnan
Copy link
Contributor Author

tmsnan commented Nov 20, 2023

can you share the use case for this? add an e2e test for this if possible? there're tons of feautes envoy support, EG won't expose all of them. IMO, most of the edge case can be achieved by EnvoyPath?

  1. I will try to implement this e2e test through indicator comparison later.
  2. Slow-start mode is useful for certain backend applications that might otherwise be overwhelmed during warm-up. Such applications may respond slowly to requests or return errors immediately after a pod starts or a container restarts. Using a slow-start configuration to gradually increase traffic to the most recently started service endpoint can reduce the impact of this behavior on users. So I think it is necessary to provide this feature in load balancing. Secondly, the API does not provide complicated configuration (like envoy) to enable slow start. It only enables the function by configuring the slow response time window. If more fine-grained use is required, EnvoyPath is suitable.

Signed-off-by: zhaonan <zhaonan06@corp.netease.com>
Signed-off-by: zhaonan <zhaonan06@corp.netease.com>
Signed-off-by: zhaonan <zhaonan06@corp.netease.com>
Signed-off-by: zhaonan <zhaonan06@corp.netease.com>
@tmsnan
Copy link
Contributor Author

tmsnan commented Nov 21, 2023

/retest

Signed-off-by: zhaonan <zhaonan06@corp.netease.com>
internal/ir/xds.go Outdated Show resolved Hide resolved
@@ -91,3 +110,33 @@ backendTrafficPolicies:
type: ConsistentHash
consistentHash:
type: SourceIP
- apiVersion: gateway.envoyproxy.io/v1alpha1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of creating a new route, can we just add this slowStart config to the existing config ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing route has been used to test ConsistentHash, so a new route needs to be added

Signed-off-by: zhaonan <zhaonan06@corp.netease.com>
Signed-off-by: zhaonan <zhaonan06@corp.netease.com>
@tmsnan
Copy link
Contributor Author

tmsnan commented Nov 23, 2023

/retest

// +k8s:deepcopy-gen=true
type SlowStart struct {
// Window defines the duration of the warm up period for newly added host.
Window *metav1.Duration `json:"window" yaml:"window"`
Copy link
Member

@zhaohuabing zhaohuabing Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should Window be defined as a pointer here? It's required.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested this, to make it easier for adding if checks within xds code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean here? Can the second if be removed since window is a mandatory field?

		if args.loadBalancer.RoundRobin.SlowStart != nil {
			if args.loadBalancer.RoundRobin.SlowStart.Window != nil {
				cluster.LbConfig = &clusterv3.Cluster_RoundRobinLbConfig_{
					RoundRobinLbConfig: &clusterv3.Cluster_RoundRobinLbConfig{
						SlowStartConfig: &clusterv3.Cluster_SlowStartConfig{
							SlowStartWindow: durationpb.New(args.loadBalancer.RoundRobin.SlowStart.Window.Duration),
						},
					},
				}
			}
		}

// Currently only supports linear growth of traffic. For additional details,
// see https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#config-cluster-v3-cluster-slowstartconfig
// +kubebuilder:validation:Required
Window *metav1.Duration `json:"window"`
Copy link
Member

@zhaohuabing zhaohuabing Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above. Should Window be defined as a pointer here? It's required.

Copy link
Member

@zhaohuabing zhaohuabing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just some small nits.

case egv1a1.RandomLoadBalancerType:
lb = &ir.LoadBalancer{
Random: &ir.Random{},
}
case egv1a1.RoundRobinLoadBalancerType:
lb = &ir.LoadBalancer{
RoundRobin: &ir.RoundRobin{},
RoundRobin: &ir.RoundRobin{
SlowStart: &ir.SlowStart{},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this slow start field still exists on line 455, can you rm this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, my bad, I totally missed it many times.

Signed-off-by: zhaonan <zhaonan06@corp.netease.com>
@zirain zirain merged commit 73fbd62 into envoyproxy:main Nov 24, 2023
18 checks passed
@tmsnan tmsnan deleted the dev-slow-start-mode branch December 6, 2023 11:29
@Xunzhuo Xunzhuo mentioned this pull request Dec 7, 2023
@Xunzhuo Xunzhuo added this to the v1.0.0-rc1 milestone Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants