× {{alert.msg}} Never ask again
Receive New Tutorials
GET IT FREE

Nginx vs Apache

– {{showDate(postTime)}}

Codementor PHP expert mentor Chris Fidao is a PHP developer who runs Servers for Hackers, the newsletter about servers, for programmers.  

‘Chris recently joined us during Codementor Office hours and answered some of our viewers’ questions about Nginx.  Here is one of the questions he answered: Nginx v.s. Apache. 

The text below is a summary done by the Codementor team and may vary from the original video and if you see any issues, please let us know!


Nginx vs Apache

Nginx and Node.js can speed up performance and perhaps offer some advantages to concurrent connections.  How is it better or worse than Apache?

 

Nginx and Node.js are similar, since they both have a single or low number of processes. They’re also both asynchronous and evented, so their way of handling processes and requests is fundamentally different from Apache in that respect.

 

 

Apache will try to make new processes, new threads for every requests in every connection. Nginx, like Node.js, will not do that. It has few numbers of processes and will take new requests as they come, but because it’s asynchronous it can just start to process a request. In other words, if something is taking a long time, it can do something else (e.g. another request), and then come back to another one when something has finished happening.

 

If you’re familiar with coding in Node.js, you’d know that it has call backs, that something can happen and you don’t know when it’s finished until you get a call back from the thing that is finishing. Even though it doesn’t actually make your application faster, it is better for handling a high number of concurrent requests because it can handle operations in a non-blocking way. In other words, it doesn’t make you wait for a file operation or a network operation before it moves onto another pass. Therefore, in that respect I think it’s better than Apache. Apache can do a lot of stuff such as handle a lot of traffic, but Nginx and Node.js are a fun combination because they both have a really similar way of handling request responses and processing HTTP requests.


Other posts in this series with Chris Fidao:

Chris FidaoNeed Chris’s help? Book a 1-on-1 session!

View Chris’s Profile

or join us as an expert mentor!



Author
Chris Fidao
Chris Fidao
PHP/Python/DevOps
I'm a web (Python, PHP, Golang) developer, primarily working within the Laravel community. I run Servers for Hackers, the newsletter (12000+ subscribed) about servers, for programmers.
Hire the Author

Questions about this tutorial?  Get Live 1:1 help from PHP experts!
Rahul Choudhary
Rahul Choudhary
5.0
Wordpress - Shopify - Wocommerce Designer & Developer | 8 + Years
I am a seasoned Senior Developer with over 8 years of experience in web design and development. Proficient in HTML, CSS, SCSS, Bootstrap,...
Hire this Expert
Bryan Mayor
Bryan Mayor
5.0
💻 NYC based web developer - PHP, Laravel, JS, jQuery, Java and more.
NYC based developer with 16+ years of experience (independent freelancing, at Fortune 500s and at small startups). Languages include PHP,...
Hire this Expert
comments powered by Disqus