3 ms·
HAProxy is faster than both of them for load balancing. Apache is slightly faster for static content. Nginx has more responsiveness under high load than Apache
by water9 3y ago
HAProxy is faster than both of them for load balancing. Apache is slightly faster for static content. Nginx has more responsiveness under high load than Apache for dynamic content (Hence Tomcat workers for example)
- tempestn 3y agoIs that true even if you configure Apache to use a static number of processes? IE set startservers equal to serverlimit and maxsparethreads equal to maxrequestworkers? IME that allows Apache to respond to load spikes more quickly. But is the issue with high load and dynamic content specifically related more to connecting to the process manager for the scripting language? (I take the same approach there, using a static pool of processes. Haven't had any issues, but have no way of knowing if nginx might be even faster!)
- water9 3y agoNginx uses an event driven model where a single thread might perform work for multiple requests. Often the batching and caching of these requests can boost performance. Apache however assigns each inbound connection its own dedicated thread which makes it slightly more responsive on average. At the end of the day it's going to come down to the priority of scheduling for the threads of the program whether it be one process with 65,535 threads or 65,535 single threaded processes
- xorcist 3y agoThat description is not correct for any of them. Apache can use either an event queue or a thread pool, and nginx is also multithreaded and not forking. So there isn't any difference, except that Apache has a bit more knobs to tweak.
- water9 3y agoNGINX is multiprocess Single Threaded Apache is one thread per connection Its like having the same waiter vs a pool of waiters Sources: https://serverguy.com/wp-content/uploads/2020/10/Apache-Vs-NGINX-Infographic_Edit-2_New-SG-Logo.png https://serverguy.com/wp-content/uploads/2020/10/Apache-Vs-N... https://www.google.com/search?rlz=1C1CHBF_enUS874US874&sxsrf=APwXEdcNR7H8yr2Iu7i9S9_FCIJgxziYPA:1684659916505&q=Is+NGINX+single+threaded+or+multithreaded https://www.google.com/search?rlz=1C1CHBF_enUS874US874&sxsrf...
- xorcist 3y agoThat is just a png of some text. The text is either wrong or outdated by a decade or more. People sometimes like to have opinions about stuff. But there's no reason to google for secondary sources when the documentation is good. Read the manual instead. The documentation for both projects is correct, short and to the point. They are both multi threaded, multi process, with an event loop. The documentation describes how to set those parameters. Look at the thread_pool directive for nginx and AsyncRequestWorkerFactor for Apache for example. You could of course configure one thread per connection, but that only makes sense under specific circumstances.
- blacklion 3y agoDoes Apache can do zero-copy for static content? nginx could on properly configured system. TLS kills this, alas, and, I think, with TLS OpenSSL will be bottleneck for static content, not server.
- water9 3y agoI think it has more to do with the event driven nature of nginx vs the thread per connection nature of Apache.
- toast0 3y agoIf you're looking for this, you want kTLS, plus or minus nic accelerated kTLS. Read the Netflix CDN presentiatons for the state of the art, and see what you can make work with your system, etc.
- blacklion 3y agoI know abut Netflix work, and even some of this work trickled down to base FreeBSD (and opensource), but is still very fragile, not completely open-sourced and require very special hardware (1 or 2 models of specific NICs with specific versions of firmware) to work.
- rb12345 3y ago"EnableSendfile On" will enable that on Apache, and has been around since Apache 2.0.44. It's not enabled by default though, and as you say, TLS breaks it.