[My-Version] – NGINX Performance Tuning.

Good evening bloggers,

Lately have been facing an issue with websites getting loaded, so with all my experience, I tried to deploy my Super Saiyan on the Nginx webserver

This is what I did,

#############################################################

sysctl -w net.core.rmem_max=8388608
sysctl -w net.core.rmem_default=65536
sysctl -w net.core.wmem_max=8388608
sysctl -w net.core.wmem_default=65536
sysctl net.ipv4.tcp_window_scaling
sysctl -w net.ipv4.tcp_mem=’8388608 8388608 8388608′
sysctl -w net.ipv4.tcp_rmem=’4096 87380 8388608′
sysctl -w net.ipv4.tcp_wmem=’4096 65536 8388608′
sysctl -w net.ipv4.route.flush=1
sysctl -w net.ipv4.tcp_retries2=7
sysctl -w vm.overcommit_memory=2
sysctl -w vm.overcommit_ratio=25
sysctl -w vm.swappiness=25

#############################################################

dd if=/dev/zero of=/swapfile count=8192 bs=1MiB (use this)
#fallocate -l 8G /swapfile (or this)
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo “/swapfile none swap sw 0 0” | sudo tee -a /etc/fstab

#############################################################

vim /etc/nginx/nginx.conf

(Edit the following Sections)

worker_processes auto;

events {
worker_connections 4000;
use epoll;
}

worker_rlimit_nofile 10000;

http {

fastcgi_read_timeout 300;
proxy_read_timeout 300;

}

service nginx reload

############################################################

vim /etc/security/limits.conf

<os user> soft nofile 350000
<os user> hard nofile 350000
<os user> soft nproc 65536
<os user> hard nproc 65536
<os user> soft stack 10240
<os user> hard stack 10240
<os user> soft nofile 350000
<os user> hard nofile 350000

############################################################

vim /etc/security/limits.d/90-nproc.conf

* soft nproc unlimited

############################################################

After this, we tested 2000 users on JMeter and we hardly got 0.45 % of errors from 47% before tuning.

Please do try this and still if it doesn’t work, then please do a post on the comment section.

 

HTTP Status Codes:- 1xx (Informational)

  • 100 Continue :- The client SHOULD continue with its request. This interim response is used to inform the client that the initial part of the request has been received and has not yet been rejected by the server. The client SHOULD continue by sending the remainder of the request or, if the request has already been completed, ignore this response. The server MUST send a final response after the request has been completed.
  • 102 Processing (WebDAV) :- The 102 (Processing) status code is an interim response used to inform the client that the server has accepted the complete request, but has not yet completed it. This status code SHOULD only be sent when the server has a reasonable expectation that the request will take significant time to complete. As guidance, if a method is taking longer than 20 seconds (a reasonable, but arbitrary value) to process the server SHOULD return a 102 (Processing) response. The server MUST send a final response after the request has been completed.Methods can potentially take a long period of time to process, especially methods that support the Depth header. In such cases the client may time-out the connection while waiting for a response. To prevent this the server may return a 102 (Processing) status code to indicate to the client that the server is still processing the method.
  • 101 Switching Protocols :-The server understands and is willing to comply with the client’s request, via the Upgrade message header field, for a change in the application protocol being used on this connection.The server will switch protocols to those defined by the response’s Upgrade header field immediately after the empty line which terminates the 101 response. The protocol SHOULD be switched only when it is advantageous to do so. For example, switching to a newer version of HTTP is advantageous over older versions, and switching to a real-time, synchronous protocol might be advantageous when delivering resources that use such features.