Book Image

NGINX High Performance

By : Rahul Sharma
Book Image

NGINX High Performance

By: Rahul Sharma

Overview of this book

<p>NGINX is one of the most common free, open source web servers. Its performance-oriented architecture and small footprint makes it an ideal choice for high-traffic websites.</p> <p>NGINX offers great performance and optimal resource utilization to its administrators. This practical guide walks you through how to tune one of the leading free open source web servers to attain optimal performance for high-traffic sites. It also explores ways to improve network utilization for high loads.</p> <p>The tour starts with an overview of the NGINX architecture. You will build and configure NGINX for optimal utilization of the hardware available. The book demonstrates various practices to improve last mile content delivery by using timeouts, caching, and compression. You'll also discover various free open source tools to test and benchmark web server performance, allowing you to verify NGINX performance at every step.</p>
Table of Contents (14 chapters)

Configuring NGINX workers


NGINX runs a fixed number of worker processes as per the specified configuration. As explained in Chapter 1, Working with NGINX, these worker processes are responsible for all request processing. In the following sections, we will work with NGINX worker parameters. These parameters are mostly part of the NGINX global context.

worker_processes

The worker_processes directive controls the number of workers:

worker_processes 1;

The default value for this is 1, which means that NGINX runs only one worker. The value should be changed to an optimal value depending on the number of cores available, disks, network subsystem, server load, and so on.

As a starting point, set the value to the number of cores available. Determine the number of cores available using lscpu:

$ lscpu
Architecture:     x86_64
CPU op-mode(s):    32-bit, 64-bit
Byte Order:      Little Endian
CPU(s):        4

The same can be accomplished by greping out cpuinfo:

$ cat /proc/cpuinfo | grep 'processor' | wc...