From 1fe23f5e41a8ea8c4f0f429189cd1edbbe53909c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com> Date: Mon, 1 Dec 2025 20:09:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MangoServer/src/settings/__init__.py | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/MangoServer/src/settings/__init__.py b/MangoServer/src/settings/__init__.py index ce07444f..46ab9c3b 100644 --- a/MangoServer/src/settings/__init__.py +++ b/MangoServer/src/settings/__init__.py @@ -105,6 +105,9 @@ ASGI_APPLICATION = 'src.asgi.application' CHANNEL_LAYERS = { 'default': { 'BACKEND': 'channels.layers.InMemoryChannelLayer', + 'CONFIG': { + 'capacity': 1000, # 增加通道容量 + } } } # ********************************************************************************************************************** @@ -118,26 +121,26 @@ if not IS_SQLITE: 'PASSWORD': MYSQL_PASSWORD, 'HOST': MYSQL_IP, 'PORT': MYSQL_PORT, - 'TEST': { - 'NAME': f'test_{MYSQL_DB_NAME}', - 'CHARSET': 'utf8mb4', - 'COLLATION': 'utf8mb4_general_ci' - }, 'OPTIONS': { 'charset': 'utf8mb4', - 'connect_timeout': 5, - 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", + 'connect_timeout': 20, # 增加到20秒 + 'read_timeout': 60, # 增加读取超时到60秒 + 'write_timeout': 60, # 增加写入超时到60秒 + 'init_command': "SET sql_mode='STRICT_TRANS_TABLES', wait_timeout=28800", 'isolation_level': 'READ COMMITTED', 'autocommit': True, }, 'POOL_OPTIONS': { - 'POOL_SIZE': 20, - 'MAX_OVERFLOW': 50, - 'RECYCLE': 3600, - 'TIMEOUT': 30, - 'PRE_PING': True, + 'POOL_SIZE': 20, # 增加连接池大小 + 'MAX_OVERFLOW': 30, # 增加最大溢出 + 'RECYCLE': 3600, # 延长回收时间到1小时 + 'TIMEOUT': 30, # 增加获取连接超时到30秒 + 'PRE_PING': True, # 保持开启 + 'ECHO': False, # 关闭SQL日志 + 'MAX_POOL_SIZE': 50, # 增加最大池大小限制 + 'POOL_RECYCLE': 3600, # 明确指定池回收 }, - 'CONN_MAX_AGE': 0, + 'CONN_MAX_AGE': 3600, # 改为3600秒,与RECYCLE一致 } } else: