Update gunicorn_config.py
Browse files- gunicorn_config.py +12 -17
gunicorn_config.py
CHANGED
|
@@ -1,31 +1,26 @@
|
|
| 1 |
-
|
| 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 |
-
#
|
| 10 |
-
workers =
|
| 11 |
|
| 12 |
-
#
|
| 13 |
worker_class = "uvicorn.workers.UvicornWorker"
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
worker_connections =
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
-
|
| 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 = "-"
|
| 28 |
-
errorlog = "-"
|
| 29 |
|
| 30 |
# --- Process Naming ---
|
| 31 |
-
proc_name = "fastapi_reverse_proxy"
|
|
|
|
| 1 |
+
import multiprocessing
|
| 2 |
|
| 3 |
# --- Server Socket ---
|
|
|
|
|
|
|
| 4 |
bind = "0.0.0.0:8000"
|
| 5 |
|
| 6 |
# --- Worker Processes ---
|
| 7 |
+
# Dynamically calculate based on CPU count
|
| 8 |
+
workers = multiprocessing.cpu_count() * 2 + 1
|
| 9 |
|
| 10 |
+
# For async FastAPI apps
|
| 11 |
worker_class = "uvicorn.workers.UvicornWorker"
|
| 12 |
|
| 13 |
+
# Use a high but safe connection limit
|
| 14 |
+
worker_connections = 100000
|
| 15 |
|
| 16 |
+
# Disable forced restarts (optional, not recommended for memory-leaky apps)
|
| 17 |
+
max_requests = 0
|
| 18 |
+
max_requests_jitter = 0
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# --- Logging ---
|
| 21 |
loglevel = "info"
|
| 22 |
+
accesslog = "-"
|
| 23 |
+
errorlog = "-"
|
| 24 |
|
| 25 |
# --- Process Naming ---
|
| 26 |
+
proc_name = "fastapi_reverse_proxy"
|