当前位置:网站首页>After class assignment for module 8 of phase 6 of the construction practice camp

After class assignment for module 8 of phase 6 of the construction practice camp

2022-06-10 15:10:00 InfoQ



design analysis

  • One table for each message queue or one table for all messages ?
Consider if there is a message queue with a large number of messages , It may affect the performance of other message queues . therefore
One table per message queue
. The corresponding message queues are distinguished by table names .

  • What to use as the primary key and index of the table ?
Since it's a message queue , The messages are sequential , Consider storing messages in a self incrementing column offset, At the same time, this column is used as the primary key .
Message query , Queries for time periods may be involved , And expired messages may need to be cleaned up . So design a column to store the time of message insertion , And add an index , Improve query efficiency .

  • What information is required for the operation of messages ?
Push Insertion of message corresponding table , Messages cannot be modified after being queued , Therefore, it is not necessary to consider modifying records .
Pull Past messages can be kept in the table , Don't delete . Expired messages may need to be deleted in batches , You can query through the time column .
When something goes wrong , The source of the message and the format of the message can be useful information . To facilitate inspection in case of problems , Add one more metadata Columns store possible additional information . It can be used key、value Format store , Easy to extend other information .

Data sheet design


【 Table name 】
Corresponding message queue name

【 Field 】
Offset
, int, auto increment, unique index
Creation_Time
, date time, index
Message
, text
Metadata
, varchar
原网站

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101333461069.html