Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Apache for serving static files. Apache2 require too much RAM.

I want to reduce the RAM usage.

I don't have experience with Varnish. It's said to be faster. I don't know how Varnish works.

So, How much RAM needed for running Apache2+Varnish? Will Apache2+Varnish have higher RAM usage than Apache2 without Varnish?


share|improve this question
You haven't described anything about your enviroment - is it mostly static files, do you use any dynamic languages (php?), do you require a specific apache2 mod? – pauska Mar 5 '10 at 12:08
I am using Magento (PHP based e-commerce CMS - which by definition is like RAM eating cookie monster). I am using Apache2 with MaxServers set to 1, and Varnish 3.0.3 with proper configuration on a Virtual server with 512 MB RAM and it easily handles few hundreds of requests a second. It heavily depends also on your code, and Varnish configuration, but it sure can save you a lot of RAM, and at the end a lot of cash. – Cninroh Feb 21 '13 at 14:46

Nginx might be a good choice if you want a lightweight server for static files. You can select which modules you want at compile time.

share|improve this answer

Varnish caches data in RAM to send "stuff" to clients faster. It doesnt save you RAM usage, it saves you processing and I/O time.

What you should be looking at is alternatives to Apache2. I saved up a great deal of RAM by switching over to lighttpd+FastCGI-PHP since I mostly share out a large number of static data.

share|improve this answer
+1 for suggesting alternative web servers. Sometimes, mixing them is good too. – sybreon Mar 5 '10 at 17:22
@Sybreon - Mixing webservers, specially nginx and apache, is not good idea always. When u r running low on RAM, its always good to stick to one server IMHO. – rahul286 Jul 16 '10 at 16:20
Varnish can save you RAM. If your Apache needs fewer processes to handle the load, this would reduce RAM usage quite a lot. You'd have to check if it's enough to offset the extra usage by Varnish. – Martijn Heemels May 5 '11 at 8:22

If you have many static files served by apache (jpgs, css/js files and html) you will find that using Varnish to serve them requires less memory than hogging a full apache process to serve that single 3kb file.

In reverse, having many dynamic files (php with POST/GET queries etc) will not make any use of varnish so it is a complete waste of memory.

So, it depends on your exact case.

To give you an example, on my site I had one php file that served on average 20 small images each.

Without varnish, the apache accesses were around 200/sec. After varnishing the server (6GB memory total) and giving 3GB to varnish and the rest for mysql/php/apache stuff, the accesses to apache dropped to 10-20/sec and the whole server got WAY faster. But do not expect to actually gain any speeds without giving Varnish a fair part of your memory

A rough estimate is the size of your static content + 25% for overhead. If the images are not served evenly (meaning that some are served way more often than others) you can get away with less.

share|improve this answer
You can of course let Varnish cache dynamic content as well, depending on the circumstances. If you have a very high load, even a few seconds of caching can go a long way. – Christian Davén Feb 26 '12 at 11:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.