Author: | Dag-Erling Smørgrav |
---|---|
Author: | Stig Sandbeck Mathisen |
Author: | Per Buer |
Date: | 2010-05-31 |
Version: | 1.0 |
Manual section: | 1 |
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.
-C | Print VCL code compiled to C language and exit. Specify the VCL file to compile with the -f option. |
-d | Enables debugging mode: The parent process runs in the foreground with a CLI connection on stdin/stdout, and the child process must be started explicitly with a CLI command. Terminating the parent process will also terminate the child. |
-F | Run in the foreground. |
-f config | Use the specified VCL configuration file instead of the builtin default. See vcl(7) for details on VCL syntax. When no configuration is supplied varnishd will not start the cache process. |
-g group | Specifies the name of an unprivileged group to which the child process should switch before it starts accepting connections. This is a shortcut for specifying the group run-time parameter. |
-i identity | Specify the identity of the varnish server. This can be accessed using server.identity from VCL |
-l shmlogsize | Specify size of shmlog file. Scaling suffixes like 'k', 'm' can be used up to (e)tabytes. Default is 80 Megabytes. Specifying less than 8 Megabytes is unwise. |
-n name | Specify a name for this instance. Amonst other things, this name is used to construct the name of the directory in which varnishd keeps temporary files and persistent state. If the specified name begins with a forward slash, it is interpreted as the absolute path to the directory which should be used for this purpose. |
-P file | Write the process's PID to the specified file. |
-S file | Path to a file containing a secret used for authorizing access to the management port. |
-t ttl | Specifies a hard minimum time to live for cached documents. This is a shortcut for specifying the default_ttl run-time parameter. |
-u user | Specifies the name of an unprivileged user to which the child process should switch before it starts accepting connections. This is a shortcut for specifying the user run- time parameter. If specifying both a user and a group, the user should be specified first. |
-V | Display the version number and exit. |
-w min[,max[,timeout]]
Start at least min but no more than max worker threads with the specified idle timeout. This is a shortcut for specifying the thread_pool_min, thread_pool_max and thread_pool_timeout run-time parameters.
If only one number is specified, thread_pool_min and thread_pool_max are both set to this number, and thread_pool_timeout has no effect.
The following hash algorithms are available:
The following storage types are available:
malloc[,size]
Malloc is a memory based backend. Each object will be allocated from memory. If your system runs low on memory swap will be used. Be aware that the size limitation only limits the actual storage and that approximately 1k of memory per object will be used for various internal structures.
The size parameter specifies the maximum amount of memory varnishd will allocate. The size is assumed to be in bytes, unless followed by one of the following suffixes:
K, k The size is expressed in kibibytes.
M, m The size is expressed in mebibytes.
G, g The size is expressed in gibibytes.
T, t The size is expressed in tebibytes.
The default size is unlimited.
Mallocs performance is bound by memory speed so it is very fast.
file[,path[,size[,granularity]]]
The file backend stores objects in memory backed by a file on disk with mmap. This is the default storage backend and unless you specify another storage this one will used along with Transient storage.
The path parameter specifies either the path to the backing file or the path to a directory in which varnishd will create the backing file. The default is /tmp.
The size parameter specifies the size of the backing file. The size is assumed to be in bytes, unless fol‐ lowed by one of the following suffixes:
K, k The size is expressed in kibibytes.
M, m The size is expressed in mebibytes.
G, g The size is expressed in gibibytes.
T, t The size is expressed in tebibytes.
- % The size is expressed as a percentage of the free space on the
- file system where it resides.
The default size is 50%.
If the backing file already exists, it will be truncated or expanded to the specified size.
Note that if varnishd has to create or expand the file, it will not pre-allocate the added space, leading to fragmentation, which may adversely impact performance. Pre-creating the storage file using dd(1) will reduce fragmentation to a minimum.
The granularity parameter specifies the granularity of allocation. All allocations are rounded up to this size. The size is assumed to be in bytes, unless followed by one of the suffixes described for size except for %.
The default size is the VM page size. The size should be reduced if you have many small objects.
File performance is typically limited by the write speed of the device, and depending on use, the seek time.
persistent,path,size {experimental}
Persistent storage. Varnish will store objects in a file in a manner that will secure the survival of most of the objects in the event of a planned or unplanned shutdown of Varnish.
The path parameter specifies the path to the backing file. If the file doesn't exist Varnish will create it.
The size parameter specifies the size of the backing file. The size is assumed to be in bytes, unless followed by one of the following suffixes:
K, k The size is expressed in kibibytes.
M, m The size is expressed in mebibytes.
G, g The size is expressed in gibibytes.
T, t The size is expressed in tebibytes.
Varnish will split the file into logical silos and write to the silos in the manner of a circular buffer. Only one silo will be kept open at any given point in time. Full silos are sealed. When Varnish starts after a shutdown it will discard the content of any silo that isn't sealed.
If you name any of your storage backend "Transient" it will be used for transient (short lived) objects. By default Varnish would use an unlimited malloc backend for this.
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:
Here is a list of all parameters, current as of last time we remembered to update the manual page. This text is produced from the same text you will find in the CLI if you use the param.show command, so should there be a new parameter which is not listed here, you can find the description using the CLI commands.
Be aware that on 32 bit systems, certain default values, such as workspace_client (=16k), thread_pool_workspace (=16k), http_resp_size (=8k), http_req_size (=12k), gzip_stack_buffer (=4k) and thread_pool_stack (=64k) are reduced relative to the values listed here, in order to conserve VM space.
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 succesfull 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.
Restart child process automatically if it dies.
Detect and eliminate duplicate bans.
How long time does the ban lurker thread sleeps between successful attempts to push the last item up the ban list. It always sleeps a second when nothing can be done. A value of zero disables the ban lurker.
Default timeout between bytes when receiving data from backend. We only wait for this many seconds between bytes before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend request and backend request. This parameter does not apply to pipe.
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 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.
Timeout for the childs replies to CLI requests from the master.
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 time the critbit hasher keeps deleted objheads on the cooloff list.
Default grace period. We will deliver an object this long after it has expired, provided another thread is attempting to get a new copy. Objects already cached will not be affected by changes made until they are fetched from the backend again.
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. Objects already cached will not be affected by changes made until they are fetched from the backend again. To force an immediate effect at the expense of a total flush of the cache use "ban.url ."
Bitmap controlling diagnostics code:
0x00000001 - CNT_Session states.
0x00000002 - workspace debugging.
0x00000004 - kqueue debugging.
0x00000008 - mutex logging.
0x00000010 - mutex contests.
0x00000020 - waiting list.
0x00000040 - object workspace.
0x00001000 - do not core-dump child process.
0x00002000 - only short panic message.
0x00004000 - panic to stderr.
0x00010000 - synchronize shmlog.
0x00020000 - synchronous start of persistence.
0x00040000 - release VCL early.
0x00080000 - ban-lurker debugging.
0x80000000 - do edge-detection on digest.
Use 0x notation and do the bitor in your head :-)
Bitmap controlling ESI parsing code:
0x00000001 - Don't check if it looks like XML
0x00000002 - Ignore non-esi elements
0x00000004 - Emit parsing debug records
0x00000008 - Force-split parser input (debugging)
Use 0x notation and do the bitor in your head :-)
How long the expiry thread sleeps when there is nothing for it to do.
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.
The unprivileged group to run as.
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.
Size of stack buffer used for gzip processing. The stack 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.
Where temporary space for gzip/gunzip is allocated:
0 - malloc
1 - session workspace
2 - thread workspace
If you have much gzip/gunzip activity, it may be an advantage to use workspace for these allocations to reduce malloc activity. Be aware that gzip needs 256+KB and gunzip needs 32+KB of workspace (64+KB if ESI processing).
Gzip window size 8=least, 15=most compression. Memory impact is 8=1k, 9=2k, ... 15=128k.
Enable gzip support. When enabled Varnish will compress uncompressed objects before they are stored in the cache. If a client does not support gzip encoding Varnish will uncompress compressed objects on demand. Varnish will also rewrite the Accept-Encoding header of clients indicating support for gzip to:
Accept-Encoding: gzip
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 headers we will deal with in client request or backend reponses. Note that the first line occupies five header fields. This paramter does not influence storage consumption, objects allocate exact space for the headers they store.
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 session workspace (param: sess_workspace) 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 resonse 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 worker workspace (param: sess_workspace) 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.
Whitespace separated list of network endpoints where Varnish will accept requests. Possible formats: host, host:port, :port
Listen queue depth.
Log the hash string components to shared memory log.
Log the local address on the TCP connection in the SessionOpen shared memory record.
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.
Maximum number of objects we attempt to nuke in orderto make space for a object body.
The limit for the number of internal matching function calls in a pcre_exec() execution.
The limit for the number of internal matching function recursions in a pcre_exec() execution.
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.
Prefer IPv6 address when connecting to backends which have both IPv4 and IPv6 addresses.
Percentage permitted queue length.
This sets the ratio of queued requests to worker threads, above which sessions will be dropped instead of queued.
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.
The maximum number of objects held off by saint mode before no further will be made to the backend until one times out. A value of 0 disables saintmode.
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.
Idle timeout for persistent sessions. If a HTTP request has not been received in this many seconds, the session is closed.
Bytes of HTTP protocol workspace allocated for sessions. This space must be big enough for the entire HTTP protocol header and any edits done to it in the VCL code. Minimum is 1024 bytes.
How long time the workerthread lingers on the session to see if a new request appears right away. If 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.
Maximum number of sessions we will allocate 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.
Maximum number of bytes in SHM log record. Maximum is 65535 bytes.
Bytes of shmlog workspace allocated for worker threads. If too big, it wastes some ram, if too small it causes needless flushes of the SHM workspace. These flushes show up in stats as "SHM flushes due to overflow". Minimum is 4096 bytes.
Objects created with TTL shorter than this are always put in transient storage.
Log all CLI traffic to syslog(LOG_INFO).
Wait at least this long between creating threads.
Setting this too long results in insuffient worker threads.
Setting this too short increases the risk of worker thread pile-up.
Overflow threshold for worker thread creation.
Setting this too low, will result in excess worker threads, which is generally a bad idea.
Setting it too high results in insuffient worker threads.
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 RAM resources for thread stacks. This delay tries to not rush it 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 where threads have expired.
Minimum is 2 threads.
Wait this long between purging threads.
This controls the decay of thread pools when idle(-ish).
Minimum is 100 milliseconds.
Worker thread stack size. On 32bit systems you may need to tweak this down to fit many threads into the limited address space.
Thread idle threshold.
Threads in excess of thread_pool_min, which have been idle for at least this long are candidates for purging.
Minimum is 1 second.
Bytes of HTTP protocol workspace allocated for worker threads. This space must be big enough for the backend request and responses, and response to the client plus any other memory needs in the VCL code.Minimum is 1024 bytes.
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.
Worker threads accumulate statistics, and dump these into the global stats counters if the lock is free when they finish a request. This parameters defines the maximum number of requests a worker thread may handle, before it is forced to dump its accumulated stats into the global counters.
The unprivileged user to run as. Setting this will also set "group" to the specified user's primary group.
Unreferenced VCL objects result in error.
Directory from which relative VCL filenames (vcl.load and include) are opened.
Trace VCL execution in the shmlog. Enabling this will allow you to see the path each request has taken through the VCL program. This generates a lot of logrecords so it is off by default.
Directory where VCL modules are to be found.
Select the waiter kernel interface.
The varnishd daemon was developed by Poul-Henning Kamp in cooperation with Verdens Gang AS, Varnish Software AS and Varnish Software.
This manual page was written by Dag-Erling Smørgrav with updates by Stig Sandbeck Mathisen ⟨ssm@debian.org⟩
This document is licensed under the same licence as Varnish itself. See LICENCE for details.