# Configuration file for varnish
#
# /etc/init.d/varnish expects the variable $DAEMON_OPTS to be set from this
# shell script fragment.
#
# Maximum number of open files (for ulimit -n)
NFILES=131072 #打开文件数目的限制的默认值
# Locked shared memory (for ulimit -l)
# Default log size is 82MB + header
MEMLOCK=82000 #应该是共享内存的默认值吧
# Maximum number of threads (for ulimit -u)
NPROCS="unlimited" #最大线程数的默认值
# Maximum size of corefile (for ulimit -c). Default in Fedora is 0
# DAEMON_COREFILE_LIMIT="unlimited"
# Set this to 1 to make init script reload try to switch vcl without restart.
# To make this work, you need to set the following variables
# explicit: VARNISH_VCL_CONF, VARNISH_ADMIN_LISTEN_ADDRESS,
# VARNISH_ADMIN_LISTEN_PORT, VARNISH_SECRET_FILE, or in short,
# use Alternative 3, Advanced configuration, below
RELOAD_VCL=1 #选择VCL配置文件的模式
# This file contains 4 alternatives, please use only one.
## Alternative 1, Minimal configuration, no VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# content server on localhost:8080. Use a fixed-size cache file.
#
#DAEMON_OPTS="-a :6081 \
# -T localhost:6082 \
# -b localhost:8080 \
# -u varnish -g varnish \
# -s file,/var/lib/varnish/varnish_storage.bin,1G"
## Alternative 2, Configuration with VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# one content server selected by the vcl file, based on the request. Use a
# fixed-size cache file.
#
#DAEMON_OPTS="-a :6081 \
# -T localhost:6082 \
# -f /etc/varnish/default.vcl \
# -u varnish -g varnish \
# -S /etc/varnish/secret \
# -s file,/var/lib/varnish/varnish_storage.bin,1G"
## Alternative 3, Advanced configuration
#
# See varnishd(1) for more information.
#
# # Main configuration file. You probably want to change it :)
VARNISH_VCL_CONF=/etc/varnish/default.vcl #VCL配置文件的位置
#
# # 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.
VARNISH_LISTEN_ADDRESS=127.0.0.1 #varnish的监听地址
VARNISH_LISTEN_PORT=6081 #varnish的监听端口
#
# # Telnet admin interface listen address and port
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1 #varnish管理工具访问的监听地址
VARNISH_ADMIN_LISTEN_PORT=6082 #varnish管理工具访问的监听端口
#
# # Shared secret file for admin interface
VARNISH_SECRET_FILE=/etc/varnish/secret #varnish管理工具所需的共享密钥
#
# # The minimum number of worker threads to start
VARNISH_MIN_THREADS=50 #varnish启动时开启的最小线程数默认值
#
# # The Maximum number of worker threads to start
VARNISH_MAX_THREADS=1000 #最大能达到的线程数默认值
#
# # Idle timeout for worker threads
VARNISH_THREAD_TIMEOUT=120 #好像是一个线程空闲120s就自动回收吧
#
# # Cache file location
VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin #varnish缓存文件的路径
#
# # Cache file size: in bytes, optionally using k / M / G / T suffix,
# # or in percentage of available disk space using the % suffix.
VARNISH_STORAGE_SIZE=2G #varnish缓存的大小,默认值是1G
#
# # Backend storage specification
#VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}" #varnish采用系统文件方式缓存
VARNISH_STORAGE="malloc,${VARNISH_STORAGE_SIZE}" #varnish直接使用内存方式缓存
#varnish缓存有三种方式,file,malloc,persistent
#file就是先创建一个系统文件,然后再用二分法分段方式映射到内存中缓存数据(二分法分段方式是啥我也不懂,网上看的,另外应该是先存数据到系统文件中,再映射到内存中,一般是设备内存较小或者VPS之类的才用这种方式,这个对系统IO有较大影响),另外网上是说file方式有个缺点是缓存系统文件不会自动清除,要手工清除。
#土豪,内存较多的系统肯定是用malloc方式了,这个是直接在内存中开辟一块空间给varnish缓存数据,优点是速度快,但缺点是服务停止或者系统挂了重启服务时,内存中的缓存容易丢失,建议在varnish后面再加个squid集群,避免对后端造成冲击
#persistent方式,测试阶段,跟file方式类似,好像是说优点介于file和malloc之间,另外没有在重启后残留缓存系统文件的缺点了
#
# # Default TTL used when the backend does not specify one
VARNISH_TTL=120
#
# # DAEMON_OPTS is used by the init script. If you add or remove options, make
# # sure you update this section, too.
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
-f ${VARNISH_VCL_CONF} \
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
-t ${VARNISH_TTL} \
-w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_T IMEOUT} \
-u varnish -g varnish \
-S ${VARNISH_SECRET_FILE} \
-s ${VARNISH_STORAGE}"
#
## Alternative 4, Do It Yourself. See varnishd(1) for more information.
#
# DAEMON_OPTS=""