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

Finding solution to Highscores ranking website data heaviness #686

Open
Klaranth opened this issue Jun 7, 2021 · 3 comments
Open

Finding solution to Highscores ranking website data heaviness #686

Klaranth opened this issue Jun 7, 2021 · 3 comments
Labels
bug 🐛 Something isn't working Discussion

Comments

@Klaranth
Copy link

Klaranth commented Jun 7, 2021

Thinksome
The highscores ranking on website https://pandorabox.io/highscore/#!/highscore
is very data heavy. 40 KB/s when it is open and it doesn't matter if the tab is focused or not.

Client-side solution would be https://addons.mozilla.org/en-US/firefox/addon/auto-tab-discard/

Auto Tab Discard for Firefox.
Increase browser speed, reduce memory load and when you have numerous open tabs.

But it's untested - don't know if it works or not

SX
Seems like xhr to skinsdb what causes most of traffic

Around 190k per request, requests are not exactly needed but it is probably just done simple/quick/bug free way. Reducing that and still keeping real time updates could be done by adding filter to requests so it would limit response data a lot.

Reducing even more is possible but quickly gets very complex and at that point work should be delegated to some framework providing higher level API for that stuff, that is to only get what should be updated and only when it should be updated.

Upside:
Can reduce traffic to some like 0.1% of current.

Downside:
Gets very complicated and bugs become a lot more likely. Mid way to filter things probably could be done however but I've no idea about code under the hood there.

Thinksome https://stackoverflow.com/questions/7389328/detect-if-browser-tab-has-focus#7389370
Stack Overflow, detects if Browser tab has focus
Is there a reliable cross-browser way to detect that a tab has focus.

SX
Tested and this is no go for anything you might want to actually watch.

Focus thing just does not work, well it works but that's also problem.
Click dev tools and updates stop.
Open page search box: updates stop.
Focus another app or just lose browser focus while site is open on screen ... updates stop.
Click address bar and updates stop.
It works "too well".

(While testing also polled document.hasFocus() every second to see if that's different, seems to be the same.)

@Klaranth
Copy link
Author

Klaranth commented Jun 9, 2021

SX
This was partially solved already by making updates slower but probably good to have issue open for that, while it fixed average traffic over some time frame it was more quick hack than good final solution.
Here's also commit link to changes: BuckarooBanzay/xp-highscore@5930644

@BuckarooBanzay
Copy link
Contributor

those are first-world problems, right? 🤔

@S-S-X
Copy link
Member

S-S-X commented Jun 14, 2021

those are first-world problems, right? 🤔

Exactly, reducing update rate to reduce average traffic. Eveything works just fine, updates are just bit slower.
To make number update faster could just revert /highscore updates back to 2s as those are small and cheap, only skinsdb is somewhat heavy.
highscore around 3 kB
skinsdb around 187 kB

@OgelGames OgelGames transferred this issue from pandorabox-io/in-game Sep 15, 2021
@BuckarooBanzay BuckarooBanzay added bug 🐛 Something isn't working Discussion labels Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working Discussion
Projects
None yet
Development

No branches or pull requests

3 participants