线上服务增加varnish缓存

简介: varnish的特点。 (1)是基于内存缓存,重启后数据将消失。  (2)利用虚拟内存方式,io性能好。  (3)支持设置0~60秒内的精确缓存时间。  (4)VCL配置管理比较灵活。  (5)32位机器上缓存文件大小为最大2G。  (6)具有强大的管理功能,例如top,stat,admin,list等。  (7)状态机设计巧妙,结构清晰。  (8)利用二叉堆管理缓存文件,

varnish的特点。

(1)是基于内存缓存,重启后数据将消失。 
(2)利用虚拟内存方式,io性能好。 
(3)支持设置0~60秒内的精确缓存时间。 
(4)VCL配置管理比较灵活。 
(5)32位机器上缓存文件大小为最大2G。 
(6)具有强大的管理功能,例如top,stat,admin,list等。 
(7)状态机设计巧妙,结构清晰。 
(8)利用二叉堆管理缓存文件,达到积极删除目的。 

varnish很强大。上线之后立即减少了服务器load。

而且接口访问速度加快了。页面加载时间变得更短了。

安装

官方网站:http://varnish-cache.org/

3.0文档:https://www.varnish-cache.org/docs/3.0/

centos安装: http://www.varnish-cache.org/installation/redhat

redhat 6 安装 :

rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el6/noarch/varnish-release/varnish-release-3.0-1.el6.noarch.rpm

http://varnish-cache.org/

yum install varnish

设置开机启动:

chkconfig varnish on

启动:

service varnish start

varnish配置:

/etc/sysconfig/varnish
设置carche路径,内存大小。
VARNISH_STORAGE_SIZE=8G

vcl配置,默认vcl路径:

/etc/varnish/default.vcl

把所有注释的代码都取消注释,然后修改成自己的服务器和端口。

backend default {

  .host = "127.0.0.1";
  .port = "80";
}

上线之后性能还是超级强悍的。服务器的负载 立刻就下降了。

并且访问速度比之前快了很多。varnish做http cache,性能很好。

varnish默认是2分钟失效。上面的配置基本上够使用了。

目录
相关文章
|
缓存 NoSQL 网络安全
【Azure Redis 缓存】Azure Redis服务开启了SSL(6380端口), PHP如何访问缓存呢?
【Azure Redis 缓存】Azure Redis服务开启了SSL(6380端口), PHP如何访问缓存呢?
165 0
|
4月前
|
存储 缓存
.NET 6中Startup.cs文件注入本地缓存策略与服务生命周期管理实践:AddTransient, AddScoped, AddSingleton。
记住,选择正确的服务生命周期并妥善管理它们是至关重要的,因为它们直接影响你的应用程序的性能和行为。就像一个成功的建筑工地,工具箱如果整理得当,工具选择和使用得当,工地的整体效率将会大大提高。
169 0
|
存储 缓存 NoSQL
【Azure Redis 缓存】关于Azure Cache for Redis 服务在传输和存储键值对(Key/Value)的加密问题
【Azure Redis 缓存】关于Azure Cache for Redis 服务在传输和存储键值对(Key/Value)的加密问题
180 2
|
缓存 NoSQL 网络协议
【Azure Redis 缓存】Lettuce 连接到Azure Redis服务,出现15分钟Timeout问题
【Azure Redis 缓存】Lettuce 连接到Azure Redis服务,出现15分钟Timeout问题
164 0
【Azure Redis 缓存】Lettuce 连接到Azure Redis服务,出现15分钟Timeout问题
|
缓存 NoSQL Java
【Azure Redis 缓存】示例使用 redisson-spring-boot-starter 连接/使用 Azure Redis 服务
【Azure Redis 缓存】示例使用 redisson-spring-boot-starter 连接/使用 Azure Redis 服务
243 0
|
缓存 NoSQL Go
缓存设计的好,服务基本不会倒
缓存设计的好,服务基本不会倒
|
缓存 NoSQL Linux
【Azure Redis 缓存】应用中出现连接Redis服务错误(production.ERROR: Connection refused)的排查步骤
【Azure Redis 缓存】应用中出现连接Redis服务错误(production.ERROR: Connection refused)的排查步骤
157 0
|
缓存 NoSQL Redis
【Azure Redis 缓存】Azure Cache for Redis 服务的导出RDB文件无法在自建的Redis服务中导入
【Azure Redis 缓存】Azure Cache for Redis 服务的导出RDB文件无法在自建的Redis服务中导入
|
存储 缓存 NoSQL
【Azure Redis 缓存】当使用Azure Redis 集群服务时候,发生了Moved的几点分析
【Azure Redis 缓存】当使用Azure Redis 集群服务时候,发生了Moved的几点分析
105 0
|
SQL 缓存 NoSQL
【Azure Redis 缓存】使用Azure Redis服务时候,如突然遇见异常,遇见命令Timeout performing SET xxxxxx等情况,如何第一时间查看是否有Failover存在呢?
【Azure Redis 缓存】使用Azure Redis服务时候,如突然遇见异常,遇见命令Timeout performing SET xxxxxx等情况,如何第一时间查看是否有Failover存在呢?
105 0