Giter Club home page Giter Club logo

Comments (5)

ydf0509 avatar ydf0509 commented on June 15, 2024

本来就是有界队列,不会迅速从redis拉取100万任务到python内存里面的,如果是这样的,那就后启动的消费者始终消费不到任务,不可能设计成这样的。这点放心,因为这使用的是有界线程/协程池,你说的那种迅速掏空reids因为使用的是官方concurrent.futures.Threadpolexecutor了才会发生这种悲剧。

高实时接口,可以设置如果多少秒后才轮到消费就丢弃任务,文档已近说明了。

from distributed_framework.

ydf0509 avatar ydf0509 commented on June 15, 2024

任务队列的size不需要你来手动调整,不希望暴露过多自定义参数。比如你设置并发是100,那么会有100个任务正在并发运行,同时python 本地queue队列会缓存100个任务。所以即使你短时间推送100万任务到消息中间件,也不会迅速掏空的

from distributed_framework.

ydf0509 avatar ydf0509 commented on June 15, 2024

本地队列的size默认是等于并发数量。从你描述的,应该是以前有使用官方 concurrent.futures.Threadpolexecutor 的经历,被那个坑惨了,那个总是迅速把redis的任务全部一股脑拿到python的queue对象里面去了,然后慢慢执行。这不科学,不符合负载均衡,不符合多个脚本共享消费。框架是不会出现这种情况的,如果你看concurrent_pool里面的代码就知道了,那里面的所有并发池都是本人自己重新实现的,其中很重要一点的概念就是 有界队列。百度搜索线程池有界队列,有很多java文章都介绍了,只不过python的线程池默认就是无界队列而且线程池没有暴露可以设置size的入参,才导致你被坑惨了提这个问题。

from distributed_framework.

DJMIN avatar DJMIN commented on June 15, 2024

哦、那可太好了 ,多谢大牛解答,事实确实如你所说的那样

from distributed_framework.

ydf0509 avatar ydf0509 commented on June 15, 2024

哦、那可太好了 ,多谢大牛解答,事实确实如你所说的那样

https://qm.qq.com/cgi-bin/qm/qr?k=unA_o_L3sv5yushJzYGUTAwSzZ7GhUhq&jump_from=webapi 点击链接加群 189603256

from distributed_framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.