- Feb 20, 2012
- by Dave Matteson
The word about nginx is out. The efficient Russian web server was previously only known to web developers and system administrators, but has now been seeing wider coverage. With good reason. A sizable chunk of the highest traffic sites on the web have switched over to nginx and it’s likely the rest have at least considered it.
So what’s the big deal? For each user that visits your site, Apache fires up a separate process to serve the content they requested. The process ends when the content has been served. For an average website, that works just fine. If you generally only have a handful of concurrent connections (that is, simultaneous visitors), your system may be able to handle the memory being eaten up by that handful of processes.
Problems arise, however, as the number of concurrent connections increase. Eventually resource requirements, memory in particular, start growing astronomically. That’s when system administrators turn to nginx. Unlike Apache, it doesn’t need a separate process for every visitor. That’s because nginx is event-driven and non-blocking. This means when multiple users make requests, each of which is waiting on the database, or a PHP script or something else other than actually sending data to the user, nginx can move on and handle another request while the database or PHP script is doing its work.
So why isn’t the whole web already on nginx? nginx is more bare bones and simple than Apache, and doesn’t offer every single feature that Apache does. A lot of web software is written with Apache and some particular features it provides in mind. Depending on what you are doing, nginx may or may not be ideal for your site. But if you have good reason to expect heavy traffic loads, or are experiencing them already, it’s definitely worth investigating if nginx can work for you.