承接 trive/varnish 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

trive/varnish

Composer 安装命令:

composer require trive/varnish

包简介

Magento 2 Varnish Fixes Module

README 文档

README

Description

Magento 2 module which fixes issues with cache tags and 503 errors when using Varnish as caching application.

Installation

Install via composer:

composer require trive/varnish

Modify your VCL file with the following content:

sub vcl_backend_response {
    ...(redacted)
    
    # Trive - add these two lines below - start
    # collect all x-magento-tags headers
    std.collect(beresp.http.X-Magento-Tags);
    # Trive - add these two lines above - end"
    
    return (deliver);
}

Enable the module:

bin/magento module:enable Trive_Varnish
bin/magento setup:upgrade

The issue

When using Varnish as caching application in Magento 2, each page is tagged by cache tags of the content displayed on it. These tags are then used for cache invalidation and purges, once content is updated.

For example, if you open a home page on default installation, it will be tagged with store, cms_page and cms_page_1 cache tags.

Categories are tagged with cache tags of all products they have assigned. This means that, if you have a large catalog, with a single category containing about 2000 products, you're likely to have about 20kB worth of cache tags when first loading that category.

Cache tags are sent to Varnish as X-Magento-Tags header on initial, non-cached request to Varnish, so it can tag the URL with displayed content, and be able to clear all pages where a object appears, when requested.

Once X-Magento-Tags header gets longer than 8kB, default http_resp_hdr_len Varnish limit is hit and Varnish returns a 503 error to customers (backend fetch failed).

Even after implementing workaround from Magento Documentation, the issue is not solved, because another limit on Apache/nginx HTTP server might be hit, as they both have 8kB max header value by default.

Affected stores

Your store is affected if you are:

  • using Magento 2 (any version)
  • having a large number of products on store, with at least one anchor category containing at least 2000 products
  • using Varnish as Magento 2 caching application, with default http_resp_hdr_len limit

Your store might also be affected if you are:

  • using Apache/nginx with default LimitRequestFieldSize, large_client_header_buffers, or some other limit that might be hit by HTTP headers
  • using nginx/HAProxy with default header length or request size limits
  • using Apache mod_proxy_fcgi

Our solution

This module addresses the above issue by separating X-Magento-Tags into 8kB header blocks. Sending multiple X-Magento-Tags headers don't hit most of the limits, and doesn't triggers 503, nor FetchError http read error: overflow errors during Varnish backend fetch.

Note that default Magento 2 VCL file should be updated after implementing this module, to be able to collect multiple X-Magento-Tags headers into one, during Varnish procesing.

trive/varnish 适用场景与选型建议

trive/varnish 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 41.52k 次下载、GitHub Stars 达 39, 最近一次更新时间为 2017 年 12 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 trive/varnish 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 trive/varnish 我们能提供哪些服务?
定制开发 / 二次开发

基于 trive/varnish 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 41.52k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 40
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 39
  • Watchers: 4
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2017-12-21