NomisCZ / hlstatsx-community-edition

HLstatsX Community Edition - PHP 7 and GeoIP2 supported
GNU General Public License v2.0
83 stars 48 forks source link

Large databases are slow at loading individual player stats #31

Closed pyro1g closed 5 years ago

pyro1g commented 5 years ago

Describe the bug Whenever you click on an individual player's stats page, it is extremely slow at loading, taking 11-18 seconds (at worst being 20 or more seconds), with a database with over 50k people in it. It also makes my server's CPU go at 100% for that same amount of time. This was never like this, only when it started collecting stats for alot of people.

To Reproduce Steps to reproduce the behavior:

  1. Go to stats page.
  2. Click on any player to view their stats.
  3. Wait...
  4. Wait...
  5. Wait...
  6. Finally.

Expected behavior I expect it to load a little faster than 20 seconds and for it to not overload my CPU, I don't know if this is something that can be fixed but it's too much for my server's CPU and the wait time is ridiculously long.

Environment

Additional context I would link my statistics page but I'm just not comfortable with it maxing out my CPU every time someone views a person's statistics page. This has been an ongoing issue since the original devs of HLStats and I don't know if they ever had a medium to large community before but this has happened to me twice so far in the time of me using this. It's especially bad because someone can easily DoS me just by loading the web page which is dangerous. Also, it's important to note that it was really fast at the start when it didn't have that many players logged, but as the database grew that's when it started really slowing down.

NomisCZ commented 5 years ago

Hi, I restored my old database with ~56k players and no issues (a bit slower then main stats), so it's looks like a problem with your server enviroment.

Version on my GIT (master) is for PHP 7.x. I didn't test it on older versions.

You can check my stats "speed" https://dev.hexa-core.eu/stats-hexa-core/ It's old backup, so some assets maybe broken ... And current stats https://stats.overcore.eu/ (~22k players)

pyro1g commented 5 years ago

Thank god I have some leadway with this issue, I've been lost for years on how to fix this. Thank you!