是否可以运行内存和磁盘存储清漆?

我有兴趣为缓慢变化的网站最大限度地提高caching命中率和效率。 虚拟主机没有大量的RAM,但是我想使用可用的清,但是如果没有足够的内存,可以回退到磁盘caching。

是否可以用一个单一的清漆实例做到这一点? 文档将“文件”和“malloc”存储描述为不同的选项。

    使用malloc方法。 它会尝试把所有东西放在RAM中,如果需要的话,内核会把它换掉。 这样你就一起使用内存和磁盘。

    同时,当你启动磁盘时, filemalloc执行得更好。 有关更多信息,请参阅:

    • “清漆书”的“调整”章节的“存储后端”部分
    • 这篇关于“光油最佳实践”的博客文章 (从2010年1月起)

    您需要按如下方式分别命名存储,并在vcl中指定要与beresp.storage = storage_name一起使用的后端存储。 。

    清漆3. *工艺选项

     DAEMON_OPTS="-a :80 \ -T localhost:6082 \ -f /etc/varnish/default.vcl \ -S /etc/varnish/secret \ -s foo=malloc,512m \ -s bar=file,/var/lib/varnish/varnish_storage.bin,512m" 

    vcl v3

     sub vcl_fetch { if (req.url ~ "html") { set beresp.storage = "foo"; set beresp.http.x-storage = "foo"; } else { set beresp.storage = "bar"; set beresp.http.x-storage = "bar"; } return (deliver); } 

    对于Varnish v4,您可以按照官方博客文章的说明https://www.varnish-software.com/blog/partitioning-your-varnish-cache