To make sure your Magento 2 installation is performing at it's best there are a number of small checks you can carry to ensure everything is healthy.
One of these is to make sure Varnish has enough memory.
You can test this by running
varnishstat -f "MAIN.n_lru_nuked" -f "SMA.s0.g_bytes" -f "SMA.s0.g_space" -1
This will give you an output like
MAIN.n_lru_nuked 539738 . Number of LRU nuked objects SMA.s0.g_bytes 5368661301 . Bytes outstanding SMA.s0.g_space 47819 . Bytes available
- MAIN.n_lru_nuked - the number of items removed from Varnish cache because it doesn't have enough memory.
- SMA.s0.g_bytes - the amount of space (in bytes) that Varnish is allowed to use.
- SMA.s0.g_space - the amount of space (in bytes) that varnish is allocated but not using.
- If MAIN.n_lru_nuked is greater than 0 this suggests Varnish doesn't have enough memory and needs increasing.
- If SMA.s0.g_space is less than 10000000 this mean Varnish has less than 10mb of space available. This also suggests Varnish doesn't have enough memory and it needs to be increased.
Increasing Varnish Storage Space
Before doing this, make sure your server has enough memory available.
All servers are slightly different, so the exact steps may differ but the process will be the same.
- Locate where your Varnish service config lives
grep -r malloc /etc/varnish/
You may see something like
- Increase this value, using your prefered text editor
- Restart Varnish
systemctl restart varnishd