首页 > 解决方案 > 在大型网站中为动态内容生成静态页面的好方法以及如何正确管理静态页面

问题描述

我有一个拥有数百万页的网站。页面上的内容存储在数据库中,但数据变化不是很频繁。所以为了提高网站的性能,降低部署web应用的成本,我想为动态内容生成静态页面,如果内容发生变化,则刷新页面。但是我很关心如何管理这些大量的页面。我应该如何存储这些页面?当web服务器处理很多请求时,会不会导致IO问题?这个问题有没有更好的解决方案?我应该使用清漆来处理这个问题吗?

标签: performancenginxarchitecturevarnish

解决方案


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.

推荐阅读