Do Memcached and Varnish Cache conflict together?

Tommyhara

Verified User
Joined
Jul 25, 2014
Messages
187
Hello,

I have just bought a new VPS for my web hosting forum and I installed Varnish cache on it

After that, I install Memcached to enable vBulletin use with Memcached to speed up loading speed for webpages but it got error immediately.

For previous forums or last time I could use Memcached with my forums but this time it didn't work.

My questions is, do Memcached and Varnish Cache conflict together? Should I remove Varnish and just only use Memcached?

My web hosting control supported Varnish so that I can install it by 1 click.

Please share your advice.

Thanks in advance.
 
Memcache is a more or less a database. It's a database that doesn't persist data and only stores it in memory. It also doesn't really care if it throws data out. The natural use for Memcache is to cache things internally in your application. Memcache uses its own specific protocol to store and fetch content.

Varnish on the other hand stores rendered pages. It talks HTTP so it will typically talk directly to a HTTP client and deliver pages from it's cache whenever there is a cache hit. When there is a cache miss it will go and fetch the content from the web server, store it and deliver a copy to the user.

These are two pretty different pieces of software. The end goal of both pieces of software is the same, though and most sites would use both technologies in order to speed up delivery.
They will deploy Varnish do speed up delivery of it's cache hits, and when you have a cache miss the application server might have access to some data in Memcache will be available to the application faster than what the database is capable of.

The performance characteristics are pretty different. Varnish will start delivering a cache hit in a matter of microseconds whereas a PHP page that gets rendered content from Memcache will likely spend somewhere around 15-30 milliseconds doing so. The reason Varnish can do it faster is that Varnish has it's content in local memory whereas the PHP script needs to get on the network and fetch the content over a TCP connection. In addition, you'll have the overhead costs of the interpreter. It's not that Varnish is better, it's just that Varnish has a much easier job to do and it is faster because of it.

There are no good reason not to use both.
 
Back
Top