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

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
NISL@THU
NISL@THU
S
Securelist
O
OpenAI News
S
Security Affairs
Cyberwarzone
Cyberwarzone
T
Threatpost
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 最新话题
C
Cisco Blogs
PCI Perspectives
PCI Perspectives
SecWiki News
SecWiki News
S
Secure Thoughts
GbyAI
GbyAI
I
Intezer
AWS News Blog
AWS News Blog
F
Fortinet All Blogs
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
Google Online Security Blog
Google Online Security Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
A
About on SuperTechFans
S
Schneier on Security
P
Proofpoint News Feed
雷峰网
雷峰网
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
小众软件
小众软件
H
Heimdal Security Blog
Microsoft Security Blog
Microsoft Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
The Exploit Database - CXSecurity.com
T
Threat Research - Cisco Blogs
V
V2EX
L
Lohrmann on Cybersecurity
Security Latest
Security Latest
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
H
Hacker News: Front Page
Cisco Talos Blog
Cisco Talos Blog
Webroot Blog
Webroot Blog
T
Tenable Blog
MyScale Blog
MyScale Blog
博客园 - 司徒正美
S
SegmentFault 最新的问题
Y
Y Combinator Blog
腾讯CDC
Hacker News: Ask HN
Hacker News: Ask HN
M
MIT News - Artificial intelligence
G
GRAHAM CLULEY

博客园 - 喜欢Ⅰ

先避免毁灭性错误,再谈聪明决策 通往天堂的三个阶梯 人类随机数趣闻 - 即使人们会觉得它更随机,但实际上它更不随机 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看使用工程师能力了, 一道菜不会因为食材简单丢分, 也许会因为猛料太多少了点原味.