Skip to content

Instantly share code, notes, and snippets.

@minimedj
Forked from sumitsk20/uwgi-medium-post.ini
Created March 3, 2021 15:07
Show Gist options
  • Save minimedj/04496d9e8535c541d10bd4f2897b7e59 to your computer and use it in GitHub Desktop.
Save minimedj/04496d9e8535c541d10bd4f2897b7e59 to your computer and use it in GitHub Desktop.
uwsgi configuration with most commonly sused options for highly scalable website (medium blog post)
[uwsgi]
# telling user to execute file
uid = bunny
# telling group to execute file
gid = webapps
# name of project you during "django-admin startproject <name>"
project_name = updateMe
# building base path to where project directory is present [In my case this dir is also where my virtual env is]
base_dir = /webapps/%(project_name)
# set PYTHONHOME/virtualenv or setting where my virtual enviroment is
virtualenv = %(base_dir)
# changig current directory to project directory where manage.py is present
chdir = %(base_dir)/src/
# loading wsgi module
module = %(project_name).wsgi:application
# enabling master process with n numer of child process
master = true
processes = 4
# enabling multithreading and assigning threads per process
# enable-threads = true
# threads = 2
# Enable post buffering past N bytes. save to disk all HTTP bodies larger than the limit $
post-buffering = 204800
# Serialize accept() usage (if possibie).
thunder-lock = True
# Bind to the specified socket using default uwsgi protocol.
uwsgi-socket = %(base_dir)/run/uwsgi.sock
# set the UNIX sockets’ permissions to access
chmod-socket = 666
# Set internal sockets timeout in seconds.
socket-timeout = 300
# Set the maximum time (in seconds) a worker can take to reload/shutdown.
reload-mercy = 8
# Reload a worker if its address space usage is higher than the specified value (in megabytes).
reload-on-as = 512
# respawn processes taking more than 50 seconds
harakiri = 50
# respawn processes after serving 5000 requests
max-requests = 5000
# clear environment on exit
vacuum = true
# When enabled (set to True), only uWSGI internal messages and errors are logged.
disable-logging = True
# path to where uwsgi logs will be saved
logto = %(base_dir)/log/uwsgi.log
# maximum size of log file 20MB
log-maxsize = 20971520
# Set logfile name after rotation.
log-backupname = %(base_dir)/log/old-uwsgi.log
# Reload uWSGI if the specified file or directory is modified/touched.
touch-reload = %(base_dir)/src/
# Set the number of cores (CPUs) to allocate to each worker process.
# cpu-affinity = 1
# Reload workers after this many seconds. Disabled by default.
max-worker-lifetime = 300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment