4 ms·
Apache vs Nginx: Practical Considerations (2015)
- reacharavindh 9y agoI skimmed through the article and a simple question came to mind that I couldn't get an easy answer for. For serving static files to very few users, what would the performance difference be between Apache httpd and Nginx. Throughput wise and latency wise.. I can run this experiment on VMs, but wanted to ask here in case anyone already did.
- sametmax 9y agoApache is using concurrent threads and nginx is just doing monothreaded asyncio. Is has consequences if you have many users, and depending of the average length of connexions. For a few users and short connexions, you probably won't see much difference. My guess would be that apache is a tad faster (if you choose the proper mpm) and nginx uses a bit less memory (if you tell it to spaw only one worker), but that's just a hunch and is probably barely noticeable with 4/5 users at the same time.
- reacharavindh 9y agoCool. Thanks for the insight. At work, we have a web server that is not allowed to run any other workloads(for security and isolation needs). It hosts only static files. Occasionally big datasets that people download over http. I will look into tuning Apache instead of moving it to nginx. I was going by the word of mouth wisdom that nginx was "faster" and noted for myself to check which on earth had better latency at lower loads..
- jlgaddis 9y agoUnless you're doing a lot of requests (or RPS), it probably isn't even worth the time to bother with any tuning.
- gtirloni 9y agoNonscientific experiment: https://news.ycombinator.com/item?id=14590060 https://news.ycombinator.com/item?id=14590060 * httpd 2.45.5, default config (prefork), peaked at 24 processes and ~8MB RSS each (192MB) => 88k req/sec * nginx 1.10.3, default config, peaked at 8 processed and ~4MB RSS each (32MB) => 199k req/sec * httpd 2.45.5, stripped down mpm_event, peaked at 5 processed 8MB each (40MB) ==> 89k req/sec
- jimjag 9y agoIf you want the super best performance, throughput and latency wise, and don't care about memory, then Apache prefork would be the way to go. Just make sure that Apache never needs to fork any new processes after startup. Usually, of course, there are tradeoffs. In those cases, Apache w/ Event MPM is just as scalable, efficient and concurrent as nginx. Just make sure you are running Apache httpd 2.4.x on a modern OS, to make use of the non-blocking and async I/O and event handling of Apache httpd.