Last active
January 30, 2024 07:58
-
-
Save sumitsk20/021ace4d1c3426618109e9e698eb97f4 to your computer and use it in GitHub Desktop.
uwsgi configuration with most commonly sused options for highly scalable website (medium blog post)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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
@dinesh-kapri you can use logrotate for that
Sample logrotate setup.