惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 喜欢Ⅰ

人类随机数趣闻 - 即使人们会觉得它更随机,但实际上它更不随机 C 里面如何使用链表 list 项目代码套路 墨菲定律 - 人类一种误判心理 CORS 跨域请求一种后端适配解决方案 自我的智慧 市场教父 André Kostolany Exception Handling Considered Harmful MySQL CREATE TABLE Template 模板设计简单交流 面试题: 字符串转整型 终结者 atomic 原子自增工程案例 - 喜欢Ⅰ HTTP 尝试获取 Client IP 对炒股看法 吃饱年代 我是个怎样的人 格林童话之祖父和孙子 Linux 守护进程 智慧 ~ 引子 ~ 三则故事 交易人生
消息队列, 一种取舍的选择 Redis Stream
喜欢Ⅰ · 2025-05-20 · via 博客园 - 喜欢Ⅰ

人多公司方便多个业务方解耦, 常用一些成熟的消息队列. 会有专门部门帮你维护好.

但在小公司, 看成本靠个人. 

有的简单可能就是 redis list or mysql 存一些状态, 有问题了就自己手工去补偿, 也未尝不可.

这里带来一种新的取舍方案. redis stream 来做这类解耦业务. 原理非常简单如下图

Producer --> [XADD mystream] --> Redis Stream
                                         |
Consumer Group (mygroup)  <----> [XREADGROUP, XACK, XPENDING]
       |                      (auto-dispatch to consumer-1 / consumer-2 ...)
       V
"consumer-1" / "consumer-2" 处理数据

Stream XADD Push 消息, 然后 XReadGroup 消费, XAck 应答, XDel 删除 .

具体细节多运用大模型, 大模型很好弥补了人类大脑不善于存储短板.

当然 Redis 取舍也有自身痛点, 成熟性便利性性能都存在差距,

Stream 是 单 Key, 哪怕 Redis Cluster 也是单点 Key Hash 分散在 slot 中.

虽然可以升级, 但几万 QPS 足够普通公司去使用了. 

优势简单方便重复利用, 不用增加额外成本花钱买组件. 

注: 口语消息队列, 分带订阅消息队列, 还有简单跑任务的任务队列,

这里简单任务队列代码, 其中积木原理相通的.

sbp/helper/rediser/stream.go at master · wangzhione/sbp

sbp/helper/rediser/queue.go at master · wangzhione/sbp看使用工程师能力了, 一道菜不会因为食材简单丢分, 也许会因为猛料太多少了点原味.