当前位置:网站首页>设计消息队列存储信息数据的MySQL表结构
设计消息队列存储信息数据的MySQL表结构
2022-06-12 23:37:00 【InfoQ】
要求
- 包括表名、字段、索引;
- 用文字描述设计思路和理由,例如:为什么设计某个索引?
- 需要考虑每个消息队列一张表,还是所有消息放一张表,里面加一个“队列名称”的字段
1.说明
1.1 消息队列使用的常用技术
- mysql (速度相对较慢,易实现,可靠)
- redis (速度快)
- 专业的消息系统 (专业,可靠,学习成本高)
1.2 常用队列的触发机制
- 写个循环一直读️
- 定时任务
- 守护进程
2.设计思路
- 每一种队列存一张表,这样比较好扩展,队列之间后续比较好做隔离,以前实际业务中,曾经存到一张表,靠队列类型,名称等字段做区分。有些队列忽然大的流量进来,导致整个消息队列全部都出问题。
- 队列写入数据表中,通过自增 id 来标识顺序,先入先出。实际业务中,也可加入队列消费优先级,高,中,低这种。在消费能力一般的情况下,优先消费优先级高的。这样不仅发挥了消息队列的作用,也更有灵活性。
- 保证高可用,采用主从的数据库架构。
- 引入错误日志表,消费状态表。用来存储,标记消费的记录。也方便队列重试。
- 和业务商量好队列完成后的消息清除时间,以保证数据表不会一直处于线性增长的状态。
3.数据表
消息队列表
错误日志表
消费状态表
边栏推荐
- Function introduction and common terms of ZABBIX
- MYSQL 行转列、列转行、多列转一行、一行转多列
- Common message oriented middleware selection
- Don't write about the full screen explosion, try the decorator mode, this is the elegant way!!
- Leetcode 890 finding and replacing patterns [map] the leetcode path of heroding
- [issue 30] shopee golang development experience
- dict和set的基本操作
- Huawei officially entered the "front loading" stage, and the millimeter wave radar track entered the "localization +4d" cycle
- Deep feature synthesis and genetic feature generation, comparison of two automatic feature generation strategies
- Theory + practice will help you master the dynamic programming method
猜你喜欢

iShot

ASP. Net core Middleware
C language: how to give an alias to a global variable?

Access static variables within class in swift

Introduction to message oriented middleware (message queue)

80 lines of code to realize simple rxjs

SAP QM qp03 displays an inspection plan with multiple specs inspection features

Actual combat | inductance element positioning -- detailed explanation of Halcon and opencv implementation (with source code)

〖Kubernetes指南④〗Pod快速入门

Theory + practice will help you master the dynamic programming method
随机推荐
2202 resume making
【建议收藏】通俗易懂图解网络知识-第一篇
2202 - production de CV
移动安全必备之CS呢【NETHUNTER】
Design a MySQL table for message queue to store message data
Sequence maximum return
细数攻防演练中十大关键防守点
AWS lambda: how to store secrets to external APIs- AWS Lambda: How to store secret to external API?
Redis realizes SMS verification code login
Sword finger offer series - 47 Maximum value of gifts
Restrictions on MySQL function creation
设计消息队列存储消息数据的 MySQL 表格
About three-tier architecture and MVC
The development trend of digital collections!
MySQL row to column, column to row, multiple columns to one row, one row to multiple columns
About three-tier architecture and MVC
Analysis report on the "fourteenth five year plan" and the latest development trend of China's medical information industry from 2022 to 2028
Deep feature synthesis and genetic feature generation, comparison of two automatic feature generation strategies
Summary of MySQL foundation view
細數攻防演練中十大關鍵防守點