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
This will give you an output like
Terms Explained
- 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.
Quick Checks
- 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
nano /etc/varnish/varnish.params
- Restart Varnish
systemctl restart varnishd