The Promise and Potential of NGINX
You’ve probably come across the name ‘nginx’ during your searches for hosting websites. Nginx has a reputation for being lightweight and quick, but without lots of extra features. It’s not known for doing everything — it’s known for doing a few things well.
Nginx was released in 2004 as free and open-source software that can be used on diverse operating systems, from Windows to BSD to Unix & Linux systems. It processes requests in an event-driven manner, handling queries to the server in a quick, low-resource-footprint manner as they come in.
This means resources are dynamically allocated and released, granting workers the ability to handle a gigantic number of queries without getting stuck and running out of CPU cycles. The server can then use those cycles elsewhere, optimizing the CPU and memory usage.
What Does Nginx Do Best?
Nginx is known to be exceptional at serving static pages. With how lightweight it is, content is provided quickly. And with its effective resource usage, nginx doesn’t get locked up trying to serve static content multiple times.
Being event-driven really makes quite a positive difference when dealing with a huge amount of hits at once.
Another powerful function is using nginx as a reverse proxy, which grants a user even more control over how content is handled, allowing actions such as:
- Passing content to another server
- Hosting multiple services on the same IP
- Serving content from different web servers over the same IP and protocol
Looking at these capabilities in another way, you can couple nginx with Apache2. Using it as a reverse proxy, you can go so far as to have nginx act as a caching service for Apache2, grabbing Apache2’s generated pages and serving them in future queries. (For more detail, check out Linode’s guide on how to set up a reverse proxy here.)
Nginx is also known to be an effective load balancing solution, making it a potential component of high availability. The configuration is intuitive and lets you tweak for load balancing method, weight, persistence, number of connections, and more.
Setting up nginx as a load balancer eliminates the need to find another service to do it for you. This reduces the clutter in your infrastructure and allows you to make all the changes in one place. You can find out how to make this possible on nginx’s official guide here.
A commercial edition is also available, called NGINX Plus, which grants additional features, like powerful caching. In addition to serving cached content, NGINX Plus can also serve cached pages when they’d be otherwise unavailable due to database errors or coding issues. An example of this is if a 5xx error occurred, NGINX Plus will recognize the error and serve a cached version of the page. This type of server setup takes only a small amount of configuration. Here’s a guide on setting up caching with NGINX.
Being lightweight and fast are enough reasons to use the service, and these reasons alone convince many to implement it in their stacks. Nginx is all about keeping content up, running, and quickly reachable. Coupling this primary purpose with how it dynamically uses resources shows why it’s such a powerful website hosting tool.
Because nginx is open source and free, there’s really no reason not to give it a try. You can find documentation everywhere online about how to use it. I recommend checking out Linode’s nginx installation guide; then, feel free to tell us about your experiences with nginx in the comments below, or tweet them to me, @Linode or @feelingsohsoh!