From 1108a8536e5d177808d108868f317a20d92d1cb2 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Wed, 19 Nov 2025 10:07:10 +0800 Subject: [PATCH] fix: update max-requests configuration to be dynamic based on worker count --- apps/common/management/commands/services/services/gunicorn.py | 3 ++- .../management/commands/services/services/local_model.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/common/management/commands/services/services/gunicorn.py b/apps/common/management/commands/services/services/gunicorn.py index cc42c4f7c..a32220ab8 100644 --- a/apps/common/management/commands/services/services/gunicorn.py +++ b/apps/common/management/commands/services/services/gunicorn.py @@ -16,13 +16,14 @@ class GunicornService(BaseService): log_format = '%(h)s %(t)s %(L)ss "%(r)s" %(s)s %(b)s ' bind = f'{HTTP_HOST}:{HTTP_PORT}' + max_requests = 10240 if int(self.worker) > 1 else 0 cmd = [ 'gunicorn', 'smartdoc.wsgi:application', '-b', bind, '-k', 'gthread', '--threads', '200', '-w', str(self.worker), - '--max-requests', '10240', + '--max-requests', str(max_requests), '--max-requests-jitter', '2048', '--access-logformat', log_format, '--access-logfile', '-' diff --git a/apps/common/management/commands/services/services/local_model.py b/apps/common/management/commands/services/services/local_model.py index 05f4f5610..db11d2d40 100644 --- a/apps/common/management/commands/services/services/local_model.py +++ b/apps/common/management/commands/services/services/local_model.py @@ -25,13 +25,14 @@ class GunicornLocalModelService(BaseService): log_format = '%(h)s %(t)s %(L)ss "%(r)s" %(s)s %(b)s ' bind = f'{CONFIG.get("LOCAL_MODEL_HOST")}:{CONFIG.get("LOCAL_MODEL_PORT")}' worker = CONFIG.get("LOCAL_MODEL_HOST_WORKER", 1) + max_requests = 10240 if int(worker) > 1 else 0 cmd = [ 'gunicorn', 'smartdoc.wsgi:application', '-b', bind, '-k', 'gthread', '--threads', '200', '-w', str(worker), - '--max-requests', '10240', + '--max-requests', str(max_requests), '--max-requests-jitter', '2048', '--access-logformat', log_format, '--access-logfile', '-'