What is NGINX?
NGINX (pronounced “Engine-X”) is an open source, high-performance Hypertext Transfer Protocol (HTTP) server. In technical terms, it is an event-driven asynchronous server. This means the method by which NGINX handles processes (required for loading web content, for example) is driven by conditions and delegated to alternative server resources to bear the load accordingly. NGINX is typically used to exploit higher performance from minimal resources, for example, on a VPS hosting platform.
NGINX is versatile, in that it can be installed to replace Apache as the HTTP server. Because of its flexibility and lightweight design, it can also be installed along side Apache. In this manner, NGINX would be referred to as a reverse proxy.
How does NGINX compare to Apache?
On our servers, Apache is the default HTTP server that is configured for handling PHP processes to serve web content. In its default configuration, Apache is designed as a process-based architecture. This means that Apache forks (or threads) each process that is needed to serve web content.
NGINX alternatively scales these processes to help decrease the amount of CPU, RAM, and other server resources utilized, thus improving the load time. For instance, if one connection requests the same content as another, rather than processing those requests individually, NGINX analyzes and delegates accordingly. Both connections receive the same results of content loaded.
Although Apache and NGINX performance can both be similar in comparing load handling for small sites, NGINX’s architecture, by design, is more efficient for heavier sites. However, the benefits of NGINX can be experienced with simple web applications, like WordPress. A common configuration that is implemented to improve the handling of a high load, is to setup NGINX as a reverse proxy.
What is a Reverse Proxy?
A Reverse Proxy is a type of configuration in which a proxy server off loads a request to another web server (or multiple servers) to execute processes. When the results of the request are received by the proxy, it is then returned to the client. This kind of proxy results in the ability to cache dynamic content without having to continuously rely on the server’s resources for each request to load the same content. This results in a reduction of resources (like CPU, RAM, I/O) utilized and thus improves the performance of your site.
How Does a Reverse Proxy Work?
Putting this all together, typically server administrators will combine the use of Apache and NGINX as a reverse proxy to decrease the server resources needed to load a site’s content. Depending on NGINX’s configuration, when requests are made, it will first check to see if the processes have already been completed.
If the results of the requests do not exist, then NGINX will provide the requests to Apache for processing. Apache will handle the requests (forking/threading the requests) and then return the results to NGINX to serve to the client. If configured, it will also keep the results of the requests cached. This allows NGINX to quickly retrieve and serve them to any other connections that are requesting the same content.
If the results of the requests already exist, then NGINX will quickly retrieve and serve the cached content. NGINX may also be configured to analyze the cached version and update it with changes accordingly. Therefore eliminating the need for Apache to do anything for repeated visits/connections, even as content is updated.
Does NGINX work with WordPress hosting?
NGINX can be configured to handle your WordPress site so that your visitors will be able to see your site’s updated content and not just an outdated cached version. Included with your WordPress-optimized server is the cPanel plugin, Cache Manager. For more information on how you can simply leverage NGINX’s caching resources, review our article on the Cache Manager for cPanel.