User Tools

Site Tools


web_cache

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. … Varnish is in front of the webserver; it works as a reverse http proxy that caches. You can use both.

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:

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:

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.

https://www.techrepublic.com/article/how-to-use-a-ramdisk-on-linux/

web_cache.txt · Last modified: 2023/03/06 11:31 by 127.0.0.1