Varnish命令行工具使用介绍
varnish的线程模型: cache-worker线程 cache-main线程:此线程只有一个,用于启动caceh; ban luker:实现缓存清理 acceptor:接受用户请求 epoll:线程池管理器 expire:清理过期缓存 varnish工作特性: ***** varnish> param.show -l 定义acceptor线程工作特性 acceptor_sleep_decay acceptor_sleep_incr acceptor_sleep_max auto_restart 必要时要不要重启某一个cache线程,默认为on ban_dups 重复的是否自动清理 脚本中定义 thread_pool_max 默认500,最大并发线程数 thread_pool_min 启动时要启动的线程数默认为5个 varnish定义其最大并发连接数:是通过线程池模型定义: thread_pools:线程池个数;默认为2; thread_pool_max:单线程池内允许启动的最多线程个数;大约超过5000个将不太稳定 thread_pool_min:启动时要启动的线程数最少线程数,默认为5个 thread_pool_timeout:多于thread_pool_min的线程空闲此参数指定的时长后即被purge; thread_pool_purge_delay :清理空闲线程,1000毫秒被清理 thread_pool_stack :工作线程站有多大,默认为-1,不做限制 thread_pool_workspace:线程池工作空间,默认使用65536字节内存,64K varnish的param查看及改变: 示例:修改线程为2000个 varnish> param.set thread_pool_max 2000 varnish> param.show thread_pool_max 200 thread_pool_max 2000 [threads] Default is 500 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. NB: This parameter may take quite some time to take (full) effect. NB: We do not know yet if it is a good idea to change this parameter, or if the default value is even sensible. Caution is advised, and feedback is most welcome. varnish> param.show [-l] [param] aram.set [param] [value] varnish的常用命令行工具: varnishadm, varnishtop: 内存日志区域查看工具 [root@[node0] ~]# varnishtop RxHeader User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36 其中: RxHeader:称为tag, 基于tag过滤,可使用-i或-x选项; User-Agent起始的内容:称为日志信息,可使用-I或-X选项进行过滤; varnishtop过滤示例: -I regexp: 仅显示被模式匹配到的条目 -X regexp:仅显示不被模式匹配到的条目 -C: 忽略字符大小写; -d: 显示已有日志; 比如: 我只显示User-Agent字段 [root@[node0] ~]# varnishtop -I ^User-Agent -1 478.00 RxHeader User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3) 在比如我只显示Hash字段 [root@[node0] ~]# varnishtop -i Hash -1 543.00 Hash 172.16.249.108 337.00 Hash /test.html 55.00 Hash /index.php 42.00 Hash /index.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42 42.00 Hash /index.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 32.00 Hash / 30.00 Hash /favicon.ico 3.00 Hash /index.html [root@[node0] ~]# varnishstat: -f field, field, ...指明字段 -l: 列出所有可用字段 -x: xml输出格式 -j: json输出格式 如: [root@[node0] ~]# varnishstat -f client_conn -1 client_conn 271 0.02 Client connections accepted 另外还有两个命令:varnishlog, varnishncsa