etags和服务器群
我从著名的 Scaling Rails 截屏视频中了解到,当您的网站变得越来越大时,代理缓存就是最佳选择。代理缓存使用 etag 等,因为 etag 可以更具体,并且强大的验证器可能是可行的方法。但是,我也听说在服务器场场景中,etag 不是正确的解决方案,因为它可能会因服务器而异(如何?)
这似乎是矛盾的,即如果它们正在运行大型负载平衡,则很可能正在实施基于 e-tag 的代理缓存服务器场。那么,如果电子标签在这种情况下失败了,他们该怎么办呢? :last_modified 并不是一个很好的选择。
在 Rails 应用程序中,假设我在后索引操作中的 etag 是
:etag => "all_posts_#{Post.count}".
负载平衡服务器场,这会因服务器而异吗?
I gathered from the much famed scaling rails screencasts that at some point when your site gets big and bigger, proxy caching is the way to go. Proxy caching uses etag, among other things and since etags can be more specific and strong validator is perhaps the way to go. However, I also hear that in server farm scenarios the etag is not the right solution because it can vary across servers (How?)
This seems contradictory i.e. most likely one is implementing e-tag based proxy caching if they are running a large load balanced server farms. So if e-tag fails in this situation how do they do it? :last_modified isn't really a great option.
In a rails app let's say if my etags in a post index action is
:etag => "all_posts_#{Post.count}".
will this vary from server to server if it's a load balanced server farm?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,当他们谈论不同服务器的 Etag 时,它与 Apache 提供的静态连接有关。默认情况下,Apache 在 Etag 中包含文件的 inode。如果文件不在共享资源上(例如 NFS 导出的 NAS),则文件的 inode 在每台服务器上都会不同。通常,建议将 Apache 配置为:
但如果服务器之间的修改时间不同,即使这样也可能会出现差异。
但是,对于非静态内容,您将在代码中生成 Etag,因此它在多个服务器上都是相同的。
Usually when they talk about Etags varying across servers it's in relation to static connect served up by Apache. By default Apache includes the file's inode in the Etag. If the files are not on a shared resource (like a NFS exported NAS), then the file's inode would be different on each server. Typically, the recommendation is to configure Apache like:
but even that has the possibility of differences if the modification time varies across the servers.
However, for non-static content, you are generating the Etag in your code, so it would be the same across multiple servers.