/images/hugo/avatar.png

27.6 varnish 日志查看

varnish 日志查看

/images/linux_mt/linux_cache.jpg

varnish 的日志存放在特定的内存区域中,分为计数器和日志信息两个部分,查看日志需要专门的工具。本节我们来学习这部分命令的使用。

27.4 varnish缓存策略配置

varnish缓存策略配置

/images/linux_mt/linux_cache.jpg

前面我们讲解了 VCL 的语法,并通过示例讲解了一部分 varnish 缓存的配置。本节我们来看看 varnish 内置的缓存策略,然后着重来看看如何对缓存进行修剪。

27.3 VCL 语法基础

VCL 语法基础

/images/linux_mt/linux_cache.jpg

varnish 的缓存配置,使用的是 VCL,一种与 C 类似的域专有类型的配置语言。本节我们先来对 VCL 做一个介绍。

1. VCL 组成与处理流程

1.1 VCL 组成

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
vcl 4.0;

# Default backend definition. Set this to point to your content server.
backend default {
    .host = "127.0.0.1";
    .port = "8080";
}

sub vcl_recv {
    # Happens before we check if we have this in cache already.
    #
    # Typically you clean up the request here, removing cookies you don't need,
    # rewriting the request, etc.
}

sub vcl_backend_response {
    # Happens after we have read the response headers from the backend.
    #
    # Here you clean the response headers, removing silly Set-Cookie headers
    # and other mistakes your backend does.

VCL 可以看作是在 C 语言基础上二次开发的子语言,保留了 C 语言基本的语法,并额外附加了特性:

27.2 varnish 架构及安装

varnish 架构及安装

/images/linux_mt/linux_cache.jpg

varnish 是 http 缓存服务器的"新星势力",它与 squid的关系,类似于 httpd 与 nginx。varnish 有个最大的问题是,它的配置文件随着版本的变化变化非常大。本节我们以 4.0 系列的版本来讲解 varnish 的架构,安装和程序组成

27.1 web架构缓存优化

web架构缓存优化

/images/linux_mt/linux_cache.jpg

上一章我们学习了如何使用 keepalived 实现一个高可用集群,接下来我们来继续完善我们的 web 站点架构,本章我们来讲解另一个重要内容,web 站点的缓存系统。