Data Centers

Which web server should you use — Apache or NGINX?

Should you be using Apache or NGINX as your web server? Jack Wallen helps answer this question.

Which web server do you use and why? Chances are you use one of these three: Microsoft IIS, Apache, or NGINX. If you use IIS, it's probably because your data center is filled with Microsoft servers. If you use Apache or NGINX, that question gets a bit blurry. Let me help you out with trying to decide which open source web server you should use.

The decision really comes down to design. Apache is a process driven design, whereas NGINX is an event driven design. What does that mean in real world usage? Simple. Apache does a great job of handling a large number of requests per second. However, the performance of an Apache site will often slow down as those requests increase. When an Apache driven websites visits suddenly spike, page load times will suffer. Why? Because Apache creates a new process for each new request. That is a very reliable model that works well for low-traffic applications. However, when that traffic increases, the demand on resources will result in slower performance.

NGINX, on the other hand, is optimised to provide consistent and predictable performance. So when your web server finds itself under under heavy load, NGINX won't blink. This is due to the differing design schemes — event versus process. Because NGINX is an event-based structure, it can handle around four times more requests per second.

But don't think you should simply use NGINX, because it can outperform Apache. Remember, Apache has been around for a very long time so there are a lot of resources and third-party add-ons available. And if you're looking to serve up dynamic content, Apache's built-in ability to parse and execute numerous types of scripting languages, makes it really flexible.

To sum it up: If performance is your goal, NGINX is your tool. If you want flexibility, go with Apache.

Also see

apachenginxhero.jpg
Image: Jack Wallen

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox