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

enable grpc retry #322

Closed
wants to merge 9 commits into from
Closed

enable grpc retry #322

wants to merge 9 commits into from

Conversation

AntonioYuen
Copy link
Contributor

Enables retry for our readside grpc services.

@codecov
Copy link

codecov bot commented Apr 30, 2021

Codecov Report

Merging #322 (424e634) into master (d3ecdc7) will increase coverage by 0.26%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #322      +/-   ##
==========================================
+ Coverage   83.77%   84.04%   +0.26%     
==========================================
  Files          46       46              
  Lines         900      915      +15     
  Branches       19       19              
==========================================
+ Hits          754      769      +15     
  Misses        146      146              
Impacted Files Coverage Δ
...in/scala/com/namely/chiefofstate/NettyHelper.scala 100.00% <100.00%> (ø)
...namely/chiefofstate/readside/ReadSideHandler.scala 100.00% <100.00%> (ø)
...ly/chiefofstate/readside/ReadSideJdbcHandler.scala 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3ecdc7...424e634. Read the comment docs.

if (!isSuccess && (maxAttempts <= 0 || numAttempts >= maxAttempts)) {
val backoffSeconds: Long = Math.min(maxBackoffSeconds, (minBackoffSeconds * Math.pow(1.1, numAttempts)).toLong)

Thread.sleep(Duration.ofSeconds(backoffSeconds).toMillis)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit dangerous because we are inside an actor. The projection is an actor making the grpc call. Let us just becareful here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you suggest in this scenario?

Copy link
Contributor

@Tochemey Tochemey May 2, 2021

Choose a reason for hiding this comment

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

I think we should make the grpc call asynchronous and make use scala retry on future. That will make it more resilient.
For instance you can use these libraries:

This is my opinion I don't see why you should reimplement something that it is already out there in form of libraries in the jvm ecosystem.

Copy link
Contributor

Choose a reason for hiding this comment

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

So instead of using the blocking stub of the grpc client we can use the non-blocking one.

Copy link
Contributor

Choose a reason for hiding this comment

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

@zenyui we need to take into consideration this:
for the projection to listen and read events persisted the sharded daemon is hooked it into the existing actor system. With that type of setup I have some worries around the execution context. Since the actor system is making use of the default dispatcher the retry mechanism can hinder a bit the performance of the system(writeside). I think we may have to push this feature into its own execution context to avoid hindering the whole actor system.

Copy link
Contributor Author

@AntonioYuen AntonioYuen May 3, 2021

Choose a reason for hiding this comment

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

@Tochemey I'm fine with using the retry package, however it's using promises, which is essentially blocking an entire thread just like a Thread.sleep. Why would this be superior aside from their jitter implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Funny thing is... I started with the amazon algo, then was asked to simplify it :D

Copy link
Contributor

Choose a reason for hiding this comment

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

That is why I am saying we may have to consider a separate thread executor. Whatever we do needs another thread executor to think of it properly. These libraries are just suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

The projection JDBC handler we are using does not have its own its thread pool compared to the slick version we stopped using.

Copy link

Choose a reason for hiding this comment

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

@Tochemey the call is already blocking, I don't see the issue. I don't mind creating a new thread pool for remote calls, but using a future won't change anything. Under the hood, they are likely just using sleep.

@Tochemey Tochemey linked an issue May 2, 2021 that may be closed by this pull request
@AntonioYuen AntonioYuen closed this May 5, 2021
@Tochemey Tochemey deleted the grpc_retry branch August 25, 2021 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exponential backoff for projections
3 participants