Squid 处理并发缓存未命中的情况

发布于 2024-08-28 06:40:16 字数 642 浏览 6 评论 0原文

我们使用 Squid 缓存来减轻网络服务器的流量,即。它被设置为反向代理,在入站请求到达我们的网络服务器之前对其进行响应。

当我们遇到缓存中没有的同一请求的并发请求时,Squid 会将所有请求代理到我们的 Web(“原始”)服务器。对于我们来说,这种行为并不理想:我们的源服务器在尝试同时满足 N 个相同的请求时陷入困境。

相反,我们希望第一个请求代理到原始服务器,其余请求在 Squid 层排队,然后当原始服务器响应第一个请求时,所有请求都由 Squid 完成。

有谁知道如何配置 Squid 来做到这一点?

我们已多次通读文档并在网络上彻底搜索该主题,但不知道如何操作。

我们也使用 Akamai,有趣的是,这是它的默认行为。 (但是,Akamai 拥有如此多的节点,即使启用了 Akamai 的超级节点功能,我们在某些流量高峰场景中仍然会看到大量并发请求。)

这种行为对于其他一些缓存来说显然是可配置的,例如。 Ehcache 文档提供了选项“并发缓存未命中:缓存未命中将导致缓存过滤器上游的过滤器链被处理。为了避免请求相同密钥的线程执行无用的重复工作,这些线程会阻塞在第一个线程后面。 ”

有些人将此行为称为“阻塞缓存”,因为后续并发请求会阻塞在第一个请求之后,直到该请求完成或超时。

感谢您查看我的菜鸟问题!

奥利弗

We're using a Squid cache to off-load traffic from our web servers, ie. it's setup as a reverse-proxy responding to inbound requests before they hit our web servers.

When we get blitzed with concurrent requests for the same request that's not in the cache, Squid proxies all the requests through to our web ("origin") servers. For us, this behavior isn't ideal: our origin servers gets bogged down trying to fulfill N identical requests concurrently.

Instead, we'd like the first request to proxy through to the origin server, the rest of the requests to queue at the Squid layer, and then all be fulfilled by Squid when the origin server has responded to that first request.

Does anyone know how to configure Squid to do this?

We've read through the documentation multiple times and thoroughly web-searched the topic, but can't figure out how to do it.

We use Akamai too and, interestingly, this is its default behavior. (However, Akamai has so many nodes that we still see lots of concurrent requests in certain traffic spike scenarios, even with Akamai's super-node feature enabled.)

This behavior is clearly configurable for some other caches, eg. the Ehcache documentation offers the option "Concurrent Cache Misses: A cache miss will cause the filter chain, upstream of the caching filter to be processed. To avoid threads requesting the same key to do useless duplicate work, these threads block behind the first thread."

Some folks call this behavior a "blocking cache," since the subsequent concurrent requests block behind the first request until it's fulfilled or timed-out.

Thx for looking over my noob question!

Oliver

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

揽月 2024-09-04 06:40:17

您正在寻找折叠转发:
http://www.squid-cache.org/Versions/v2 /2.7/cfgman/collapsed_forwarding.html

在 2.6 和 2.7 中可用,但在 3.x 中尚不可用。

当缓存中有某些内容但已过时时,您可能还会对 stale-while-reavlidate 感兴趣:
http://www.mnot.net/blog/2007/12/12/stale

You're looking for collapsed forwarding:
http://www.squid-cache.org/Versions/v2/2.7/cfgman/collapsed_forwarding.html

Available in 2.6 and 2.7, but not yet in 3.x.

When there is something in cache, but stale, you might also be interested in stale-while-reavlidate:
http://www.mnot.net/blog/2007/12/12/stale

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文