Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using apache with mod_php to serve content. Mostly the content is fetched form memcache over the network. All of my images, css and js are already on a cdn

What are the pros and cons of putting nginx and/or varnish in front.

Bonus: How would I deal with user accounts that required a custom page to be displayed if someone was logged in (maybe this is another question)

share|improve this question

closed as primarily opinion-based by Chopper3, Christopher Perrin, mdpc, Andrew B, Stephane Aug 9 '13 at 14:43

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

1 Answer

If you're already using a decent CDN for your static content, the benefits of a separate static-content server sitting in front of your app will be pretty minimal unless you have a very low TTL on a substantial amount of your content. Keep that in mind first and foremost.

Varnish has a number of reported issues with memory usage. Some people have claimed that this is because Varnish will try to claim all the virtual memory on a host for itself in order to better serve content. Others have noted what appear to be serious and substantial memory leak problems with it, and these issues seem to keep cropping up. I'm not an authority, but the sheer number of people out there saying things like "I tried Varnish but I kept having to restart it once per day" makes me wary. Given that there's not a substantial performance difference over Nginx in most cases, I've avoided it in production so far, and Nginx hasn't left me wanting.

Though, if you're looking at Nginx, I'd consider removing Apache from the equation entirely. PHP runs quite nicely through an interface like FPM or FCGI (via spawn-fcgi) without having to get full-on reverse HTTP proxying involved.

share|improve this answer
    
Can you give me an estimate of how many pageviews with a low (5 mins) TTL where it would be worth caching with varnish instead of having it served from apache/memcache. Ex if I had an index.php page that only needed to be refreshed every 5 mins and I had 20k page views in that period. Would it be worth installing and catching with Varnish or just continue to all apache and memcache to handle it. –  ckliborn Nov 30 '11 at 17:21
    
I have seen benchmarks of varnish vs nginx (though I can't find it now), and I remember nginx beeing slightly faster. –  Isaac Aug 8 '13 at 6:13
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.