performance - 在大型网站中为动态内容生成静态页面的好方法以及如何正确管理静态页面
问题描述
我有一个拥有数百万页的网站。页面上的内容存储在数据库中,但数据变化不是很频繁。所以为了提高网站的性能,降低部署web应用的成本,我想为动态内容生成静态页面,如果内容发生变化,则刷新页面。但是我很关心如何管理这些大量的页面。我应该如何存储这些页面?当web服务器处理很多请求时,会不会导致IO问题?这个问题有没有更好的解决方案?我应该使用清漆来处理这个问题吗?
解决方案
Varnish looks like a very good use case for that. Basically, you wouldn't be generating the full site statically, but incrementally, every time there's new requested content varnish hasn't cached yet.
EDIT to cover the comments:
- if all the Varnish nodes are down, you can't get your content, same as if the database is down, or if your load-balancers are down. Just have two Varnish load-balanced for high availability with keepalived for example.
- if varnish is restarted, the cache will get cleared, unless you are using Varnish Plus/Enterprise with MSE. It may not be an issue if you don't restart often (configuration changes don't need restarts), since the database still has the data to repopulate the cache.
- Varnish has a ton of options to invalidate content: purges for just one object, revalidation, bans to target entire sub-domains or sub-trees, xkeys for tag-based invalidation.
推荐阅读
- react-native - 具有样式边距的 Native Base 按钮不包含其中的文本
- python - 在 Python 中搜索特定实例的基因组 .txt 文件
- scala - 从外部输入改变值的流
- reactjs - MenuItem 不会首先出现在 DropdownButton 列表中?
- json - 如何在 Swift4 中使用 Codable 字典
- azure - Intune 管理扩展未安装 - 下载镜像不存在
- c# - c#:检查“ref”参数是否实际上来自静态变量
- hadoop - Hadoop - 直接将数据集从外部复制到 HDFS
- overlay - Nix(OS):仅为一个包构建设置“permittedInsecurePackages”(在覆盖中?)
- json - 如何将 twitterscraper 输出保存为 json 文件