[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.

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s