I have varnish installed on the Ubuntu server 22.04.
The environment is Php8.1 and Varnish 7.3.0.
The server has 16GB RAM.
For me the Varnish keep on crashing intermittently and I get following message.
:~$ sudo service varnish status
× varnish.service - Varnish Cache, a high-performance HTTP accelerator
Loaded: loaded (/etc/systemd/system/varnish.service; enabled; vendor preset: enabled)
Active: failed (Result: oom-kill) since Mon 2023-11-20 13:18:05 UTC; 18s ago
Process: 198053 ExecStart=/usr/sbin/varnishd -a :80 -a localhost:8443,PROXY -p feature=+http2 -p http_resp_hdr_len=35M -p http_resp_size=40M -p workspac>
Main PID: 198054 (code=exited, status=64)
CPU: 14min 39.533s
Nov 20 13:18:05 varnishd[198054]: Manager got SIGTERM
Nov 20 13:18:05 systemd[1]: varnish.service: A process of this unit has been killed by the OOM killer.
Nov 20 13:18:05 varnishd[198054]: Stopping Child
Nov 20 13:18:05 varnishd[198054]: Child (198068) died signal=9
Nov 20 13:18:05 varnishd[198054]: Child cleanup complete
Nov 20 13:18:05 varnishd[198054]: manager stopping child
Nov 20 13:18:05 varnishd[198054]: manager dies
Nov 20 13:18:05 systemd[1]: varnish.service: Main process exited, code=exited, status=64/USAGE
Nov 20 13:18:05 systemd[1]: varnish.service: Failed with result 'oom-kill'.
Nov 20 13:18:05 systemd[1]: varnish.service: Consumed 14min 39.533s CPU time.
lines 1-17/17 (END)
I have following setting in the /etc/systemd/system/varnish.service
ExecStart=/usr/sbin/varnishd \
-a :80 \
-a localhost:8443,PROXY \
-p feature=+http2 \
-p http_resp_hdr_len=35M \
-p http_resp_size=40M \
-p workspace_backend=40M \
-p workspace_client=40M \
-f /etc/varnish/default.vcl \
-s malloc,512m
I have increased the assigned memory to Varnish and also created a swap memory
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
but it still crashes.
How can I fix this issue?