pokerogue icon indicating copy to clipboard operation
pokerogue copied to clipboard

Exponential backoff in unavailable-modal-ui-handler

Open exitmouse opened this issue 9 months ago • 1 comments

Currently when the servers are down each player attempts to reconnect every 5 seconds. I'm not sure how much of the DDoS-like traffic the game is getting is due to this retry, but it seems like it can't hurt to add some kind of exponential backoff. I'm not super comfortable as a typescript dev and I don't know how to get this dialogue to appear when running locally, so use caution.

exitmouse avatar May 08 '24 09:05 exitmouse

PR Description: Current state of the game is calling updateUserInfo() every 5 seconds when the game is in unavailable state.

This change make the request delay exponential up to 1 minutes to drastically reduce the stress on the server from every game that are let opened.

MonsieurDMA avatar May 08 '24 10:05 MonsieurDMA

Closing this due to inactivity. Feel free to make a new request if interest is reignited

bennybroseph avatar May 19 '24 16:05 bennybroseph

I'd recommend setting the maximum at 5 minutes and add some randomness to avoid the pendulum effect where all requests end up being synchronized and make a BIG ddos at regular interval

Dakurei avatar May 23 '24 19:05 Dakurei

The last commit ~~removes the randomness and~~ resets the delay to 1 minute instead of 5, that's not good I didn't say anything about random, but only 1 minute is still short for a global outage where many clients could be left open 😅

Dakurei avatar May 23 '24 20:05 Dakurei

I've tested this with a local server, forcing the /info request to return a 500 error, and the delay is well included in the exponential backoff set up, so it looks all right to me apart from the shortened maximum delay.

This should save the server from getting a ton of useless requests during outages, making the situation worse in the event of a provider's ddos block.

Server view requests image image

Client view requests image

Dakurei avatar May 23 '24 20:05 Dakurei

Sorry about any confusion caused with how I had to go about this. Had to make a bunch of changes and test on someone else's repository and it just ended up being faster to create my own branch with the changes rather than keep editing this one. Closing this out for real this time.

bennybroseph avatar May 23 '24 21:05 bennybroseph