Update gunicorn_config.py
Browse files- gunicorn_config.py +7 -19
gunicorn_config.py
CHANGED
|
@@ -2,42 +2,30 @@
|
|
| 2 |
|
| 3 |
# --- Server Socket ---
|
| 4 |
# Bind to all network interfaces on port 8000.
|
| 5 |
-
# This is
|
| 6 |
bind = "0.0.0.0:8000"
|
| 7 |
|
| 8 |
# --- Worker Processes ---
|
| 9 |
-
#
|
| 10 |
-
# A common recommendation is (2 * number_of_cpus) + 1.
|
| 11 |
-
# For a 2 CPU container, this defaults to 5 workers.
|
| 12 |
workers = 5
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
# we use the Uvicorn worker class.
|
| 16 |
worker_class = "uvicorn.workers.UvicornWorker"
|
| 17 |
|
| 18 |
# The maximum number of simultaneous clients that a single worker can handle.
|
| 19 |
-
# This is a good starting point for I/O-bound applications.
|
| 20 |
worker_connections = 1000
|
| 21 |
|
| 22 |
# The maximum number of requests a worker will process before restarting.
|
| 23 |
-
# This
|
| 24 |
max_requests = 2048
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
# from restarting at the same time.
|
| 28 |
max_requests_jitter = 512
|
| 29 |
|
| 30 |
# --- Logging ---
|
| 31 |
-
# The level of logging.
|
| 32 |
loglevel = "info"
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
accesslog = "-"
|
| 36 |
-
|
| 37 |
-
# The location of the error log. "-" means log to stderr.
|
| 38 |
-
errorlog = "-"
|
| 39 |
|
| 40 |
# --- Process Naming ---
|
| 41 |
-
# A base to use with setproctitle to change the way Gunicorn processes are
|
| 42 |
-
# named in the process table. This affects things like `ps` and `top`.
|
| 43 |
proc_name = "fastapi_reverse_proxy"
|
|
|
|
| 2 |
|
| 3 |
# --- Server Socket ---
|
| 4 |
# Bind to all network interfaces on port 8000.
|
| 5 |
+
# This is required for containerized environments.
|
| 6 |
bind = "0.0.0.0:8000"
|
| 7 |
|
| 8 |
# --- Worker Processes ---
|
| 9 |
+
# Based on (2 * number_of_cpus) + 1 for your 2 CPU container.
|
|
|
|
|
|
|
| 10 |
workers = 5
|
| 11 |
|
| 12 |
+
# Use Uvicorn's worker class for async applications.
|
|
|
|
| 13 |
worker_class = "uvicorn.workers.UvicornWorker"
|
| 14 |
|
| 15 |
# The maximum number of simultaneous clients that a single worker can handle.
|
|
|
|
| 16 |
worker_connections = 1000
|
| 17 |
|
| 18 |
# The maximum number of requests a worker will process before restarting.
|
| 19 |
+
# This helps prevent memory leaks in long-running applications.
|
| 20 |
max_requests = 2048
|
| 21 |
|
| 22 |
+
# Add a random jitter to max_requests to prevent all workers from restarting at once.
|
|
|
|
| 23 |
max_requests_jitter = 512
|
| 24 |
|
| 25 |
# --- Logging ---
|
|
|
|
| 26 |
loglevel = "info"
|
| 27 |
+
accesslog = "-" # Log to stdout
|
| 28 |
+
errorlog = "-" # Log to stderr
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
# --- Process Naming ---
|
|
|
|
|
|
|
| 31 |
proc_name = "fastapi_reverse_proxy"
|