fuels-ts icon indicating copy to clipboard operation
fuels-ts copied to clipboard

Consider implementing Provider throttling

Open arboleya opened this issue 1 year ago • 5 comments

Maybe just some docs would be enough.

This could be further discussed with @FuelLabs/devrel.

[!NOTE]

  • Incoming from https://github.com/FuelLabs/fuels-ts/discussions/1537

arboleya avatar Dec 18 '23 21:12 arboleya

Are there any resources currently published/unpublished on the topic?

hummusonrails avatar Dec 26 '23 14:12 hummusonrails

@hummusonrails You mean internally? Probably not, but I bet we can find some external articles on the topic. I just don't have anything at hand to share atm.

@nedsalk Now that I'm looking at this, I wonder if this wouldn't be a small variation of the retrier you did (no maxRetries tho). I may be oversimplifying it. Let me know what you think.

arboleya avatar Jan 08 '24 15:01 arboleya

but I bet we can find some external articles on the topic.

Here's a great one from the SRE book: https://sre.google/sre-book/handling-overload/. The section of most interest for us would be "Client-Side Throttling".

Now that I'm looking at this, I wonder if this wouldn't be a small variation of the retrier you did (no maxRetries tho).

Yeah, that would probably be the place to do it, just that the logic would be kinda inverse to the retry functionality so one would have to take care to properly implement the interplay between these two functionalities.

This throttling would be an internal detail not modifiable by the user, right? I don't see why we'd allow users access to it, but I wanted to throw this question out there.

As for the implementation, I see two ways that we can go about throttling:

  1. Reject the request locally and throw an error,
  2. Store the request locally and delay its sending for some time

But just to take a step back, do we actually need client-side throttling on the SDK level? The only error I found on the fuel node that might benefit from client-side throttling is the TooManyTransactions error, but it's thrown when the max u16 value of transactions in a block is reached (65535 transactions), so maybe we're prematurely optimizing here. To me it seems like we neither need docs nor implementation here.

nedsalk avatar Jan 18 '24 11:01 nedsalk

[..] do we actually need client-side throttling on the SDK level?

I don't think so. We are just evolving the topic here.

This seems more pertinent to the user domain, so maybe some mention in the docs will be enough, especially if we have more information about the fuel-core rate-limiting (not sure if we have these details yet).

arboleya avatar Jan 18 '24 11:01 arboleya

especially if we have more information about the fuel-core rate-limiting (not sure if we have these details yet).

Could somebody from @FuelLabs/client chime in on this?

nedsalk avatar Jan 18 '24 12:01 nedsalk

Closing this issue as not planned because it's not in the domain of the SDK. Referencing the @FuelLabs/devrel team because they might want to evolve this topic further from the docs side.

nedsalk avatar Feb 22 '24 09:02 nedsalk