Control PanelCWP

How to optimize Varnish cache server in CWP – Control WebPanel Centos7/8, Almalinux, Rockylinux

Varnish is an HTTP accelerator designed for content-heavy dynamic web sites as well as APIs. In contrast to other web accelerators, such as Squid, which began life as a client-side cache, or Apache and nginx, which are primarily origin servers, Varnish was designed as an HTTP accelerator.

Here how you can optimize varnish cache server in CWP

Install Varnish cache from CWP Webserver Settings >> Webserver conf

For Centos 7/EL7 :

Edit this file : /etc/varnish/varnish.params

and replace all lines with the below configs :

# Varnish environment configuration description. This was derived from
# the old style sysconfig/defaults settings
# Set this to 1 to make systemd reload try to switch VCL without restart.
# Set WARMUP_TIME to force a delay in reload-vcl between vcl.load and vcl.use
# This is useful when backend probe definitions need some time before declaring
# configured backends healthy, to avoid routing traffic to a non-healthy backend.
# Main configuration file. You probably want to change it.
# Default address and port to bind to. Blank address means all IPv4
# and IPv6 interfaces, otherwise specify a host name, an IPv4 dotted
# quad, or an IPv6 address in brackets.
# Admin interface listen address and port
# Shared secret file for admin interface
# Backend storage specification, see Storage Types in the varnishd(5)
# man page for details.
# User and group for the varnishd worker processes
# Other options, see the man page varnishd(1)
DAEMON_OPTS="-p thread_pools=30 -p thread_pool_min=600 -p thread_pool_max=20000 -p connect_timeout=600 -p thread_pool_timeout=600 -P /run/"

then restart varnish server from cwp admin dashboard

For centos 8 stream/almalinux/rockylinux :

Edit this systemed service file : /usr/lib/systemd/system/varnish.service

Then find ExecStart= directive and replace the full line with below config :

ExecStart=/usr/sbin/varnishd -a :82 -f /etc/varnish/default.vcl -p thread_pools=30 -p thread_pool_min=600 -p thread_pool_max=20000 -s malloc,1G -p connect_timeout=600 -p thread_pool_timeout=600 -P /run/

it will look like below config example :

Description=Varnish Cache, a high-performance HTTP accelerator


# Maximum number of open files (for ulimit -n)

# Locked shared memory - should suffice to lock the shared memory log
# (varnishd -l argument)
# Default log size is 80MB vsl + 1M vsm + header -> 82MB
# unit is bytes

# Enable this to avoid "fork failed" on reload.

# Maximum size of the corefile.

ExecStart=/usr/sbin/varnishd -a :82 -f /etc/varnish/default.vcl -p thread_pools=30 -p thread_pool_min=600 -p thread_pool_max=20000 -s malloc,1G -p connect_timeout=600 -p thread_pool_timeout=600 -P /run/


Then run daemon reload command :

systemctl daemon-reload

After restart the varnish server from cwp dashbaord.

Sandeep B.

I'm a system admin and php developer and currently working as System Admin In CWP Control panel, expertise in Linux and Windows administration RHEL certified admin.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button