Memcache(d)vs. Varnish,可加快3层Web架构的速度 [英] Memcache(d) vs. Varnish for speeding up 3 tier web architecture

查看:80
本文介绍了Memcache(d)vs. Varnish,可加快3层Web架构的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试加快基准测试(3层Web体系结构)的速度,并且我对与Memcache(d)和Varnish有关的一些一般性问题.

I'm trying to speed up my benchmark (3 tier web architecture), and I have some general questions related to Memcache(d) and Varnish.

  • 有什么区别?
    在我看来, Varnish 位于Web服务器的后面,可以缓存网页,不需要更改代码,只需配置即可.
    另一方面, Memcached 是通用缓存系统,主要用于缓存数据库结果,并且确实需要更改get方法(第一次缓存查找).

  • What is the difference?
    It seems to me that Varnish is behind the web server, caching web pages and doesn't require change in code, just configuration.
    On the other side, Memcached is general purpose caching system and mostly used to cache result from database and does require change in get method (first cache lookup).

我可以同时使用吗?

有什么更好的选择?

(方案1-主要是撰写,
方案2-大部分阅读,
情况3-读写相似)

(scenario 1 - mostly write,
scenario 2 - mostly read,
scenario 3 - read and write are similar)

推荐答案

  • Varnish位于Web服务器的前面;它用作缓存的反向http代理.
  • 您可以同时使用.
  • 大多数情况下要写-Varnish将需要清除受影响的页面.这将导致开销很大,并且修改后的页面受益不大.
  • 最常读的书-Varnish可能涵盖了大部分内容.
  • 类似的阅读&写入-Varnish将为您提供很多页面,Memcache将为包含已知数据和新数据的页面提供信息,从而使您可以更快地生成页面.
    • Varnish is in front of the webserver; it works as a reverse http proxy that caches.
    • You can use both.
    • Mostly write -- Varnish will need to have affected pages purged. This will result in an overhead and little benefit for modified pages.
    • Mostly read -- Varnish will probably cover most of it.
    • Similar read & write -- Varnish will serve a lot of the pages for you, Memcache will provide info for pages that have a mixture of known and new data allowing you to generate pages faster.
    • 一个可能适用于stackoverflow.com的示例:添加此注释会使页面缓存无效,因此必须从Varnish(以及我的个人资料页面)中清除此页面,这可能不值得一开始就进行缓存.使所有受影响的页面失效可能会有点问题).但是,所有注释都仍在Memcache中,因此数据库只需编写此注释即可.数据库无需执行任何其他操作即可生成页面.所有评论都由Memcache提取,页面被重新缓存,直到有人再次影响它为止(也许通过投票赞成我的答案).再次,数据库进行投票,所有其他数据都从Memcache中提取,并且寿命很快.

      An example that could apply to stackoverflow.com: adding this comment invalidated the page cache, so this page would have to be cleared from Varnish (and also my profile page, which probably isn't worth caching to begin with. Remembering to invalidate all affected pages may be a bit of an issue). All the comments, however, are still in Memcache, so the database only has to write this comment. Nothing else needs to be done by the database to generate the page. All the comments are pulled by Memcache, and the page is recached until somebody affects it again (perhaps by voting my answer up). Again, the database writes the vote, all other data is pulled from Memcache, and life is fast.

      Memcache通过减少生成页面的次数来节省数据库的工作量,而Varnish通过减少生成页面的次数来节省动态Web服务器的CPU负担(如果不是对于Memcache,则可以减轻数据库的负担).

      Memcache saves your DB from doing a lot of read work, Varnish saves your dynamic web server from CPU load by making you generate pages less frequently (and lightens the db load a bit as well if not for Memcache).

      这篇关于Memcache(d)vs. Varnish,可加快3层Web架构的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆