Last active
November 23, 2022 07:33
-
-
Save Shawn1224/a2187e8ffc4a1bf7cc257d702e4b0897 to your computer and use it in GitHub Desktop.
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] | |
strict = true ; 显式声明!要啥配啥,不要瞎配没有的东西,有的可能有但是不一定兼容,没有用的就不要配了 | |
py-autoreload = 1 ; 修改代码后自动重启 | |
chdir = /data/service/xxx | |
wsgi-file = xxx/wsgi.py | |
pidfile = ./project-master.pid | |
master = true | |
enable-threads = true | |
protocol = uwsgi | |
vacuum = true | |
; https://www.techatbloomberg.com/blog/configuring-uwsgi-production-deployment/ | |
; Disabling this feature appears to have no negative impact, | |
; while also reducing the odds of compatibility issues | |
; that may waste development time or cause production outages. | |
single-interpreter = true | |
; 坑!如果是 false 可能 kill 失败 | |
; You should enable this feature because it makes uWSGI behave | |
; in the way that any sane developer would expect. | |
die-on-term = true | |
; 坑!可能造成启动失败服务可用的假象 | |
; need-app = false 是远古时代的最佳实践了 | |
need-app = true | |
; identify the workers | |
http-socket = 0.0.0.0:8095 | |
buffer-size = 65535 | |
max-requests = 1000 ; Restart workers after this many requests | |
max-worker-lifetime = 3600 ; Restart workers after this many seconds | |
reload-on-rss = 2048 ; Restart workers after this much resident memory | |
worker-reload-mercy = 60 ; How long to wait before forcefully killing workers | |
; Too many workers may cause oom. Keep balance between workers and memory. | |
; You must Choose wisely. | |
; For example: | |
; 4G mem per pod. | |
; One worker need 110~120m RES at leat. | |
; 4096 / 120 = 34.13 | |
; 32 = 8 * 4 | |
cheaper-algo = busyness | |
processes = 32 ; Maximum number of workers allowed | |
cheaper = 8 ; Minimum number of workers allowed | |
cheaper-initial = 8 ; Workers created at startup | |
cheaper-overload = 1 ; Length of a cycle in seconds | |
cheaper-step = 8 ; How many workers to spawn at a time | |
cheaper-busyness-multiplier = 30 ; How many cycles to wait before killing workers | |
cheaper-busyness-min = 10 ; Below this threshold, kill workers (if stable for multiplier cycles) | |
cheaper-busyness-max = 90 ; Above this threshold, spawn new workers | |
cheaper-busyness-backlog-alert = 8 ; Spawn emergency workers if more than this many requests are waiting in the queue | |
cheaper-busyness-backlog-step = 2 ; How many emergency workers to create if there are too many requests in the queue | |
cheaper-busyness-multiplier = 30 ; How many cycles to wait before killing workers | |
cheaper-busyness-min = 20 ; Below this threshold, kill workers (if stable for multiplier cycles) | |
cheaper-busyness-max = 70 ; Above this threshold, spawn new workers | |
cheaper-busyness-backlog-alert = 16 ; Spawn emergency workers if more than this many requests are waiting in the queue | |
cheaper-busyness-backlog-step = 2 ; How many emergency workers to create if there are too many requests in the queue | |
; http-timeout is for client, hrakiri is for chef | |
; Let us assume http-timeout is less than harakiri(http-timeout = 60, harakiri = 80), | |
; that means client order a pizza at the restaurant, after 60 seconds the pizza is not made, | |
; then client lefet, but chef is still working | |
harakiri = 600 ; Forcefully kill workers after 10 minutes. Should equal to http-timeout | |
http-timeout = 600 | |
log-4xx = true | |
log-5xx = true | |
auto-procname = true | |
;daemonize = | |
;logto = | |
;log-maxsize = 52428800 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment