Znote / ZnoteAAC

Developement repository for the Znote AAC project. A website portal to represent and manage your Open Tibia server.
MIT License
145 stars 127 forks source link

trouble with the cache #294

Open MoisesFV opened 7 years ago

MoisesFV commented 7 years ago

I'm having trouble with the cache. They cause a lot of processor usage when being written, especially the cache "highscores". How can I remove the highscores cache, or improve the recording?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/43999439-trouble-with-the-cache?utm_campaign=plugin&utm_content=tracker%2F532683&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F532683&utm_medium=issues&utm_source=github).
Znote commented 7 years ago

How big is your $config['cache_lifespan']? How big is your engine/cache/highscores.cache.php file? How many rows have you configured in $config['highscore'] ? Is the RAM usage on your host machine capped? Does the host machine use a spindisk or an SSD disk?

MoisesFV commented 7 years ago

I have tested on two servers, linux and windows. Both with hd ssd. $config['cache_lifespan'] = 6 * 60 * 60;//60 * 15; // 15 minutes. The engine / cache / highscores.cache.php file is on average at 15 mb

$config['highscore'] = array( 'rows' => 100, 'rowsPerPage' => 20, 'ignoreGroupId' => 2, // Ignore this and higher group ids (staff) ); Is totally dedicated, 8gb of ram

Znote commented 7 years ago

Do you have many vocations? My highscores.cache.php file is about 500kb with 100 rows of score data for each vocation

MoisesFV commented 7 years ago

About 50 vocations ..

Znote commented 7 years ago

@MoisesFV when you configured those vocations in config.php, did you configure the "fromvoc" property? Vocations that can be grouped together on the highscore should be linked to each other with fromvoc, that way we reduce the amount of data we need to store.

Etc: currently sorcerers and master sorcerers are grouped together as "sorcerer", their vocation is so similar it makes sense to group them together.

Else we may need to refine highscore loading even further, like making separate cache files for each vocation, maybe only query and cache the vocation we have selected.

The stored data is pretty huge, for each single vocation, we store 100 * (8-9 skill types) rows of data. That would be around 40000 rows of data collected, parsed, saved and loaded for your 50 vocations if they are all separate. Even if the cache files were to be entirely stored in RAM, the CPU consumption to parse it would slow the site down significantly.

Hmm, I might be able to save a few queries if we can bundle weapons (axe, club, sword) into one highscore group as well.

Perhaps change rows to 10, and rowsPerPage to 10. It won't show much data, but the most important data, and the highscores will load much quicker. (10 times as quick).