mailserver2 / mailserver

Simple and full-featured mail server using Docker
https://store.docker.com/community/images/mailserver2/mailserver
MIT License
133 stars 28 forks source link

Add option to have ClamAV clamd use less memory on startup #64

Closed ksylvan closed 4 months ago

ksylvan commented 4 months ago

Description

Adds a new variable CLAMD_MEMORY_FIX to use the new ClamAV ConcurrentDatabaseReload option.

This reduces memory in the mailserver container on startup, with the downside that clamd will block any new scans until reload is complete.

Fixes #63

Type of change

Status

How has this been tested ?

Tested this on my production server.

So far, it seems to be working. The load spiked, but not as much as before, then settled back down.

Will keep testing and update the PR.

$ w
 23:46:19 up 10 min,  1 user,  load average: 0.08, 0.10, 0.06
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
deploy   pts/0    76.132.225.162   23:35    1.00s  0.08s  0.00s w

$ docker-compose exec mailserver /bin/bash
root@mail:/# tail /etc/clamav/clamd.conf 
LogFile /var/log/clamav/clamav.log
LogTime true
LogFileUnlock false
LogFileMaxSize 0
Bytecode true
BytecodeSecurity TrustSigned
BytecodeTimeout 60000
OnAccessMaxFileSize 5M
TCPSocket 3310
ConcurrentDatabaseReload no
ksylvan commented 4 months ago

image

After the latest reboot (upon upgrading my base OS to Debian 12 "bookworm"), here is what rspamd status looks like. I am thrilled because this dashboard wasn't even loading recently, and now it comes up fast.

ksylvan commented 4 months ago

I merged this. Without the CLAMD_MEMORY_FIX environment variable, this is a no-op for existing installs, and I've tested this over the last few days on two different production domains I have running the mailserver stack.