armeria icon indicating copy to clipboard operation
armeria copied to clipboard

Added Ring hash selection strategy

Open Bue-von-hon opened this issue 2 years ago โ€ข 15 comments

Motivation:

this Resolves #4698 issue

Added Ring hash strategy for For a broader selection.

Motification:

  • Added(RingHashEndpointSelectionStrategy): Implement a ring hash using the md5 hash algorithm and a ConcurrentSkipListMap

Result:

For now on, users will be able to use Ring hashes for load balancing.

Bue-von-hon avatar Apr 17 '23 07:04 Bue-von-hon

Looking at the wighted round robin, it looks like we need to identify the keys via host and port, am I understanding this correctly?๐Ÿค”

Bue-von-hon avatar Apr 20 '23 06:04 Bue-von-hon

Thanks for continuing updating this PR. Please feel free to let us know when it's ready for reviews. If you feel it's not yet, please consider switching it to a draft PR. ๐Ÿ™‡

trustin avatar May 08 '23 10:05 trustin

Thanks for continuing updating this PR. Please feel free to let us know when it's ready for reviews. If you feel it's not yet, please consider switching it to a draft PR. ๐Ÿ™‡

Thanks for pointing out this great feature. It turned out to be longer than I thought, so I fixed it to draft status

Bue-von-hon avatar May 08 '23 14:05 Bue-von-hon

I've worked on some of the details.๐Ÿ›  I'm still struggling with writing tests.๐Ÿ˜ญ How about testing the size of the ring or the element it contains?(I've put this approach now.) I also considered injecting the ring directly into the ring hash, but realized that it would be difficult to handle the hashing.

P.S. I don't know why the lint test fails. If I run ./gradlew lint --parallel command in local, it will succeed. Below is a part of the failed lint task log.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':core:compileTestJava'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:149)
	at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:147)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:135)
	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:74)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)

Bue-von-hon avatar Jun 24 '23 11:06 Bue-von-hon

I don't feel like this PR is ready yet. This is because I've heard from @minwoox that endpoints can be change dynamically. As result, I'll be working on incorporating this idea into code this week.๐Ÿ™‚

Bue-von-hon avatar Jul 02 '23 10:07 Bue-von-hon

Resolved everything in the comment.๐Ÿ™‚ I'm not sure about test for ring hashing's equality, but round robin has an equality test. so I have concern about if I should consider that.๐Ÿ˜… @minwoox PTAL ๐Ÿ™

Bue-von-hon avatar Jul 24 '23 13:07 Bue-von-hon

Codecov Report

Attention: Patch coverage is 92.39130% with 7 lines in your changes missing coverage. Please review.

Project coverage is 74.70%. Comparing base (9a29b39) to head (1a64c77). Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
...nt/endpoint/RingHashEndpointSelectionStrategy.java 92.30% 2 Missing and 5 partials :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4831      +/-   ##
============================================
+ Coverage     74.66%   74.70%   +0.03%     
- Complexity    21681    21705      +24     
============================================
  Files          1896     1898       +2     
  Lines         80320    80475     +155     
  Branches      10548    10570      +22     
============================================
+ Hits          59974    60116     +142     
- Misses        15318    15322       +4     
- Partials       5028     5037       +9     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 08 '23 12:08 codecov[bot]

๐Ÿ” Build Scanยฎ (commit: 0f12d268b51aa3b026c790a15e635ec117b66b95)

Job name Status Build Scanยฎ
build-ubicloud-standard-8-jdk-8 โœ… https://ge.armeria.dev/s/534qu5cdpyhjc
build-ubicloud-standard-8-jdk-21-snapshot-blockhound โœ… https://ge.armeria.dev/s/ydl3vhtxcrvby
build-ubicloud-standard-8-jdk-17-min-java-17-coverage โŒ (failure) https://ge.armeria.dev/s/ssx26i3nkaqmq
build-ubicloud-standard-8-jdk-17-min-java-11 โœ… https://ge.armeria.dev/s/3no2euebo4bzc
build-ubicloud-standard-8-jdk-17-leak โœ… https://ge.armeria.dev/s/lylgm3eu2g35i
build-ubicloud-standard-8-jdk-11 โœ… https://ge.armeria.dev/s/bb7yppkcmxp5m
build-macos-12-jdk-21 โœ… https://ge.armeria.dev/s/qnjigh4nzdonc

github-actions[bot] avatar Aug 28 '23 12:08 github-actions[bot]

gentle ping @trustin @ikhoon @jrhee17 @minwoox

Bue-von-hon avatar Oct 01 '23 04:10 Bue-von-hon

gentle ping @trustin @ikhoon @jrhee17 @minwoox

Bue-von-hon avatar Nov 22 '23 00:11 Bue-von-hon

gentle ping @trustin @ikhoon @jrhee17 @minwoox

Bue-von-hon avatar Dec 06 '23 07:12 Bue-von-hon

~~I fixed some minor mistakes, changed the hashing algorithm, and of course shaded the dependencies. PTAL ๐Ÿ™~~

I just realized a mistake in the shading implementation and am fixing it.

Bue-von-hon avatar Sep 15 '24 06:09 Bue-von-hon

@ikhoon @trustin @minwoox @jrhee17 finally fixed the shading feature! I actually unzipped it to check it out and it looks like this. PTAL ๐Ÿ™

unzip -l build/libs/armeria-shaded-1.30.2-SNAPSHOT.jar | grep openhft
        0  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/
      256  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/Access$1.class
     3183  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/Access$ReverseAccess.class
     3538  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/Access.class
     1539  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/LongHashFunction.class
      268  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/Primitives$1.class
      786  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/Primitives$ByteOrderHelper.class
      894  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/Primitives$ByteOrderHelperReverse.class
     1420  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/Primitives.class
      274  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/UnsafeAccess$1.class
     1156  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/UnsafeAccess$OldUnsafeAccessBigEndian.class
     1169  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/UnsafeAccess$OldUnsafeAccessLittleEndian.class
     4253  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/UnsafeAccess.class
     1717  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/XxHash$AsLongHashFunction.class
     2833  09-15-2024 21:15   com/linecorp/armeria/internal/shaded/openhft/XxHash.class

Bue-von-hon avatar Sep 15 '24 12:09 Bue-von-hon

gentle ping @trustin @ikhoon @jrhee17 @minwoox

Bue-von-hon avatar Oct 02 '24 11:10 Bue-von-hon