krateng / maloja

Self-hosted music scrobble database to create personal listening statistics and charts
https://maloja.krateng.ch
GNU General Public License v3.0
1.12k stars 63 forks source link

Maloja frequently using all cpu resources to the point of getting errors 504 (Gateway Time-Out) #370

Open alscaldas opened 1 month ago

alscaldas commented 1 month ago

Hello,

Maloja has been frequently using all of the cpu resources lately, to the point that I start to get 504 errors. It is an apparently random behavior, since it works fine most of the time and then it just gets slow to the point to being unusable, working again only if I restart the docker container.

I'm using a couple of tools to scrobble. Sometimes MPD + rescrobbled or Feishin (Navidrome) + Multi-scrobbler when on my desktop and Symphonium (also Navidrome + Multi-scrobbler) when using my Android phone.

Is there anything I can do to solve this issue? Maybe reinstall everything (although I really wouldn't like to lose my scrobble history) would work?

I'd appreciate any suggestion.

Currently installed Maloja version: 3.2.2 (Docker) Latest recommended Maloja version: 3.2.2

Before restarting the container

docker stats --no-stream maloja 
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O        PIDS
d7497450d92a   maloja    130.52%   143.6MiB / 15.45GiB   0.91%     26.6MB / 30.7MB   149MB / 15.4MB   35

docker stats --no-stream maloja 
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O        PIDS
d7497450d92a   maloja    132.89%   139.8MiB / 15.45GiB   0.88%     26.6MB / 30.7MB   149MB / 15.4MB   35

After restarting the container

docker stats --no-stream maloja 
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT     MEM %     NET I/O         BLOCK I/O        PIDS
d7497450d92a   maloja    0.01%     82.75MiB / 15.45GiB   0.52%     15kB / 3.07kB   26.4MB / 618kB   30

cat /home/myuser/Docker/maloja/mljdata/settings.ini

[MALOJA]
lastfm_api_key = xxxxxx
spotify_api_id = xxxxxxx
spotify_api_secret = xxxxxxx
audiodb_api_key = XXXXX
lastfm_username = xxxx
lastfm_password = xxxx
lastfm_api_secret = xxxxx
timezone = -7
charts_display_tiles = True
send_stats = False
fancy_placeholder_art = True
show_play_number_on_tiles = True
directory_config = /mljdata
db_max_memory = 50
use_global_cache = True
discourage_cpu_heavy_stats = True
use_db_cache = True
use_request_cache = True

docker-compose.yaml

version: "3"
services:
  baikal:
    image: krateng/maloja:latest
    container_name: maloja
    restart: unless-stopped
    environment:
      - TZ=XXX/XXX
      - MALOJA_SKIP_SETUP=yes
      - MALOJA_DATA_DIRECTORY=/mljdata
      - MALOJA_FORCE_PASSWORD=xxxx
      - PUID=1000
      - PGID=1000
    ports:
      - "42010:42010"
    volumes:
      - /home/myuser/Docker/maloja/mljdata:/mljdata
SirMartin commented 3 weeks ago

I have the same issue, it always happened like that, but no idea why.

I tried to search, and it took to answer very slowly until it was dead.

image

SirMartin commented 3 weeks ago

Did your errors happen also while trying to search? I found doing some testing, that while you are writing is sending a request each time you type, instead of wait until you have finished, that means that if you search something like "The Rolling Stones" it sends almost 20 requests to search. That should be easy to fix, and wait a certain amount of time before send the request.