Warracker icon indicating copy to clipboard operation
Warracker copied to clipboard

memory usage

Open luci-serendipity opened this issue 1 year ago • 18 comments

Warracker appears to be using 3x more RAM than expected. This will ultimately limit what types of servers it can run on. I'm currently seeing about 150mb RAM utilization from the warracker front-end. the db is using about 36mb which is expected. version 0.9.9.8

luci-serendipity avatar May 29 '25 19:05 luci-serendipity

Hello @icywhisker-official!

Do you have email notifications enabled?

And are your files and documents running on a separate volume?

sassanix avatar May 29 '25 20:05 sassanix

E-mail notifications are turned off. I'm not really sure if 150mb ram utilization is normal. it seems not though. the docker is running send_expiration_notifications every 2 minutes

luci-serendipity avatar May 29 '25 20:05 luci-serendipity

Couple of things are not optimized.

And the email notification runs in the background even if it's turned off.

I'm investigating as well.

For your storage what have you set?

sassanix avatar May 29 '25 20:05 sassanix

this is running on a google container optimized os. its root fs is read only (sda). sdb is where the warracker db is mounted to

[Unit] Description=Warracker Service After=warrackerdb.service

[Service] ExecStart=/usr/bin/docker run --rm
--network actual-net
--name warracker
-p 8005:80
-v /mnt/disks/data/warracker/uploads:/data/uploads
-e DB_HOST=warrackerdb
-e DB_NAME=warranty_db
-e DB_USER=warranty_user
-e DB_PASSWORD=${DB_PASSWORD:-warranty_password}
-e SMTP_HOST=smtp.email.com
-e SMTP_PORT=465
-e SMTP_USERNAME=REDACTED
-e SMTP_PASSWORD=REDACTED
ghcr.io/sassanix/warracker/main:latest

ExecStop=/usr/bin/docker stop warracker ExecStopPost=/usr/bin/docker rm -f warracker

[Install] WantedBy=multi-user.target [Unit] Description=Warracker DB After=fs-prep.service network-online.target docker.service

[Service] ExecStart=/usr/bin/docker run --rm
--network actual-net
--name warrackerdb
-v /mnt/disks/data/warracker/db:/var/lib/postgresql/data
-e POSTGRES_DB=warranty_db
-e POSTGRES_USER=warranty_user
-e POSTGRES_PASSWORD=${DB_PASSWORD:-warranty_password}
--health-cmd="pg_isready -U warranty_user -d warranty_db"
--health-interval=5s
--health-timeout=5s
--health-retries=5
postgres:15-alpine

ExecStop=/usr/bin/docker stop warrackerdb ExecStopPost=/usr/bin/docker rm -f warrackerdb

[Install] WantedBy=multi-user.target

luci-serendipity avatar May 29 '25 21:05 luci-serendipity

Thanks for that, how many warranties have you added in total?

sassanix avatar May 29 '25 21:05 sassanix

1

luci-serendipity avatar May 29 '25 21:05 luci-serendipity

1

And there are no large documents added correct?

Can you change the storage limit from 32 MB's to 16 and restart your application, and see if that reduced it a little bit.

sassanix avatar May 29 '25 21:05 sassanix

I found it. each gunicorn worker uses about 45mb.

luci-serendipity avatar May 29 '25 21:05 luci-serendipity

I'm working on having different memory modes to increase efficiency.

Right now, there's 4 workers.

sassanix avatar May 29 '25 21:05 sassanix

this app is designed to support multiple users which makes sense however, there doesnt seem to be any real need for multiple workers if there is only one user in the db. perhaps that check can be built in and for every 5 users, increase the worker count exponentially until a limit is reached?

luci-serendipity avatar May 29 '25 21:05 luci-serendipity

I will give the option to the users, if they want to use the least amount of ram on their VPS or Raspberry Pie's I will set up 1 worker, which will handle the workload well.

So three different modes, optimized, ultra-light, and performance, which can be setup through .env or within docker-compose.

Thanks for letting me know, I also need to work on the email notification scheduler to stay disabled when it's disabled in the settings.

sassanix avatar May 29 '25 21:05 sassanix

docker compose is ideal for me. I can build it into the service

luci-serendipity avatar May 29 '25 21:05 luci-serendipity

With over 6 warranties, I have brought it down to this much usage.

Image

sassanix avatar May 31 '25 19:05 sassanix

I believe actual budgeting software merged their server and front end into one docker. If the same thing is done here, it may drastically improve memory usage and processing times. The current usage that this application has will limit the amount of future projects I add to my server unless I add swap.

luci-serendipity avatar May 31 '25 19:05 luci-serendipity

I will look into how actual budget has it setup, that's very interesting. I will look into it, but in the meantime I have the optimized versions that can be utilized through the environment variables.

sassanix avatar May 31 '25 20:05 sassanix

I wouldn't focus on merging or even optimizing until after initial release. Features first, bugs second, optimization 3rd. That seems like a good idea

luci-serendipity avatar May 31 '25 21:05 luci-serendipity

HI @icywhisker-official,

Thanks again for bringing it to my attention, I appreciate your feedback! :)

I have released the enhancements under the latest release, you can use the environments in your docker-compose this way:

Memory optimization mode

Options: optimized (default), ultra-light, performance

  • optimized: 2 workers, ~60-80MB RAM usage (recommended for most deployments)
  • ultra-light: 1 worker, ~40-50MB RAM usage (for very limited resources)
  • performance: 4 workers, ~150-200MB RAM usage (for high-traffic deployments)

WARRACKER_MEMORY_MODE=optimized

sassanix avatar Jun 01 '25 19:06 sassanix

The app runs at around 60-80mb. Thanks for the improvement!

It is possible to save an overall 30-50mb of RAM by implementing further optimizations. This could include using a different db provider such as sqllite; merging the two dockers into one; allowing the e-mail server to be optional; using a different web hoster other than nginx; using waitress instead of gunicorn

luci-serendipity avatar Jun 01 '25 23:06 luci-serendipity