You can improve the work of the web server which hosts customer websites
(Apache) by using nginx, a supplementary high-performance web server
which is typically used as a reverse proxy server. This web server was
specifically designed for delivering large amounts of static content
(such as images, video, css, xml, and so on). As opposed to Apache,
nginx is much more efficient when it comes to handling a large number of
concurrent connections. Another advantage of this web server compared
with Apache is that nginx has a significantly smaller memory footprint
per client connection.
To leverage all the benefits of nginx, Plesk configures it as a reverse
proxy server that stands between the Internet and Apache (see the
diagram below). This means that nginx becomes a frontend web server that
processes all incoming requests from site visitors. The requests are
sent to Apache which, in turn, distinguishes requests for static and
dynamic content. If a request is for a static file (such as jpg, css,
html, and so on), Apache passes the request through all registered
handlers (applies .htaccess
directory-level configuration, rewrites
a URL, and so on) and returns to nginx a response which contains only
the location of the requested file on the file system. nginx locates the
file and sends it to the client. If the request is for a dynamic file
(such as a PHP script), Apache executes the file and sends the response
to nginx, which delivers it to the client.
Such a combination of nginx and Apache gives the following advantages:
- The maximum number of concurrent connections to a website increases.
- The consumption of server CPU and memory resources decreases.
The maximum effect will be achieved for websites with a large amount
of static content (such as photo galleries, video streaming sites,
and so on). - The efficiency of serving visitors who have a slow connection speed
(GPRS, EDGE, 3G, and so on) improves.
For example, a client with a 10 KB/s connection requests a PHP
script, which generates a 100 KB response. If there is no nginx on
the server, the response is delivered by Apache. During the 10
seconds required to deliver the response, Apache and PHP continue to
consume full system resources for this open connection. If nginx is
installed, Apache forwards the response to nginx (the nginx-to-Apache
connection is very fast as both of them are located on the same
server) and releases system resources. As nginx has a smaller memory
footprint, the overall load on the system decreases. If you…