I have been investigating the differences between Apache and Nginx recently and am confused about which I should choose.
I have done some searching but there is no definitive comparison between the two and I was wondering if someone here could give their views on the differences between the two.
My current knowledge allows me to understand that mod_php is faster and more secure than fastcgi however Apache is much worse when it comes to simultaneous connections and memory consumption.
My site is using a lot of long polling but has a non AJAX web base (i.e. Apache with long polling over the top).
My original solution to Apaches memory problems were to send the long polling through node.js and then get node.js to access Apache every 2 secs in which case Apache would not have an open connection but instead node.js would. I have come to the realisation this might not be good enough and am looking at different solutions. I am still interested as to whether my original idea would have worked.
So which is better for the modern web? Apache or Nginx?
Update: All the suggestions given were good and valid. I have gone with the original second idea which is to use a full Nginx server. I am satisfied that being a dedicated server I could not suffer security issues from fastcgi and since my long polling scripts need to be written in PHP I require a server that can deal with high load simultaneous connections and Apache just cannot do that no matter how much I change the structure it will still be memory hungry.
I have marked Martin F's answer since he gave such a clear and complete answer to my questions points that I feel he deserves the mark, however, all three answers were good and valid and will most definately look into using reverse proxy for another site I own since I just found something very very very kool that Nginx can do in proxying.