Skip to content

Instantly share code, notes, and snippets.

View kumaraswins's full-sized avatar
🎯
Focusing

AswinKumar kumaraswins

🎯
Focusing
View GitHub Profile
@kumaraswins
kumaraswins / nginx-tuning.md
Created July 17, 2021 04:28 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@kumaraswins
kumaraswins / create_psql_bash
Created March 17, 2021 05:59
Bash for psql
#!/bin/bash
echo "Please enter the database name"
read DB_NAME
echo "Please enter the database password"
read DB_PASSWORD
sudo su postgres <<EOF
psql -c 'CREATE DATABASE ${DB_NAME};'
psql -c "CREATE ROLE ${DB_NAME} WITH LOGIN PASSWORD 'password';"
psql -c 'GRANT ALL PRIVILEGES ON DATABASE ${DB_NAME} TO ${DB_NAME};'
If you get this error
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.
execute the following command
sudo chmod 666 /var/run/docker.sock
var formulateData = function(oList){
var json = {};
for (var i=0;i<oList.length;i++){
json[oList[i]["name"]] = oList[i]["value"]
}
return {"data":json};
}
@kumaraswins
kumaraswins / mysql
Created January 29, 2020 06:39
Change the default mysql password
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
@kumaraswins
kumaraswins / gitignore_python.txt
Created December 31, 2019 14:43
Python gitignore file
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
@kumaraswins
kumaraswins / gitignore_node.txt
Created December 31, 2019 14:42
node js gitignore mac files
##########################
# Application specfic
##########################
# config/config.js
##########################
# General
##########################
#####
@kumaraswins
kumaraswins / get_bm_ip
Created December 27, 2019 12:43
Get the VM ip address pythonic way
curl http://checkip.amazonaws.com
import requests
requests.get('http://checkip.amazonaws.com').text.rstrip()
@kumaraswins
kumaraswins / staus code django
Created June 17, 2019 10:56
Django satus code
Informational - 1xx
HTTP_100_CONTINUE
HTTP_101_SWITCHING_PROTOCOLS
Successful - 2xx
HTTP_200_OK
HTTP_201_CREATED
HTTP_202_ACCEPTED
worker_processes
A worker process is a single-threaded process.
If Nginx is doing CPU-intensive work such as SSL or gzipping and you have 2 or more CPUs/cores,
then you may set worker_processes to be equal to the number of CPUs or cores.
If you are serving a lot of static files and the total size of the files is bigger than the available memory,
then you may increase worker_processes to fully utilize disk bandwidth.