Comments (5)
本来就是有界队列,不会迅速从redis拉取100万任务到python内存里面的,如果是这样的,那就后启动的消费者始终消费不到任务,不可能设计成这样的。这点放心,因为这使用的是有界线程/协程池,你说的那种迅速掏空reids因为使用的是官方concurrent.futures.Threadpolexecutor了才会发生这种悲剧。
高实时接口,可以设置如果多少秒后才轮到消费就丢弃任务,文档已近说明了。
from distributed_framework.
任务队列的size不需要你来手动调整,不希望暴露过多自定义参数。比如你设置并发是100,那么会有100个任务正在并发运行,同时python 本地queue队列会缓存100个任务。所以即使你短时间推送100万任务到消息中间件,也不会迅速掏空的
from distributed_framework.
本地队列的size默认是等于并发数量。从你描述的,应该是以前有使用官方 concurrent.futures.Threadpolexecutor 的经历,被那个坑惨了,那个总是迅速把redis的任务全部一股脑拿到python的queue对象里面去了,然后慢慢执行。这不科学,不符合负载均衡,不符合多个脚本共享消费。框架是不会出现这种情况的,如果你看concurrent_pool里面的代码就知道了,那里面的所有并发池都是本人自己重新实现的,其中很重要一点的概念就是 有界队列。百度搜索线程池有界队列,有很多java文章都介绍了,只不过python的线程池默认就是无界队列而且线程池没有暴露可以设置size的入参,才导致你被坑惨了提这个问题。
from distributed_framework.
哦、那可太好了 ,多谢大牛解答,事实确实如你所说的那样
from distributed_framework.
哦、那可太好了 ,多谢大牛解答,事实确实如你所说的那样
https://qm.qq.com/cgi-bin/qm/qr?k=unA_o_L3sv5yushJzYGUTAwSzZ7GhUhq&jump_from=webapi 点击链接加群 189603256
from distributed_framework.
Related Issues (20)
- 上下游任务调度 HOT 3
- 关于任务 HOT 1
- 关于log输出的兼容问题 HOT 3
- 定时任务应该如何关闭 HOT 2
- 你好请问这个框架在tornado怎么使用 HOT 1
- ModuleNotFoundError: No module named 'nb_log_config' HOT 2
- 在使用多个步骤的消费函数的时候发布的任务不执行 HOT 10
- 建议改个名字 HOT 3
- 是否有类似celery的任务编排功能 HOT 6
- 别的可能什么都好,但就名字... HOT 1
- 体验 HOT 3
- 能否加上一个获得返回值的demo,我使用redis的demo。 HOT 6
- RabbitMQ连接不上,找不到能讨论的地方只能来这里了 HOT 2
- 几点建议 HOT 5
- python3.9 设置function_timeout 引发异常 HOT 3
- PySnooper 包引用相关 HOT 3
- worker平滑关闭问题 HOT 4
- 新手入门,求个能跑起来的demo HOT 2
- 服务器部署运行函数,如果函数使用了第三方库,但是服务器的python解释器没有安装该第三方库,该如何解决? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from distributed_framework.