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

Decouple fadeIn from loadbalancer #2634

Merged
merged 1 commit into from
Jan 24, 2024
Merged

Decouple fadeIn from loadbalancer #2634

merged 1 commit into from
Jan 24, 2024

Conversation

RomanZavodskikh
Copy link
Member

Decouple fadeIn from loadbalancer

loadbalancer/algorithm_test.go Outdated Show resolved Hide resolved
loadbalancer/fadein_test.go Outdated Show resolved Hide resolved
routing/datasource.go Outdated Show resolved Hide resolved
proxy/proxy_test.go Outdated Show resolved Hide resolved
@RomanZavodskikh RomanZavodskikh force-pushed the decoupleFadeIn branch 2 times, most recently from 30a49e3 to d51d217 Compare September 28, 2023 13:19
@RomanZavodskikh RomanZavodskikh marked this pull request as ready for review September 28, 2023 14:39
proxy/proxy_test.go Outdated Show resolved Hide resolved
proxy/proxy.go Outdated Show resolved Hide resolved
proxy/proxy.go Outdated Show resolved Hide resolved
@@ -0,0 +1,279 @@
package proxy
Copy link
Member Author

Choose a reason for hiding this comment

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

Those test were moved from loadbalancer/fadein_test.go

@szuecs
Copy link
Member

szuecs commented Oct 6, 2023

lgtm

@szuecs
Copy link
Member

szuecs commented Oct 6, 2023

👍

proxy/proxy.go Outdated Show resolved Hide resolved
proxy/proxy.go Outdated Show resolved Hide resolved
@RomanZavodskikh RomanZavodskikh marked this pull request as draft January 12, 2024 14:07
@RomanZavodskikh RomanZavodskikh added the architectural all changes in the hot path, big changes in the control plane, control flow changes in filters label Jan 12, 2024
proxy/proxy.go Outdated Show resolved Hide resolved
@RomanZavodskikh RomanZavodskikh force-pushed the decoupleFadeIn branch 2 times, most recently from b975b7d to 578d4ee Compare January 18, 2024 14:21
@RomanZavodskikh RomanZavodskikh marked this pull request as ready for review January 18, 2024 14:25
@szuecs
Copy link
Member

szuecs commented Jan 18, 2024

👍

proxy/proxy.go Outdated Show resolved Hide resolved
proxy/proxy.go Outdated Show resolved Hide resolved
proxy/proxy.go Outdated Show resolved Hide resolved
proxy/proxy.go Outdated Show resolved Hide resolved
averageLoad := computeLoadAverage(ctx)
targetLoad := averageLoad * balanceFactor
// Loop round ring, starting at endpoint with closest hash. Stop when we find one whose load is less than targetLoad.
for i := 0; i < ch.Len(); i++ {
endpointIndex := ch.hashRing[ringIndex].index
if skipEndpoint(endpointIndex) {
if ctx.SkipEndpoint(endpointIndex) {
Copy link
Member

Choose a reason for hiding this comment

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

Note: skipFadingEndpoints did linear search over notFadingIndexes and this would do linear search over LBContext.LBEndpoints (potentially having fading endpoints filtered out) so it should not be worse performance-wise.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried having an LBEndpointsSet together with LBEndpoint slice and using it in SkipEndpoint, however, this using does not improve performance at all:

goos: linux
goarch: amd64
pkg: github.com/zalando/skipper/proxy
cpu: AMD Ryzen 7 PRO 4750U with Radeon Graphics
                                                     │ decoupleFadeIn.txt │       decoupleFadeInWithSet.txt        │
                                                     │       sec/op       │    sec/op      vs base                 │
FadeIn/power-of-n-random-choices,_11,_1_clients-16            35.40µ ± 2%    72.97µ ±  1%  +106.16% (p=0.000 n=15)
FadeIn/power-of-n-random-choices,_11,_4_clients-16            14.01µ ± 5%    28.01µ ±  9%  +100.02% (p=0.000 n=15)
FadeIn/power-of-n-random-choices,_11,_16_clients-16           4.744µ ± 4%   16.192µ ±  2%  +241.32% (p=0.000 n=15)
FadeIn/power-of-n-random-choices,_11,_64_clients-16           4.474µ ± 3%   12.780µ ±  1%  +185.65% (p=0.000 n=15)
FadeIn/power-of-n-random-choices,_11,_256_clients-16          4.003µ ± 2%    9.654µ ±  2%  +141.17% (p=0.000 n=15)
FadeIn/random,_11,_1_clients-16                               36.58µ ± 2%    77.11µ ±  1%  +110.79% (p=0.000 n=15)
FadeIn/random,_11,_4_clients-16                               13.73µ ± 3%    26.47µ ± 13%   +92.83% (p=0.000 n=15)
FadeIn/random,_11,_16_clients-16                              4.680µ ± 7%   16.234µ ±  1%  +246.88% (p=0.000 n=15)
FadeIn/random,_11,_64_clients-16                              4.617µ ± 2%   13.017µ ±  3%  +181.94% (p=0.000 n=15)
FadeIn/random,_11,_256_clients-16                             4.032µ ± 2%   10.251µ ±  5%  +154.24% (p=0.000 n=15)
FadeIn/round-robin,_11,_1_clients-16                          36.45µ ± 2%    76.75µ ±  1%  +110.56% (p=0.000 n=15)
FadeIn/round-robin,_11,_4_clients-16                          12.58µ ± 4%    27.09µ ±  4%  +115.37% (p=0.000 n=15)
FadeIn/round-robin,_11,_16_clients-16                         4.714µ ± 5%   17.271µ ±  3%  +266.38% (p=0.000 n=15)
FadeIn/round-robin,_11,_64_clients-16                         4.583µ ± 3%   14.322µ ±  5%  +212.50% (p=0.000 n=15)
FadeIn/round-robin,_11,_256_clients-16                        4.175µ ± 2%   10.887µ ±  9%  +160.77% (p=0.000 n=15)
FadeIn/consistent-hash,_11,_1_clients-16                      36.05µ ± 2%    81.63µ ±  3%  +126.43% (p=0.000 n=15)
FadeIn/consistent-hash,_11,_4_clients-16                      12.47µ ± 7%    30.50µ ± 10%  +144.55% (p=0.000 n=15)
FadeIn/consistent-hash,_11,_16_clients-16                     4.402µ ± 2%   16.419µ ±  4%  +272.99% (p=0.000 n=15)
FadeIn/consistent-hash,_11,_64_clients-16                     4.300µ ± 2%   13.765µ ±  1%  +220.12% (p=0.000 n=15)
FadeIn/consistent-hash,_11,_256_clients-16                    3.974µ ± 1%   11.031µ ±  4%  +177.58% (p=0.000 n=15)
geomean                                                       8.328µ         21.87µ        +162.62%

Signed-off-by: Roman Zavodskikh <[email protected]>
"github.com/zalando/skipper/routing"
)

func returnFast(rt *routing.Route) bool {
Copy link
Member

@szuecs szuecs Jan 24, 2024

Choose a reason for hiding this comment

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

The name sounds a bit weird.
Maybe: noFadeIn or shouldFadeIn

or drop the func and change the logic below ( filterFadeIn ) to:

if rt.BackendType != eskip.LBBackend || rt.LBFadeInDuration <= 0 { return endpoints }

Copy link
Member

Choose a reason for hiding this comment

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

Do we need to check backend type at all? This code is only called for loadbalanced backends anyway as it passes endpoints

@AlexanderYastrebov
Copy link
Member

👍

1 similar comment
@RomanZavodskikh
Copy link
Member Author

👍

@RomanZavodskikh
Copy link
Member Author

RomanZavodskikh commented Jan 24, 2024

All comments that are left are about code refactoring, feature-wise everything seems good.

@RomanZavodskikh RomanZavodskikh merged commit 6bd37d5 into master Jan 24, 2024
14 checks passed
@RomanZavodskikh RomanZavodskikh deleted the decoupleFadeIn branch January 24, 2024 19:12
@RomanZavodskikh
Copy link
Member Author

Loadtested v0.19.32, loadtests are okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architectural all changes in the hot path, big changes in the control plane, control flow changes in filters
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants