rkihacker commited on
Commit
69dab88
·
verified ·
1 Parent(s): 5e1596b

Update gunicorn_config.py

Browse files
Files changed (1) hide show
  1. 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 a good default for containerized environments.
6
  bind = "0.0.0.0:8000"
7
 
8
  # --- Worker Processes ---
9
- # The number of worker processes for handling requests.
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
- # The type of worker to use. For an asyncio application like FastAPI,
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 can help prevent memory leaks.
24
  max_requests = 2048
25
 
26
- # A random jitter to the max_requests setting to prevent all workers
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
- # The location of the access log. "-" means log to stdout.
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"