From f26b7a470a351d6f36eafa3f42b9b85a0120830c Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Fri, 20 Nov 2020 20:23:09 +0800 Subject: [PATCH] =?UTF-8?q?perf(celery-task):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E8=8A=82=E7=82=B9=E8=B5=84=E4=BA=A7=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=9A=84=20Celery=20=E4=BB=BB=E5=8A=A1=20(#5052)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: xinwen --- apps/assets/tasks/nodes_amount.py | 2 +- apps/assets/utils.py | 2 +- jms | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/assets/tasks/nodes_amount.py b/apps/assets/tasks/nodes_amount.py index 0ec0810a0..3ae191788 100644 --- a/apps/assets/tasks/nodes_amount.py +++ b/apps/assets/tasks/nodes_amount.py @@ -8,6 +8,6 @@ logger = get_logger(__file__) @register_as_period_task(crontab='0 2 * * *') -@shared_task(queue='node_assets_amount') +@shared_task(queue='celery_heavy_tasks') def check_node_assets_amount_celery_task(): check_node_assets_amount() diff --git a/apps/assets/utils.py b/apps/assets/utils.py index f04c06d0b..c4c112c16 100644 --- a/apps/assets/utils.py +++ b/apps/assets/utils.py @@ -25,7 +25,7 @@ def check_node_assets_amount(): node.assets_amount = assets_amount node.save() # 防止自检程序给数据库的压力太大 - time.sleep(2) + time.sleep(0.1) def is_asset_exists_in_node(asset_pk, node_key): diff --git a/jms b/jms index d3ede99ff..4cc7e916d 100755 --- a/jms +++ b/jms @@ -158,7 +158,7 @@ def parse_service(s): web_services = ['gunicorn', 'flower', 'daphne'] celery_services = [ "celery_ansible", "celery_default", "celery_node_tree", - "celery_check_asset_perm_expired", "celery_node_assets_amount" + "celery_check_asset_perm_expired", "celery_heavy_tasks" ] task_services = celery_services + ['beat'] all_services = web_services + task_services @@ -228,9 +228,9 @@ def get_start_celery_node_tree_kwargs(): return get_start_worker_kwargs('node_tree', 2) -def get_start_celery_node_assets_amount_kwargs(): - print("\n- Start Celery as Distributed Task Queue: NodeAssetsAmount") - return get_start_worker_kwargs('celery_node_assets_amount', 1) +def get_start_celery_heavy_tasks_kwargs(): + print("\n- Start Celery as Distributed Task Queue: HeavyTasks") + return get_start_worker_kwargs('celery_heavy_tasks', 1) def get_start_celery_check_asset_perm_expired_kwargs(): @@ -374,7 +374,7 @@ def start_service(s): "celery_ansible": get_start_celery_ansible_kwargs, "celery_default": get_start_celery_default_kwargs, "celery_node_tree": get_start_celery_node_tree_kwargs, - "celery_node_assets_amount": get_start_celery_node_assets_amount_kwargs, + "celery_heavy_tasks": get_start_celery_heavy_tasks_kwargs, "celery_check_asset_perm_expired": get_start_celery_check_asset_perm_expired_kwargs, "beat": get_start_beat_kwargs, "flower": get_start_flower_kwargs,