trilium icon indicating copy to clipboard operation
trilium copied to clipboard

(Bug report) Avoid CPU Usage Spikes by improving the healthcheck script

Open AuthorShin opened this issue 1 year ago • 3 comments

Trilium Version

v0.62.5 Docker

What operating system are you using?

Other (specify below)

What is your setup?

Server access only

Operating System Version

Linux Vision 6.1.0-17-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.69-1 (2023-12-30) x86_64 GNU/Linux

Description

Hello I was checking the CPU usage of the docker container of trilium and realized that there are big CPU spikes every 30 seconds which I believe is caused by the healthcheck script which we encountered on the other docker container for another app which might help you to fix the problem easier, you can read about and see the result of it here : https://github.com/louislam/uptime-kuma/issues/2249

Also It's worth mentioning that it's a fresh install of trilium and there's no data that being added to it, which makes me wonder why there are a lot of disk writes cause by trilium all the time even we it's not open in the browser and there are no activities and no sync and no backup is active but the writes are consistent.

Error logs

Docker container of trilium logs

200 GET /api/health-check with 15 bytes took 0ms

200 GET /api/health-check with 15 bytes took 1ms

200 GET /api/health-check with 15 bytes took 2ms

200 GET /api/health-check with 15 bytes took 1ms

200 GET /api/health-check with 15 bytes took 1ms

200 GET /api/health-check with 15 bytes took 0ms

200 GET /api/health-check with 15 bytes took 0ms

200 GET /api/health-check with 15 bytes took 0ms

200 GET /api/health-check with 15 bytes took 2ms

200 GET /api/health-check with 15 bytes took 1ms

200 GET /api/health-check with 15 bytes took 0ms

200 GET /api/health-check with 15 bytes took 1ms

200 GET /api/health-check with 15 bytes took 0ms

200 GET /api/health-check with 15 bytes took 1ms

200 GET /api/health-check with 15 bytes took 2ms

200 GET /api/health-check with 15 bytes took 1ms

200 GET /api/health-check with 15 bytes took 1ms

AuthorShin avatar Jan 08 '24 17:01 AuthorShin

Hmm, healthcheck is a super simple implementation of returning just constant response. This shouldn't be causing CPU spikes.

zadam avatar Jan 09 '24 22:01 zadam

@zadam I monitored the CPU usage of the container with Portainer, you can verify that as well.

AuthorShin avatar Jan 16 '24 21:01 AuthorShin

Hmm, healthcheck is a super simple implementation of returning just constant response. This shouldn't be causing CPU spikes.

Based on a cursory glance, I think the reported issue is that the current healthcheck launches node since the linked project fixed this issue by moving their healthcheck to a go-based implementation ( https://github.com/louislam/uptime-kuma/blob/482049c72b3a650c7bc5c26c2f4d57a21c0e0aa0/extra/healthcheck.js and https://github.com/louislam/uptime-kuma/blob/482049c72b3a650c7bc5c26c2f4d57a21c0e0aa0/extra/healthcheck.go ).

Not endorsing a go-based approach, but the follow-on issues with Portainer after moving to a new healthcheck are worth keeping an eye out for if a new healthcheck is implemented ( https://github.com/louislam/uptime-kuma/issues/2774#issuecomment-1429092359 ).

PretzelVector avatar Jan 23 '24 22:01 PretzelVector