+Six tips for nginx speed performance



NGINX, pronounced as Engine-X, is an open source, high-performance, lightweight web server. It is also used as reverse proxy server for HTTP, HTTPS, SMTP, IMAP, POP3 protocols.

NGINX is useful for HTTP cache and servers load balancing. The popularity of the NGINX can be judged from the fact that it is responsible for serving more than 50% of the traffic on the Internet.

Though NGINX is built for performance and speed, you need to also play some part. Here are 6 tips through which you can keep your NGINX setup performing at its best.


1. Regulate work processes

The work processes (Master process and worker process) and the connection between them are two important variables that need to be tuned for NGINX optimal performance. The directive of the work processes is extremely important for NGINX. The main purpose of the master process is to read and evaluate configuration of worker processes.

The worker processes tells the virtual sever how many cores are assigned to each processor, and this allows the NGINX event based model mechanism to manage concurrent requests in an optimized way. To find the number of processors in your web server, type the following command.

grep processor /proc/cpuinfo | wc –l

The output will show the number of worker processes per core which in our case is 1. This means the machine has 1 core. If your website has lower traffic, you need to set work processes to 1 in the NGINX configuration file to get optimal performance.

worker_processes 1;

If you have higher traffic or a dedicated site for NGINX, you need to set one worker per core.

worker_processes auto;


2.Maximize worker connections

The worker connections tells worker processes the number of clients that can be served simultaneously by NGINX. The default work connection limit is 768, but you need to understand each browser will open at least two server connections and NGINX system has the capacity to handle more. You can find out the number for worker connections by a command:

ulimit –n

On majority of the machines, the maximum numbers of worker connection supported are 1024. If the output of the above command is 1024, it implies that NGINX can serve 1024 clients per second.

Now you can go ahead and set the maximum worker connection limit to 1024. Here are steps to update NGINX config

sudo nano /etc/nginx/nginx.conf

worker_processes 1;

worker_connections 1024;


3. Activate Gzip Compression

Gzip is a utility used for file compression and decompression. The application is supported by majority of clients and server. When a Gzip compatible browser sends requests for resource, the server will compress the response before sending it to the browser.

Gzip offers great way to makes things more efficient and optimize NGINX server. Here are simple steps to activate Gzip in NGINX environment.

You need to create a file at /etc/nginx/conf.d/gzip.conf and type following commands in it:Gzip on;

gzip_proxied any;

gzip_types text/plain text/xml text/css application/x-javascript;

gzip_vary on;

gzip_disable “MSIE [1-6]\.(?!.*SV1)”;

After creating the file, you need to restart your server and then you will serve site assets to users with Gzip compression.


4. Enable Cache for Static Files

Caching is a great way to optimize performance of NGINX. Within your NGINX environment, you need to instruct the server to cache web page’s static files for faster accessibility. You need to add following commands to tell your server to serve static content. The default location for this operation


location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {

expires 365d;


When you add these commands as the directives, all image, audio, and video files will get an expires header with a date of 365 in the future from the browser access time.


5. Disable access logs

The NGINX environment creates log files for every action that affects performance. By disabling it, you can save valuable hard drive space and reduce additional processing. To disable access logs, you need to write access_log off; next to the access_log syntax.


6.Use Monitis to monitor NGINX server

Monitis is a leading web performance monitoring tool that allows you to monitor NGINX servers closely. The monitoring tool provides first-hand report on server health and performance in cloud-based environment. It allows you to learn about potential problems before users are affected or complain about it. Monitis enables you to keep the server infrastructure smooth and running more effectively. It keeps you stress free and helps you focus on business.

Leave a Reply

Your email address will not be published. Required fields are marked *

9 + nineteen =

Security code * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.