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

Adding backoff mechanism to google-fcm #923

Closed
JakubKahovec opened this issue May 3, 2018 · 6 comments
Closed

Adding backoff mechanism to google-fcm #923

JakubKahovec opened this issue May 3, 2018 · 6 comments
Milestone

Comments

@JakubKahovec
Copy link

JakubKahovec commented May 3, 2018

Hi,
thanks for the FCM connector. Have you thought about adding support for backoff mechanism needed by the FCM server ? It'd be very useful to have it as a part of the connector itself rather than implementing it outside.

@JakubKahovec JakubKahovec changed the title Adding retry/backoff mechanism to google-fcm Adding backoff mechanism to google-fcm May 3, 2018
@ennru
Copy link
Member

ennru commented May 4, 2018

cc @tg44

@tg44
Copy link
Contributor

tg44 commented May 4, 2018

Yeah... I mentioned it in the documentation :D

If I remember well, the streams-contrib has a stage for exponential backoff. The problem in general, that we need to know when we can retry and when there is some other error.

The sendWithPassthrough can pass the retry number, so if you know when you can safely retry and how much failed send is enough to actually give up; its not that hard to write the functionality for your problem.

I had more problems when tried to generalize this;

  • the (google) documentation (which is really shity in my opinion),
  • the input params (how much is too much? and other stuffs I didn't remember now),
  • the safeness (cycles are always problematic, which is more important sending new or retrying old, buffers? how big buffers? what happens when a buffer is full?),
  • the output elements (I need to parse/translate the inner google related errors, need to document the translations etc., if I drop elements bcs of buffer overflow those will lost forever)

So if you have any idea/concept I'm happy to help/code it, but when I started to implement this I faced too much problems.

@JakubKahovec
Copy link
Author

JakubKahovec commented May 4, 2018

I agree that the FCM documentation could have been more detailed. What I assume is that when there is an error code INTERNAL or UNAVAILABLE in the response it means the message should be backed off. My thought about how it might work was that when you get a response from the server which signals a backoff it would schedule an exponential retry of sending (num of attempts configurable) and postpone fulfilling a promise which would eventually decrease demand and back-pressured. I was also also thinking about restarting the whole flow but it would mean losing some of the messages in it which is not desirable.

@tg44
Copy link
Contributor

tg44 commented May 7, 2018

Okay so if I understand well, you want to restart the code inside the future with something like a recoverWith. This has a ton of possible problems... For example what happens when the token is about to expire but we start to retry the request (and get unauth)? What happens if all our threads are backing off (but we could send to other devices, just the actuals broken in the google side)? BTW unauth is a retryable response in some cases but the recoverWith method will make it hard to solve.

I personally think this is much worst then building a cycle... I will thinking about it.

@armanbilge
Copy link
Contributor

This will be fixed in #2613.

@seglo
Copy link
Member

seglo commented Mar 26, 2021

Fixed in #2613

@seglo seglo closed this as completed Mar 26, 2021
@seglo seglo added this to the 3.0.0-M1 milestone Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants