Add new comment

Difference between memcache and varnish?

  Memcached can be used as an in-memory, distributed back-end for your application cache.
  Varnish can be used as a reverse proxy to externally cache HTTP requests.

  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).

  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.

  Varnish is meant to serve webpage files, like html, js, css, images, etc. It intercepts the HTTP traffic between the internet clients and the backend application server. Varnish listens to http port 80 and speaks HTTP protocol. Neither browsers nor the backend applications need to know that Varnish exists, once it is properly configured it just works.

  Memcached is an application usually used to cache data brought from a database server to an application, in order to decrease the number of queries to the DB. Furthermore, since the data is cached on memory, its retrieval is much faster. But is the application that controls the insertion and retrieval of data from Memcached, in other words, the application must be written to make proper use of Memcached. Memcached does not speak HTTP protocol.

  Memcached is a distributed, key-value, object cache in memory. This is similar to the object cache provided by APC but there are some important differences. It’s in-memory, while APC’s object cache is in shared memory. This will make Memcached faster, but will also require the memory allocation for it’s storage. The other major difference is that Memcached is distributed. This means that it runs across multiple servers. 

  Varnish is a caching HTTP reverse proxy. The reverse proxy part means that it sits between your application and the outside world. Visiting your domain will actually connect to Varnish. Varnish will then make the corresponding request to your application and then deliver it to the client. It will cache the results of these requests based on a configuration file you can write in the Varnish Configuration Language.


Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
3 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.