38

varnish-agent:让 varnish 更简单

 6 years ago
source link: https://www.tuicool.com/articles/Aruuee6
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

varnish-agent

varnish-agent 提供界面化的配置管理,配置信息保存于 etcd 中,当配置信息有更新时,自动更新配置并重新加载,方便多实例的配置管理。 varnish-agent 设置的varnish默认的 ttl 为0,因此如果不设置 Cache-Control 的所有请求都为不可缓存,尽量使用 Cache-Control 来控制接口的缓存时间。

需要注意, varnish-agent 默认的 probe 如下:

probe basicProbe {
  .url = "/ping";
  .interval = 3s;
  .timeout = 5s;
  .window = 5;
  .threshold = 3;
}

所以对于backend都需要添加相应的health check处理(/ping),如果有需要自定义的,可以去调整 template.vcl 后,自行重新编译。

运行

参数说明:

  • CONFIG 配置etcd的连接地址,此参数必须指定,如 CONFIG=etcd://192.168.31.176:2379/varnish-test
  • AUTH agent的认证配置,如 AUTH=user:pwd ,如果不配置则不使用认证,建议指定此参数
  • ADMIN_PATH 管理后台的路径,如果不配置,则为 /agent
  • PARAMS varnish的启动参数,如 PARAMS="-a :8080 -s malloc,256m" ,需要注意的是,varnish的启动参数默认会添加 -F -p default_ttl=0 ,而 -a 如果未指定,则指定为 :8080-s 如果未指定,则指定为 malloc,1G ,一般不需要调整此参数
docker run -d --restart=always \
  -p 8080:8080 \
  -e CONFIG=etcd://10.254.136.81:2379/varnish \
  -e AUTH=user:pwd \
  -e ADMIN_PATH=/@agent \
  --name varnish-agent \
  vicanso/varnish-agent

启动成功后,访问 http://127.0.0.1:8080/@agent/ ,则可进入管理后台。

添加director

ZJzumy3.png!web

ueumyqe.png!web

在更新相关配置后,会自动更新加载最新的配置文件(其它实例也会同时更新),当前最新的配置可在 Basic Info 中查看,需要注意的是,由于file是根据时间生成,因此不同实例有可能不一致,判断配置文件是否一致应该根据 hash 值。

YNNvyij.png!web


Recommend

  • 77
    • blog.51cto.com 7 years ago
    • Cache

    nginx varnish-初学者

    1.前端nginx做调度器及反代服务器,将用户的请求调度至后端的两台varnish,缓存调度算法使用一致性hash算法保证缓存命中率;2.两台varnish反向代理用户请求至三个(组)后端主机,分别为存储静态资源(htm,html,css,js),应用程序服务器(可以部署wordpress或Discuz!)...

  • 93
    • blog.51cto.com 7 years ago
    • Cache

    haproxy varnish-初学者

    (1)动静分离部署wordpress,动静都要能实现负载均衡,要注意会话的问题;(2)在haproxy和后端主机之间添加varnish进行缓存;(3)设计拓扑;(4)haproxy的设定要求:(a)statspage,要求仅能通过本地访问使用管理接口;(b)动静分离;(c)分别考虑不同的服务器组的调度算...

  • 159

    README.rst Varnish Cache This is Varnish Cache, the high-performance HTTP accelerator. Documentation and additional information about Varnish is available on

  • 58

    介绍  keepalived    keepalived是一个使用C语言编写的路由软件,设计目的是为Linux系统和基于Linux的虚拟架构提供简单而强大的负载均衡和高可用设施。负载均衡依赖于广泛使用的LIinux虚拟服务器(IPVS)内核模块,提供四层的负载均衡;keepalived实现了一组检查程...

  • 89

    Varnish反向代理服务器Varnish是一个开源的轻量级Cache和反向代理软件,通常只为http提供缓存,与Squit相比,Varnish具有性能更高、速度更快、管理更方便等优点。Varnish的特点:基于内存进行缓存,重启后数据将丢失利用虚拟内存方式,IO性能好支持设置0-60秒的精...

  • 54

    VarnishSpy Overview This is a simple client/server that will monitor the varnishncsa stdout for all the urls that are coming into varnish and connected clients will get a listing of the top 50 urls b...

  • 37
    • www.tuicool.com 6 years ago
    • Cache

    Varnish: Notes from the Architect (2006)

    Notes from the Architect Once you start working with the Varnish source code, you will notice that Varnish is not your average run of the mill application. That is not a coincidence. I have sp...

  • 56

    README.md varnish-agent varnish-agent提供界面化的配置管理,配置信息保存于etcd中,当配置信息有更新时,自动更新配置并...

  • 38

    Varnish是什么 这是一张标准的新零售行业中的微服务化组件从前到后的架构概览图。 我们都知道,凡是静态内容,一般...

  • 20
    • hub.docker.com 4 years ago
    • Cache

    varnish docker image 镜像

    ``` docker pull varnish ``` # Quick reference - **Maintained by**: [the Varnish Docker Community](https://github.com/varnish/docker-varnish) - **Where to get help**: [the Docker Community Forums](https://forums.docker.com/), [the Doc...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK