Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit 29f0b17

Browse files
Reduce worker count on development deploys
Launching large numbers of workers causes issues on high core count machines when developing in WSL
1 parent a6d3b75 commit 29f0b17

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

docker/gunicorn_config/fastapi_config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
wsgi_app = "bookserver.main:app"
3434

3535
# `workers <https://docs.gunicorn.org/en/stable/settings.html#workers>`_: The number of worker processes for handling requests. Pick this based on CPU count.
36-
workers = multiprocessing.cpu_count() * 2 + 1
36+
if os.environ["BOOK_SERVER_CONFIG"] == "development":
37+
workers = 4
38+
else:
39+
workers = multiprocessing.cpu_count() * 2 + 1
3740

3841
# `worker_class <https://docs.gunicorn.org/en/stable/settings.html#worker-class>`_: The type of workers to use. Use `uvicorn's worker class for gunicorn <https://www.uvicorn.org/deployment/#gunicorn>`_.
3942
worker_class = "uvicorn.workers.UvicornWorker"

docker/gunicorn_config/web2py_config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
wsgi_app = "wsgihandler:application"
3333

3434
# `workers <https://docs.gunicorn.org/en/stable/settings.html#workers>`_: The number of worker processes for handling requests. Pick this based on CPU count.
35-
workers = multiprocessing.cpu_count()
35+
if os.environ["BOOK_SERVER_CONFIG"] == "development":
36+
workers = 4
37+
else:
38+
workers = multiprocessing.cpu_count()
3639

3740
# `bind <https://docs.gunicorn.org/en/stable/settings.html#bind>`_: The socket to bind. This must match the socket nginx sends to.
3841
bind = "unix:/run/web2py.sock"

0 commit comments

Comments
 (0)