• <i id='ppWjs'><tr id='ppWjs'><dt id='ppWjs'><q id='ppWjs'><span id='ppWjs'><b id='ppWjs'><form id='ppWjs'><ins id='ppWjs'></ins><ul id='ppWjs'></ul><sub id='ppWjs'></sub></form><legend id='ppWjs'></legend><bdo id='ppWjs'><pre id='ppWjs'><center id='ppWjs'></center></pre></bdo></b><th id='ppWjs'></th></span></q></dt></tr></i><div id='ppWjs'><tfoot id='ppWjs'></tfoot><dl id='ppWjs'><fieldset id='ppWjs'></fieldset></dl></div>
  • <small id='ppWjs'></small><noframes id='ppWjs'>

    <tfoot id='ppWjs'></tfoot>
    • <bdo id='ppWjs'></bdo><ul id='ppWjs'></ul>

    1. <legend id='ppWjs'><style id='ppWjs'><dir id='ppWjs'><q id='ppWjs'></q></dir></style></legend>

        使用 Celery 创建动态队列

        Create dynamic queues with Celery(使用 Celery 创建动态队列)

            <i id='azYcI'><tr id='azYcI'><dt id='azYcI'><q id='azYcI'><span id='azYcI'><b id='azYcI'><form id='azYcI'><ins id='azYcI'></ins><ul id='azYcI'></ul><sub id='azYcI'></sub></form><legend id='azYcI'></legend><bdo id='azYcI'><pre id='azYcI'><center id='azYcI'></center></pre></bdo></b><th id='azYcI'></th></span></q></dt></tr></i><div id='azYcI'><tfoot id='azYcI'></tfoot><dl id='azYcI'><fieldset id='azYcI'></fieldset></dl></div>
            1. <legend id='azYcI'><style id='azYcI'><dir id='azYcI'><q id='azYcI'></q></dir></style></legend>

            2. <small id='azYcI'></small><noframes id='azYcI'>

              <tfoot id='azYcI'></tfoot>
              • <bdo id='azYcI'></bdo><ul id='azYcI'></ul>

                    <tbody id='azYcI'></tbody>
                  本文介绍了使用 Celery 创建动态队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是我的场景:

                  当用户登录我的网站时,我为给定用户排队了一堆任务(通常每个任务需要 100 毫秒,每个用户有 100 多个任务).这些任务排队到默认的 Celery Queue 中,我有 100 名工作人员正在运行.当后端任务完成时,我使用 websockets 向用户显示实时进度.如果我只有 1 或 2 个活跃用户,生活就会很美好.

                  When a user logs in to my website, I queue up a bunch of tasks for the given user (typically each task takes 100s of msecs and there are 100s of tasks per user). These tasks are queued to the default Celery Queue and I have 100s of workers running. I use websockets to show the user real-time progress as the tasks complete on the backend. Life is good if I have just 1 or 2 users active.

                  现在,如果我有几个并发用户登录到我的站点,后面的用户会排在初始用户后面,他们的任务就会饿死(因为所有任务都进入同一个队列).我的想法是为每个用户创建一个动态队列以确保公平.但是根据芹菜文档(http://docs.celeryproject.org/en/latest/userguide/routing.html#defining-queues),看来我需要静态定义队列.

                  Now if I a few concurrent users log-in to my site, the latter users are queued behind the initial users and their tasks starve (since all the tasks go to the same queue). My thoughts are to create a dynamic queue per user to ensure fairness. However as per Celery documentation (http://docs.celeryproject.org/en/latest/userguide/routing.html#defining-queues), seems I need to be define the queues statically.

                  关于在我的场景中使用 celery 的最佳实践有什么建议吗?

                  Any suggestions on best practices for using celery for my scenario?

                  推荐答案

                  http://docs.celeryproject.org/en/latest/userguide/workers.html#queues

                  celery -A proj control add_consumer foo -d worker1.local
                  

                  同样可以使用 app.control.add_consumer() 方法动态完成:

                  The same can be accomplished dynamically using the app.control.add_consumer() method:

                  app.control.add_consumer('foo', reply=True)
                  [{u'worker1.local': {u'ok': u"already consuming from u'foo'"}}]
                  
                  app.control.add_consumer('foo', reply=True,
                  destination=['worker1@example.com'])
                  

                  这篇关于使用 Celery 创建动态队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                  <i id='7oFWl'><tr id='7oFWl'><dt id='7oFWl'><q id='7oFWl'><span id='7oFWl'><b id='7oFWl'><form id='7oFWl'><ins id='7oFWl'></ins><ul id='7oFWl'></ul><sub id='7oFWl'></sub></form><legend id='7oFWl'></legend><bdo id='7oFWl'><pre id='7oFWl'><center id='7oFWl'></center></pre></bdo></b><th id='7oFWl'></th></span></q></dt></tr></i><div id='7oFWl'><tfoot id='7oFWl'></tfoot><dl id='7oFWl'><fieldset id='7oFWl'></fieldset></dl></div>
                  <legend id='7oFWl'><style id='7oFWl'><dir id='7oFWl'><q id='7oFWl'></q></dir></style></legend>
                    <tbody id='7oFWl'></tbody>
                  • <bdo id='7oFWl'></bdo><ul id='7oFWl'></ul>

                        <tfoot id='7oFWl'></tfoot>
                          1. <small id='7oFWl'></small><noframes id='7oFWl'>