moloch-- / RootTheBox

A Game of Hackers (CTF Scoreboard & Game Manager)
http://root-the-box.com/
Apache License 2.0
916 stars 291 forks source link

While loading scoreboard is taking long time #504

Closed PunitTailor55 closed 2 years ago

PunitTailor55 commented 2 years ago

Hi team, I have seen that scoreboard is taking so long to load the page. As per the pagination, It suppose to load 50 users details in the page. I am displaying top 50 users on Summary page.

Load the scoreboard, it is taking 17 seconds.

image

Python debug. image

Is there anyway to display only top 50 users and mention user rank in their profile/dashbooard.

Thanks

eljeffeg commented 2 years ago

That is pretty crazy.. displaying only the top 50 wouldn't help this situation.. that's essentially what the pagination is doing already. The base /scoreboard query is pretty simple.

https://github.com/moloch--/RootTheBox/blob/273472308f15b00474b1f513d63a9582f395e535/handlers/ScoreboardHandlers.py#L80-L104

The only area that would take any amount of time would be the Scoreboard.update_gamestate(self) as this "refreshes" the data in memory (we could probably do this asynchronously to improve performance). But here is the code if you wanted to put in some timing statements to see what is happening.

https://github.com/moloch--/RootTheBox/blob/273472308f15b00474b1f513d63a9582f395e535/libs/Scoreboard.py#L49-L121

eljeffeg commented 2 years ago

I created a new branch that updates the gatestate in a separate thread, which I think should resolve that issue. But I expect the main problem is the history, which needs to be rewritten. https://github.com/moloch--/RootTheBox/tree/scoreboard_test

Give it a test and let me know.

PunitTailor55 commented 2 years ago

I have tried the thread but not working. Summary page is taking 17 seconds to disaplay the top 50 users. I have removed pagination from summary and team page and displaying top 50 users only but still taking time. Also, disabled the charts from scoreboard page.

image