wger-project / wger

Self hosted FLOSS fitness/workout, nutrition and weight tracker
https://wger.de
GNU Affero General Public License v3.0
2.96k stars 554 forks source link

Performance of `api/v2/exercisebaseinfo/?limit=900` #1694

Open bbkz opened 1 month ago

bbkz commented 1 month ago

Use case

In my setup, when i open /exercise/overview/ it takes 2-3 minutes to load the content of api/v2/exercisebaseinfo/?limit=900. I run it on raspberry's and similar, so it may just be a hardware limitation.

Workaround

So i came up with the following workaround. I set EXERCISE_CACHE_TTL to 25 hours and run a cronjob every 24 hours to warm up the cache:

python3 manage.py warmup-exercise-api-cache --force

This way it will reset the TTL of the exercise cache every 24 hours. This work fine and it is blazing fast now ;-) I think updating a exercise will warmup it's cache induvidually so, i don't have to wait till the next day for the updates (but i am not sure).

Proposal

It would be nice if the warmup-exercise-api-cache could be refactured similar to sync_exercises, so that celery task can be created. This would eliminate the fact that a cronjob is needed to warmup the cache.

rolandgeider commented 1 month ago

mhh, yes, that does sound like a good idea