频繁使用网站的缓存策略
我们正在为一个频繁使用的网站设计缓存策略。 该网站由动态和静态内容混合组成。前端是PHP,中间层是Tomcat,后端是mysql。
仅通过 HTTPS 完成用户登录屏幕以保护凭据。之后,所有内容都通过纯 HTTP 提供。有些屏幕是特定于客户的(比如说他的最后订单),而其他屏幕则是每个人都通用的(最受欢迎的产品、促销、规则等)。
考虑到预期的流量,很明显我们需要一个全面的缓存策略。因此,我们正在考虑以下选项:
- 将 Squid 或 Varnish 放在 PHP 前面,并将其配置为缓存所有公共内容以及甚至客户的订单提交表单。
- 通过 PHP 使用 memcached 来缓存页面片段(例如最流行的产品)
- 在中间层/tomcat 中实现缓存(即在将内容返回到 Web 服务器之前,尝试从本地缓存(例如 ehcache)获取它)
- 使用 PHP 级缓存,例如Zend 缓存并存储页面片段。这与我提到的第二个选项很接近,但它内置于 Zend 框架中。
我们可能会结合使用这些策略。
那么问题是是否值得像Varnish一样添加前端缓存,或者只是在内部使用Zend Cache?
我忘记提及的另一个选项是使用 PHP 级缓存(如 Zend Cache)并存储页面片段。这与我提到的第二个选项很接近,但它内置于 Zend 框架中。
那么问题是是否值得像Varnish一样添加前端缓存,或者只是在内部使用Zend Cache?
再次感谢, 菲洛帕托.
We’re in process of designing caching strategy for a heavily used web-site.
The site consists of a mix of dynamic and static content. The front-end is PHP, middle tier is Tomcat and mysql on the back.
Only user login screen is done over HTTPS to secure the credentials. After that, all content is served over plain HTTP. Some of the screens are specific to the customer (let’s say his last orders), while other screens are common to everybody (most popular products, promotions, rules, etc).
Given the expected traffic volume it’s clear that we need a comprehensive caching strategy. So we’re considering following options:
- Put Squid or Varnish in front of PHP and configure it to cache all public content and even order submission form of a customer.
- Use memcached by PHP to cache page fragments (such as most popular products)
- Implement caching in the middle tier/tomcats (i.e. before returning content to web-servers, try to fetch it from local cache such as ehcache)
- Use PHP-level cache like Zend Cache and store there fragments of the pages. This is close to the second option that i mentioned but it's built into the Zend framework.
It’s possible that we will use a combination of those strategies.
So the question is whether it's worthwhile to add front cache like Varnish, or just use Zend Cache inside?
The other option that i forgot to mention is to use PHP-level cache like Zend Cache and store there fragments of the pages. This is close to the second option that i mentioned but it's built into the Zend framework.
So the question is whether it's worthwhile to add front cache like Varnish, or just use Zend Cache inside?
Thanks again,
Philopator.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经完成了很多这样的项目,并发现:
这些天我非常喜欢 Varnish:它是一个独立的层,不会使 Java/PHP 代码变得混乱,它速度快且非常灵活。缺点是vcl中的配置有点太复杂了。
我通常在内存存储中使用ehcache +,以避免小数据集的延迟(例如数据库查询或服务请求),而当数据量很大并且缓存需要由多个节点共享时,我通常使用memcached。
I've done quite a few projects like this and found that:
These days I like Varnish a lot: it's a separate layer that doesn't clutter the Java/PHP code, it's fast and very flexible. Downside is that the configuration in vcl is a bit too complex.
I typically use ehcache + in memory storage to avoid latency (e.g. database queries or service requests) with small data sets, and memcached when there's a lot of data and the cache needs to shared by multiple nodes.