fmartinou / whats-up-docker

What's up Docker ( aka WUD ) gets you notified when a new version of your Docker Container is available.
https://fmartinou.github.io/whats-up-docker
MIT License
939 stars 29 forks source link

LokiJS Sessions collection and High CPU utilization #328

Open enticedwanderer opened 8 months ago

enticedwanderer commented 8 months ago

Environment

Runtime: Plain docker running as root Docker image: fmartinou/whats-up-docker:6.3.0

The issue

I've run into an issue with my instance of whats-up-docker running extremely slowly and poorly. It was basically constantly pegging a cpu core. Furthermore, the app became so slow it was mostly unusable. It would take upwards of 30s for containers to load at all on the web ui. After taking a look with a profiler (command: "node --prof index") I've discovered that:

Now the 2 major issues here are:

  1. The session entries are never pruned from the store which makes all store operation with them slower and slower in memory.
  2. All API calls result in sessions being looked up or stored. External agents like prometheus do not reuse the session and since they can call very frequently many sessions can accumulate quickly.

I can kludge a workaround to clear the sessions collection every once in a while in the meantime to avoid this issue, but in app periodic pruning should address this issue, i.e. remove all expired session entries once an hour and once at the start.

On a side note, I have noticed that LokiJS is now replaced by RxDB and the project is basically dead since 2022. Might want to migrate away from it in the future.