Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

celery异步分布式工具调研 #67

Open
guochaorong opened this issue Jun 13, 2018 · 0 comments
Open

celery异步分布式工具调研 #67

guochaorong opened this issue Jun 13, 2018 · 0 comments
Assignees

Comments

@guochaorong
Copy link
Collaborator

guochaorong commented Jun 13, 2018

http://www.celeryproject.org/
teamcity上只支持3个免费agent。 如果将来需要测试若干种机型task, 需要加若干agent才能支持。
调研了celery 工具

流程

master监测到teamcity 上的queue 中有tasks,
执行相应的调度

@app.task
def V100():
    #Run tasks on v100
    return {"task_kpis":"kpis_values", "task_type": "v100"}

@app.task
def P40():
    #Run tasks on P40
    return {"task_kpis":"kpis_values", "task_type": "p40"}

if __name__ == "__main__":
    if "task name is startswith v100":
        re = V100.delay()
    elif "task name is startswith p40":
        re = P40.delay()
    print(re.result)
    print(re.get(timeout=2))
    print(re.status)

每一个work机器上启动work 监控进程
比如v100 work上

@app.task
def V100():
    #Run tasks on v100
    return {"task_kpis":"kpis_values", "task_type": "v100"}
celery -A download  worker -l info -c 5

当master执行时, v100 worker上就会收到消息并执行V100函数

[2018-06-13 18:45:00,533: INFO/MainProcess] Received task: download.V100[03a74fb0-df6a-4ec0-b9cc-bc8e4870194e]  
[2018-06-13 18:45:00,541: INFO/ForkPoolWorker-3] Task download.V100[03a74fb0-df6a-4ec0-b9cc-bc8e4870194e] succeeded in 0.00594224780798s: {'task_kpis': 'kpis_values'}

master上可以拿到各个worker的返回

{u'task_type': u'v100', u'task_kpis': u'kpis_values'}

celery存在的问题

  1. 多机时, 每个机器上都要有所有代码, master上并未执行真正逻辑, 依然需要注册该函数。
    文档中对于多机使用不清晰,

  2. 我们ce中所有步骤都在docker中执行, 采用celery,所有命令都得加上docker run XX, 并且可能会踩坑

  3. 这样其实破坏了teamcity 本来的queue 队列和pool池子的 异步调用功能。考虑到优先维护好v100 和 p40 两个场景下tasks功能完备性, 目前agent 数目并不是瓶颈。

和春伟讨论决定继续按照加agent 方式进行, 以后有需要再用工具流

@guochaorong guochaorong changed the title Celery异步分布式工具调研 celery异步分布式工具调研 Jun 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants