当前位置:网站首页>消息队列消息存储设计(架构实战营 模块八作业)
消息队列消息存储设计(架构实战营 模块八作业)
2022-07-31 22:37:00 【InfoQ】
消息表

消费信息表
consume_log 表
- 我们支持多个消费者组,每个消费者组共享一条消费进度记录,所以表中需要有 group 字段来区分是哪个消费者组的消费记录;
- 消费偏移量是最重要的,记录了消费到哪条数据,用 offset 来标识,即 message 表中的 msg_id,因为 msg_id 在一个数据分组,一个 topic 下是严格递增的;

索引分析
发送消息
- 客户端完成分片路由,分配到某个 shard,发送消息数据
- 消息队列服务器根据 topic 找到对应的消息表 message_{topic},然后插入数据,msg_id 自增
消费消息
- 客户端完成分片的路由,向对应服务器拉取消息,带上参数 topic,group
- 查询 consumer_log 表,根据 topic,group 通过索引找到对应的数据,取出 offset
- 根据 offset 查询对应的 message 表,通过主键 id,找出下个 offset 的记录,取出并准备返回
- 更新 consumer_log 的 offset 信息
- 返回数据
边栏推荐
- Interview assault 69: TCP reliable?Why is that?
- Embedded development has no passion, is it normal?
- Pytorch lstm time series prediction problem stepping on the pit "recommended collection"
- The latest masterpiece!Alibaba just released the interview reference guide (Taishan version), I just brushed it for 29 days
- "SDOI2016" Journey Problem Solution
- Realize serial port receiving data based on STM32 ring queue
- [Open class preview]: Research and application of super-resolution technology in the field of video image quality enhancement
- focus on!Haitai Fangyuan joins the "Personal Information Protection Self-discipline Convention"
- VOT2021 game introduction
- Count characters in UTF-8 string function
猜你喜欢
Quick Start Tutorial for flyway
Count characters in UTF-8 string function
Write a database document management tool based on WPF repeating the wheel (1)
flowable workflow all business concepts
Binary tree non-recursive traversal
VOT2021比赛简介
Network security - crack WiFi through handshake packets (detailed tutorial)
[Open class preview]: Research and application of super-resolution technology in the field of video image quality enhancement
Go mode tidy reports an error go warning “all” matched no packages
The difference between adding or not adding the ref keyword when a variable of reference type is used as a parameter in a method call in C#
随机推荐
Chapter VII
IJCAI2022 | 代数和逻辑约束的混合概率推理
周总结
[Code Hoof Set Novice Village 600 Questions] Leading to the combination of formulas and programs
-xms -xmx(information value)
A few permanent free network transmission, convenient and simple (Intranet through tutorials)
Payment module implementation
HTC using official firmware as bottom bag made ROM brush card bag tutorial
21. Support Vector Machine - Introduction to Kernel Functions
Structure of the actual combat battalion module eight operations
Realize serial port receiving data based on STM32 ring queue
Dry goods | 10 tips for MySQL add, delete, change query performance optimization
[NLP] What is the memory of the model!
Federated Learning: Multi-source Knowledge Graph Embedding in Federated Scenarios
基于RT1052 Aworks nanopb string 类型固定长度使用方式(二十七)
BM5 merge k sorted linked lists
Flink_CDC construction and simple use
Pytest初体验
"SDOI2016" Journey Problem Solution
Summary of the classic drawing method of histogram