crazy-max / docker-rtorrent-rutorrent

rTorrent and ruTorrent Docker image
MIT License
492 stars 109 forks source link

CPU Spikes at Regular Intervals #392

Closed V33m closed 2 months ago

V33m commented 2 months ago

Support guidelines

I've found a bug and checked that ...

Description

I became aware of constant CPU spikes in the GluetunVPN container, as highlighted in this issue. This led me to investigate similar behavior in my other Docker containers.

As shown in the logs below, I observe significant CPU spikes every 15 seconds on my ARM server. These spikes do not occur with other containers like Transmission, nor do they occur with Gluetun when I disable the healthcheck.

Expected behaviour

Minimal CPU spikes similar to Transmission container or others

Actual behaviour

Logs using docker stats

NAME           CPU %     MEM USAGE / LIMIT   MEM %
transmission   0.27%     28.46MiB / 512MiB   5.56%
rtorrent       0.41%     102.1MiB / 512MiB   19.93%
vpn            0.44%     60.43MiB / 256MiB   23.61%

NAME           CPU %     MEM USAGE / LIMIT   MEM %
transmission   0.16%     28.47MiB / 512MiB   5.56%
rtorrent       50.36%    102.1MiB / 512MiB   19.94%
vpn            0.12%     60.43MiB / 256MiB   23.61%

NAME           CPU %     MEM USAGE / LIMIT   MEM %
transmission   0.16%     28.47MiB / 512MiB   5.56%
rtorrent       0.12%     102MiB / 512MiB     19.91%
vpn            0.13%     60.5MiB / 256MiB    23.63%

NAME           CPU %     MEM USAGE / LIMIT   MEM %
transmission   0.21%     27.05MiB / 512MiB   5.28%
rtorrent       0.07%     102MiB / 512MiB     19.91%
vpn            0.51%     60.43MiB / 256MiB   23.61%

-- Some seconds later
NAME           CPU %     MEM USAGE / LIMIT   MEM %
transmission   0.91%     27.05MiB / 512MiB   5.28%
rtorrent       39.24%    102.1MiB / 512MiB   19.94%
vpn            0.31%     60.44MiB / 256MiB   23.61%

Steps to reproduce

Run docker stats and monitor the resource consumption

Docker info

Client: Docker Engine - Community
 Version:    27.1.2
 Context:    default
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc.)
    Version:  v2.29.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 4
  Running: 4
  Paused: 0
  Stopped: 0
 Images: 4
 Server Version: 27.1.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8fc6bcff51318944179630522a095cc9dbf9f353
 runc version: v1.1.13-0-g58aa920
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.6.32-current-meson64
 Operating System: Armbian 24.5.5 noble
 OSType: linux
 Architecture: aarch64
 CPUs: 6
 Total Memory: 3.691GiB
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Docker Compose config

rtorrent-rutorrent:
    container_name: rtorrent
    image: crazymax/rtorrent-rutorrent:latest
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    healthcheck:
      disable: true
    mem_limit: 512M
    network_mode: "service:vpn"
    env_file:
      - "./rtorrent-rutorrent/rtorrent-rutorrent.env"
    environment:
      - PUID=1001
      - PGID=1001
      - RU_REMOVE_CORE_PLUGINS=_cloudflare,cookies,extsearch,feeds,geoip2,ipad,loginmgr,lookat,rss,rssurlrewrite,rutracker_check,spectrogram,xmpp
      - WAN_IP=0
      - WAN_IP_CMD=false
    volumes:
      - ./rtorrent-rutorrent/data:/data
      - ./rtorrent-rutorrent/passwd:/passwd
      - ./rtorrent-rutorrent/downloads:/downloads

Logs

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-fix-logs.sh: executing... 
[cont-init.d] 00-fix-logs.sh: exited 0.
[cont-init.d] 01-fix-uidgid.sh: executing... 
Switching to PGID 1001...
Switching to PUID 1001...
[cont-init.d] 01-fix-uidgid.sh: exited 0.
[cont-init.d] 02-fix-perms.sh: executing... 
Fixing perms...
[cont-init.d] 02-fix-perms.sh: exited 0.
[cont-init.d] 03-config.sh: executing... 
Public IP address enforced to 0
Setting PHP-FPM configuration...
Setting PHP INI configuration...
Setting OpCache configuration...
Setting Nginx configuration...
Setting Nginx XMLRPC over SCGI configuration...
Setting Nginx ruTorrent configuration...
Setting Nginx WebDAV configuration...
Update healthcheck script...
Initializing files and folders...
Checking rTorrent local configuration...
Checking rTorrent configuration...
Bootstrapping ruTorrent configuration...
Removing core plugin _cloudflare...
Removing core plugin cookies...
Removing core plugin extsearch...
Removing core plugin feeds...
Removing core plugin geoip2...
Removing core plugin ipad...
Removing core plugin loginmgr...
Removing core plugin lookat...
Removing core plugin rss...
Removing core plugin rssurlrewrite...
Removing core plugin rutracker_check...
Removing core plugin spectrogram...
Removing core plugin xmpp...
Setting custom config for create plugin...
Checking ruTorrent custom plugins...
Checking ruTorrent plugins configuration...
Checking ruTorrent custom themes...
Setting GeoIP2 databases for geoip2 plugin...
  WARNING: geoip2 plugin does not exist
Fixing perms...
[cont-init.d] 03-config.sh: exited 0.
[cont-init.d] 04-create-services.sh: executing... 
[cont-init.d] 04-create-services.sh: exited 0.
[cont-init.d] ~-socklog: executing... 
[cont-init.d] ~-socklog: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
2024/08/24 13:17:27 [notice] 515#515: using the "epoll" event method
2024/08/24 13:17:27 [notice] 515#515: nginx/1.24.0
2024/08/24 13:17:27 [notice] 515#515: OS: Linux 6.6.32-current-meson64
2024/08/24 13:17:27 [notice] 515#515: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/08/24 13:17:27 [notice] 515#515: start worker processes
2024/08/24 13:17:27 [notice] 515#515: start worker process 546
2024/08/24 13:17:27 [notice] 515#515: start worker process 547
2024/08/24 13:17:27 [notice] 515#515: start worker process 548
2024/08/24 13:17:27 [notice] 515#515: start worker process 549
2024/08/24 13:17:27 [notice] 515#515: start worker process 550
2024/08/24 13:17:27 [notice] 515#515: start worker process 570
[24-Aug-2024 13:17:27] NOTICE: fpm is running, pid 519
[24-Aug-2024 13:17:27] NOTICE: ready to handle connections

Additional info

Questions:

V33m commented 2 months ago

I am closing the issue as it is not related to the healthcheck and the performance has very likely been like this for a long while. Healthcheck is correctly disabled for me as seen below.

sudo docker inspect --format='{{json .State.Health}}' rtorrent
null