varnishd [-a address[:port][,PROTO]] [-b host[:port]] [-C] [-d] [-F] [-f config] [-h type[,options]] [-i identity] [-j jail[,jailoptions]] [-l vsl[,vsm]] [-M address:port] [-n name] [-P file] [-p param=value] [-r param[,param...]] [-S secret-file] [-s [name=]kind[,options]] [-T address[:port]] [-t TTL] [-V] [-W waiter]
The varnishd daemon accepts HTTP requests from clients, passes them on to a backend server and caches the returned documents to better satisfy future requests for the same document.
When neither a -f nor a -b argument are given, varnishd will not start the worker process but process cli commands.
This option can be used multiple times to specify multiple storage files. Names are referenced in logs, VCL, statistics, etc.
The following hash algorithms are available:
The following storage types are available:
The path is mandatory. If path points to a directory, a temporary file will be created in that directory and immediately unlinked. If path points to a non-existing file, the file will be created.
If size is omitted, and path points to an existing file with a size greater than zero, the size of that file will be used. If not, an error is reported.
Granularity sets the allocation block size. Defaults to the system page size or the filesystem block size, whichever is larger.
Varnish jails are a generalization over various platform specific methods to reduce the privileges of varnish processes. They may have specific options. Available jails are:
With the unix jail technology activated, varnish will switch to an alternative user for subprocesses and change the effective uid of the master process whenever possible.
The optional user argument specifies which alternative user to use. It defaults to varnish
The optional ccgroup argument specifies a group to add to varnish subprocesses requiring access to a c-compiler. There is no default.
If the -T option was specified, varnishd will offer a command-line management interface on the specified address and port. The recommended way of connecting to the command-line management interface is through varnishadm(1).
The commands available are documented in varnish(7).
Runtime parameters are marked with shorthand flags to avoid repeating the same text over and over in the table below. The meaning of the flags are:
We have no solid information about good/bad/optimal values for this parameter. Feedback with experience and observations are most welcome.
This parameter can be changed on the fly, but will not take effect immediately.
The worker process must be stopped and restarted, before this parameter takes effect.
The VCL programs must be reloaded for this parameter to take effect.
We're not really sure about this parameter, tell us what you find.
Do not touch unless you really know what you're doing.
Only works if varnishd is running as root.
Be aware that on 32 bit systems, certain default values are reduced relative to the values listed below, in order to conserve VM space:
This text is produced from the same text you will find in the CLI if you use the param.show command:
Enable kernel accept-filters (if available in the kernel).
If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. This parameter (multiplicatively) reduce the sleep duration for each successful accept. (ie: 0.9 = reduce by 10%)
If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. This parameter control how much longer we sleep, each time we fail to accept a new connection.
If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. This parameter limits how long it can sleep between attempts to accept new connections.
Automatically restart the child/worker process if it dies.
Timeout before we close unused backend connections.
Eliminate older identical bans when a new ban is added. This saves CPU cycles by not comparing objects to identical bans. This is a waste of time if you have many bans which are never identical.
The ban lurker will ignore bans until they are this old. When a ban is added, the active traffic will be tested against it as part of object lookup. This parameter holds the ban-lurker off, until the rush is over.
The ban lurker sleeps ${ban_lurker_sleep} after examining this many objects. Use this to pace the ban-lurker if it eats too many resources.
How long the ban lurker sleeps after examining ${ban_lurker_batch} objects. Use this to pace the ban-lurker if it eats too many resources. A value of zero will disable the ban lurker entirely.
We only wait for this many seconds between bytes received from the backend before giving up the fetch. A value of zero means never give up. VCL values, per backend or per backend request take precedence. This parameter does not apply to pipe'ed requests.
Command used for compiling the C source code to a dlopen(3) loadable object. Any occurrence of %s in the string will be replaced with the source file name, and %o will be replaced with the output file name.
Size of buffer for CLI command input. You may need to increase this if you have big VCL files and use the vcl.inline CLI command. NB: Must be specified with -p to have effect.
Maximum size of CLI response. If the response exceeds this limit, the response code will be 201 instead of 200 and the last line will indicate the truncation.
Timeout for the childs replies to CLI requests from the mgt_param.
How much clockskew we are willing to accept between the backend and our own clock.
Default connection timeout for backend connections. We only try to connect to the backend for this many seconds before giving up. VCL can override this default value for each backend and backend request.
How long the critbit hasher keeps deleted objheads on the cooloff list.
Enable/Disable various kinds of debugging.
Use +/- prefix to set/reset individual bits:
Default grace period. We will deliver an object this long after it has expired, provided another thread is attempting to get a new copy.
Default keep period. We will keep a useless object around this long, making it available for conditional backend fetches. That means that the object will be removed from the cache at the end of ttl+grace+keep.
The TTL assigned to objects if neither the backend nor the VCL code assigns one.
Enable/Disable various minor features.
Use +/- prefix to enable/disable individual feature:
The default chunksize used by fetcher. This should be bigger than the majority of objects with short TTLs. Internal limits in the storage_file module makes increases above 128kb a dubious idea.
The maximum chunksize we attempt to allocate from storage. Making this too large may cause delays and storage fragmentation.
Default timeout for receiving first byte from backend. We only wait for this many seconds for the first byte before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend and backend request. This parameter does not apply to pipe.
Size of malloc buffer used for gzip processing. These buffers are used for in-transit data, for instance gunzip'ed data being sent to a client.Making this space to small results in more overhead, writes to sockets etc, making it too big is probably just a waste of memory.
Gzip compression level: 0=debug, 1=fast, 9=best
Gzip memory level 1=slow/least, 9=fast/most compression. Memory impact is 1=1k, 2=2k, ... 9=256k.
Clients that do not support gzip will have their Accept-Encoding header removed. For more information on how gzip is implemented please see the chapter on gzip in the Varnish reference.
Maximum number of HTTP header lines we allow in {req|resp|bereq|beresp}.http (obj.http is autosized to the exact number of headers). Cheap, ~20 bytes, in terms of workspace memory. Note that the first line occupies five header lines.
Enable support for HTTP Range headers.
Maximum length of any HTTP client request header we will allow. The limit is inclusive its continuation lines.
Maximum number of bytes of HTTP client request we will deal with. This is a limit on all bytes up to the double blank line which ends the HTTP request. The memory for the request is allocated from the client workspace (param: workspace_client) and this parameter limits how much of that the request is allowed to take up.
Maximum length of any HTTP backend response header we will allow. The limit is inclusive its continuation lines.
Maximum number of bytes of HTTP backend response we will deal with. This is a limit on all bytes up to the double blank line which ends the HTTP request. The memory for the request is allocated from the backend workspace (param: workspace_backend) and this parameter limits how much of that the request is allowed to take up.
Time to wait with no data sent. If no data has been transmitted in this many seconds the session is closed. See setsockopt(2) under SO_SNDTIMEO for more information.
Listen queue depth.
Grace period before object moves on LRU list. Objects are only moved to the front of the LRU list if they have not been moved there already inside this timeout period. This reduces the amount of lock operations necessary for LRU list access.
Maximum depth of esi:include processing.
Upper limit on how many times a request can restart. Be aware that restarts are likely to cause a hit against the backend, so don't increase thoughtlessly.
Upper limit on how many times a backend fetch can retry.
Maximum number of objects we attempt to nuke in order to make space for a object body.
The limit for the number of calls to the internal match() function in pcre_exec().
(See: PCRE_EXTRA_MATCH_LIMIT in pcre docs.)
This parameter limits how much CPU time regular expression matching can soak up.
The recursion depth-limit for the internal match() function in a pcre_exec().
(See: PCRE_EXTRA_MATCH_LIMIT_RECURSION in pcre docs.)
This puts an upper limit on the amount of stack used by PCRE for certain classes of regular expressions.
We have set the default value low in order to prevent crashes, at the cost of possible regexp matching failures.
Matching failures will show up in the log as VCL_Error messages with regexp errors -27 or -21.
Testcase r01576 can be useful when tuning this parameter.
Interval between pings from parent to child. Zero will disable pinging entirely, which makes it possible to attach a debugger to the child.
Idle timeout for PIPE sessions. If nothing have been received in either direction for this many seconds, the session is closed.
Parameters for per worker pool request memory pool. The three numbers are:
Parameters for per worker pool session memory pool. The three numbers are:
Parameters for backend object fetch memory pool. The three numbers are:
Prefer IPv6 address when connecting to backends which have both IPv4 and IPv6 addresses.
How many parked request we start for each completed request on the object. NB: Even with the implict delay of delivery, this parameter controls an exponential increase in number of worker threads.
Send timeout for client connections. If the HTTP response hasn't been transmitted in this many seconds the session is closed. See setsockopt(2) under SO_SNDTIMEO for more information.
Maximum number of sessions we will allocate from one pool before just dropping connections. This is mostly an anti-DoS measure, and setting it plenty high should not hurt, as long as you have the memory for it.
Old name for vsl_reclen, use that instead.
Objects created with (ttl+grace+keep) shorter than this are always put in transient storage.
Install a signal handler which tries to dump debug information on segmentation faults, bus errors and abort signals.
Log all CLI traffic to syslog(LOG_INFO).
The number of seconds between TCP keep-alive probes.
The maximum number of TCP keep-alive probes to send before giving up and killing the connection if no response is obtained from the other end.
The number of seconds a connection needs to be idle before TCP begins sending out keep-alive probes.
Wait at least this long after creating a thread.
Some (buggy) systems may need a short (sub-second) delay between creating threads. Set this to a few milliseconds if you see the 'threads_failed' counter grow too much.
Setting this too high results in insuffient worker threads.
Wait this long after destroying a thread.
This controls the decay of thread pools when idle(-ish).
Wait at least this long after a failed thread creation before trying to create another thread.
Failure to create a worker thread is often a sign that the end is near, because the process is running out of some resource. This delay tries to not rush the end on needlessly.
If thread creation failures are a problem, check that thread_pool_max is not too high.
It may also help to increase thread_pool_timeout and thread_pool_min, to reduce the rate at which treads are destroyed and later recreated.
The maximum number of worker threads in each pool.
Do not set this higher than you have to, since excess worker threads soak up RAM and CPU and generally just get in the way of getting work done.
The minimum number of worker threads in each pool.
Increasing this may help ramp up faster from low load situations or when threads have expired.
Minimum is 10 threads.
Worker thread stack size. This will likely be rounded up to a multiple of 4k (or whatever the page_size might be) by the kernel.
Thread idle threshold.
Threads in excess of thread_pool_min, which have been idle for at least this long, will be destroyed.
Number of worker thread pools.
Increasing number of worker pools decreases lock contention.
Too many pools waste CPU and RAM resources, and more than one pool for each CPU is probably detrimal to performance.
Can be increased on the fly, but decreases require a restart to take effect.
Permitted queue length per thread-pool.
This sets the number of requests we will queue, waiting for an available thread. Above this limit sessions will be dropped instead of queued.
Worker threads accumulate statistics, and dump these into the global stats counters if the lock is free when they finish a job (request/fetch etc.) This parameters defines the maximum number of jobs a worker thread may handle, before it is forced to dump its accumulated stats into the global counters.
Idle timeout for client connections. A connection is considered idle, until we have received the full request headers.
How long the worker thread lingers on an idle session before handing it over to the waiter. When sessions are reused, as much as half of all reuses happen within the first 100 msec of the previous request completing. Setting this too high results in worker threads not doing anything for their keep, setting it too low just means that more sessions take a detour around the waiter.
Allow inline C code in VCL.
Unreferenced VCL objects result in error.
Allow '/' in vmod & include paths. Allow 'import ... from ...'.
How long a VCL is kept warm after being replaced as the active VCL (granularity approximately 30 seconds).
Directory (or colon separated list of directories) from which relative VCL filenames (vcl.load and include) are to be found.
Directory (or colon separated list of directories) where VMODs are to be found.
Bytes of (req-/backend-)workspace dedicated to buffering VSL records. Setting this too high costs memory, setting it too low will cause more VSL flushes and likely increase lock-contention on the VSL mutex.
The minimum tracks the vsl_reclen parameter + 12 bytes.
Mask individual VSL messages from being logged.
Use +/- prefix in front of VSL tag name, to mask/unmask individual VSL messages.
Maximum number of bytes in SHM log record.
The maximum tracks the vsl_buffer parameter - 12 bytes.
The amount of space to allocate for the VSL fifo buffer in the VSM memory segment. If you make this too small, varnish{ncsa|log} etc will not be able to keep up. Making it too large just costs memory resources.
The amount of space to allocate for stats counters in the VSM memory segment. If you make this too small, some counters will be invisible. Making it too large just costs memory resources.
Bytes of HTTP protocol workspace for backend HTTP req/resp. If larger than 4k, use a multiple of 4k for VM efficiency.
Bytes of HTTP protocol workspace for clients HTTP req/resp. If larger than 4k, use a multiple of 4k for VM efficiency.
Allocation size for session structure and workspace. The workspace is primarily used for TCP connection addresses. If larger than 4k, use a multiple of 4k for VM efficiency.
Bytes of auxiliary workspace per thread. This workspace is used for certain temporary data structures during the operation of a worker thread. One use is for the io-vectors for writing requests and responses to sockets, having too little space will result in more writev(2) system calls, having too much just wastes the space.
Varnish and bundled tools will, in most cases, exit with one of the following codes
The varnishd master process may also OR its exit code
The varnishd daemon was developed by Poul-Henning Kamp in cooperation with Verdens Gang AS and Varnish Software.
This manual page was written by Dag-Erling Smørgrav with updates by Stig Sandbeck Mathisen <ssm@debian.org>, Nils Goroll and others.
This document is licensed under the same licence as Varnish itself. See LICENCE for details.