当有多个请求发送到 Squid 时,将单个请求发送到后端,并在未命中时对其他请求进行排队

当有多个请求发送到 Squid 时,将单个请求发送到后端,并在未命中时对其他请求进行排队

我希望通过让 Squid 在资源缓存未命中时向服务器发送单个请求来保护后端服务器。在获取期间,其他请求应被搁置,直到单个请求返回。

标题几乎满足了我的要求,但是当和的stale-while-revalidate时间都过去后,就没有陈旧的响应了,而且多个请求将被发送到后端。max-agestale-while-revalidate

该指令collapsed_forwarding似乎正是我所寻找的。但我无法让它按预期工作,仍然看到在最大期限内向后端发出多个请求。我正在使用 40 个线程的 SoapUI 5.2.1 简单负载测试对此进行测试。

我当前的 Squid (3.5.19) 配置是默认配置,但进行了以下更改:

#Queue incomming requests when a request is send to the backend. I.E. collapse request into a single backend request.
collapsed_forwarding on

# Squid normally listens to port 3128
http_port 3128 accel no-vhost defaultsite=localhost ignore-cc

#Backend requires basic auth
cache_peer 127.0.0.1 parent 53142 0 no-query originserver name=myAccel login=username:password

#Allow caching of files that have a ttl of 1 seconds
minimum_expiry_time 1 seconds

acl our_sites dstdomain localhost
http_access allow our_sites
cache_peer_access myAccel allow our_sites
cache_peer_access myAccel deny all

请求 URI:/rest/information/bridge/Test?isrs=AB12345

响应标头Cache-Control no-transform, max-age=2

答案1

目前看来,collapsed_rowarding 无法实现反向代理的预期效果。我在 squid 邮件列表中问过这个问题,回复如下(发送了一些日志之后):

折叠转发尚不适用于缓存重新验证请求。工厂正在努力实施折叠重新验证(在某些环境中),但我无法保证具体的交付日期或您的特定环境将得到覆盖。

查看邮件列表了解更多详细信息:http://lists.squid-cache.org/pipermail/squid-users/2016-June/011021.html

相关内容