WO2022111733A1 - 消息处理方法、装置及电子设备 - Google Patents

消息处理方法、装置及电子设备 Download PDF

Info

Publication number
WO2022111733A1
WO2022111733A1 PCT/CN2021/134525 CN2021134525W WO2022111733A1 WO 2022111733 A1 WO2022111733 A1 WO 2022111733A1 CN 2021134525 W CN2021134525 W CN 2021134525W WO 2022111733 A1 WO2022111733 A1 WO 2022111733A1
Authority
WO
WIPO (PCT)
Prior art keywords
database
message
target
target message
messages
Prior art date
Application number
PCT/CN2021/134525
Other languages
English (en)
French (fr)
Inventor
何俊华
黄健
黄威威
Original Assignee
百果园技术(新加坡)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 百果园技术(新加坡)有限公司 filed Critical 百果园技术(新加坡)有限公司
Publication of WO2022111733A1 publication Critical patent/WO2022111733A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/54Store-and-forward switching systems 
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/40Data acquisition and logging

Definitions

  • the present disclosure relates to the technical field of message processing, and in particular, to a message processing method, apparatus, and electronic device.
  • the timeliness is the key to the quality of the function. If each message has zero delay, for users, users can get real-time feedback faster, thereby stimulating enthusiasm for use. In addition, this real-time nature is tantamount to an instant network call, which can also allow users to make Better communication plays an important role in the establishment of the social chain; on the contrary, if the consumption delay is large, the longer the waiting time, the greater the loss of users.
  • the stability of the bell is also the basis of the bell system.
  • bells are prone to swarming. For example, a head user posts a video, which may trigger a large number of like bells and comment bells in a short period of time. The impact on a system is very huge. Therefore, the swarming needs to be handled reasonably to maintain the stability of the system.
  • the bell messages of all users can be stored in a relational database, and when users pull, they are sorted and pulled in reverse chronological order, which may be limited by the scale of the system.
  • the concurrency of messages is large, and the database is no longer applicable; even if you choose to use the remote dictionary service redis as the cache to build a message list for each user, the cost of this solution is high due to the huge amount of data. .
  • the present disclosure provides a message processing method, device and electronic device, so as to solve the problems of large data volume and poor system stability to a certain extent.
  • a message processing method includes:
  • a message processing apparatus includes:
  • a processing module used to obtain a target message and determine the priority of the target message
  • a cache module configured to cache the target message in the first database according to the priority of the target message
  • the first dumping module is configured to dump the target messages in the first database whose cache duration exceeds the first preset duration from the first database to the second database.
  • an electronic device including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
  • the processor is configured to implement the steps in the above message processing method when executing the program stored in the memory.
  • a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned message processing method is implemented.
  • a computer program product containing instructions, which, when executed on a computer, cause the computer to execute the message processing method as described above.
  • the target message is cached in the first database according to the priority of the target message, and if the target message is cached in the first database for longer than the first preset If the duration is set, the target message is transferred from the first database to the second database, which can not only be written to the cache in real time, but also can store persistent data, while maintaining efficient message processing, ensuring system stability and reducing costs.
  • FIG. 1 is a flowchart of a message processing method provided by an embodiment of the present disclosure
  • FIG. 2 is a schematic structural diagram of a message processing system provided by an embodiment of the present disclosure
  • FIG. 3 is a specific flowchart of a message processing method provided by an embodiment of the present disclosure.
  • FIG. 4 is a structural block diagram of a message processing apparatus provided by an embodiment of the present disclosure.
  • FIG. 5 is a structural block diagram of an electronic device according to an embodiment of the present disclosure.
  • FIG. 6 schematically shows a block diagram of another electronic device for performing the method according to the present disclosure.
  • Figure 7 schematically shows a memory unit for holding or carrying program code implementing the method according to the present disclosure.
  • first, second and the like in the description and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances so that the embodiments of the present application can be practiced in sequences other than those illustrated or described herein, and distinguish between “first”, “second”, etc.
  • the objects are usually of one type, and the number of objects is not limited.
  • the first object may be one or more than one.
  • “and/or” in the description and claims indicates at least one of the connected objects, and the character “/" generally indicates that the associated objects are in an "or” relationship.
  • Bell After the user in the APP performs production behavior, a message prompt is triggered to the designated group of people. For example, if user A likes user B's video X, user B will receive an in-device message notification similar to "A liked your video X"; similarly, if user C follows user D, D will receive To an in-terminal message notification that "User C has followed you", such notifications are collectively referred to as "bells". According to different production scenarios, bells will also have several different sub-categories, such as like bells, follow bells, comment on bells, etc.
  • the timeliness of the bell refers to whether the bell can give immediate feedback to the user after it is triggered.
  • embodiments of the present disclosure provide a message processing method, device, and electronic device, and for these existing phenomena, a persistent storage database is introduced, which can reduce system costs while maintaining high time efficiency and high stability of the bell.
  • an embodiment of the present disclosure provides a message processing method, and the method specifically includes:
  • Step 101 Acquire a target message, and determine the priority of the target message.
  • the bell system acquires the target message and determines the priority of the target message, and the priority of the target message can be used as a basis for judging the importance of the target message.
  • obtaining the target message in the above step 101 may specifically include:
  • the bell system includes: a production behavior service 21 , a message queue 22 , a bell consumer 23 , a first database 24 and a second database 25 .
  • the production behavior server 21 is used for producing messages to be consumed, and the messages to be consumed are written into the message queue 22; the bell consumer 23 is used for bell consumption, that is, consuming messages to be consumed; the first database 24 and the second database 25 are both user cache targets information.
  • FIG. 3 there are many behaviors that trigger messages to be consumed (ie, bells), and various behaviors in the APP will generate bells, such as: video like 311, video comment 312, user follow 313, user @ 314, etc., all these messages will be written to the message queue, and the bell system will subscribe and consume one by one.
  • a message producer ie, a user
  • the message queue can be defined as a fast message queue 32 here.
  • the message to be consumed in the fast message queue 32 is acquired, and the target message to be consumed in the message to be consumed is first consumed 33, and the number of threads can be adjusted.
  • the role of the message queue is not only to decouple the service, but also to reduce the peak current and limit the current when the message is highly concurrent, which effectively improves the stability of the system.
  • the importance of different types of bells is different, for example: the importance of commenting on bells is higher than that of liking bells; and the importance of bells to different users is also different.
  • the real-time status of the bell becomes relatively secondary, and the bell of such a user can be set as a low-priority message.
  • the priority 34 can be determined, that is, the priority of the bell can be determined, and the priority of the target message is determined after the target message to be consumed is consumed for the first time.
  • Step 102 Cache the target message in the first database according to the priority of the target message.
  • the first database as a real-time cache database, can be a redis database, which can maintain the timeliness of the bell.
  • Step 103 Transfer the target messages whose cache duration exceeds the first preset duration in the first database to the second database from the first database.
  • step 103 if the target message cache duration in the first database exceeds the first preset duration, the target message is transferred from the first database to the second database; if the target message in the first database is stored in the second database If the message cache duration is less than or equal to the first preset duration, the target message will not be dumped and is still cached in the first database.
  • the first preset duration is a time limit for determining whether the target message can be transferred to the second database as persistent data. If the time for the target message to be cached in the first database exceeds the first preset duration, the target message needs to be transferred to the second database as persistent data; if the time for the target message to be cached in the first database is less than or is equal to the first preset duration, the target message needs to continue to be cached in the first database.
  • the second database is a cache persistent data database, which can be a pickup truck, which can improve system performance and reduce costs.
  • the target message is cached in the first database according to the priority of the target message, and if the target message is cached in the first database for longer than the first With a preset duration, the target message is transferred from the first database to the second database, which can be written to the cache in real time and can also store persistent data. While maintaining efficient message processing, system stability is ensured and costs are reduced .
  • the target message is cached in the first database according to the priority of the target message, which specifically includes:
  • the target message is a high-priority message, caching the target message in the first database
  • the target message is cached in the first database after secondary consumption.
  • the target message after consumption can be directly cached in the first database 35 (ie, directly written); if it is determined that the target message is If it is a low-priority message, the target message needs to be put into the slow message queue 36 first, and then cached in the first database 35 after secondary consumption 37 (ie, delayed writing), so as to avoid the target message caused by the accumulation of fast message queues.
  • the problem of message delay caching if it is determined that the target message is a high-priority message, the target message after consumption can be directly cached in the first database 35 (ie, directly written); if it is determined that the target message is If it is a low-priority message, the target message needs to be put into the slow message queue 36 first, and then cached in the first database 35 after secondary consumption 37 (ie, delayed writing), so as to avoid the target message caused by the accumulation of fast message queues.
  • secondary consumption 37 ie, delayed writing
  • the unread number of the user's bell can be used as a factor to determine the priority of the target message. If the unread number exceeds 99, the user can be defined as a lazy user of the bell. When the bell fast message queue accumulates, the user's bell message will be used as a Delayed writing of low-priority messages can effectively deal with some sudden high concurrency situations, and can improve user experience.
  • the method may further include:
  • the first quantity of the target messages cached in the first database is obtained, the first quantity is compared with the first threshold, and if the first quantity exceeds the first threshold, the target message The deletion may be performed sequentially in the chronological order of being cached in the first database, until the first number of remaining target messages cached in the first database is less than or equal to the first threshold.
  • the target message in the first database is deleted, and then the earliest target message cached in the first database is selected from the remaining target messages in the first database for deletion, and so on, until the first number is less than or equal to the first threshold.
  • the first threshold is the threshold of the number of bells that the same user can save in the first database, and the first threshold can be set as required, which is not specifically limited here.
  • the bell system will only store the first threshold (eg: 2000) number of bells for each user. Therefore, after writing to the first database (eg: redis) in real time, it is necessary to determine whether its length exceeds the deletion threshold (ie.
  • the first threshold if it exceeds, the delete operation will be performed to ensure that the data volume of each user list will not be too large, which avoids the performance problem caused by the excessive number of caches for a single user, and also avoids the cache fragmentation. Data skew occurs, resulting in a drop in the cache hit rate.
  • deletion method is not limited to the deletion in the chronological order of the cache to the first database, and can also be set to other deletion methods as required, which is not specifically limited again.
  • the target message whose cache duration exceeds the first preset duration in the first database is transferred from the first database to the second database, which may specifically include:
  • the target messages whose cache duration exceeds the first preset duration in different clusters are respectively transferred from the first database to the second database.
  • each cluster includes at least one target message.
  • the target message is transferred to the second database as persistent data, and the persistent data is cached by the second database to improve concurrent processing capability.
  • the first preset duration is a time period for judging whether each cluster contains a target message whose cache duration exceeds the first preset duration, and the first preset duration can be specifically set as required, There is no specific limitation here.
  • the method may further include:
  • the target messages can be deleted in the order of time cached in the second database, until the second number of remaining target messages cached in the second database is less than or equal to the second threshold, change
  • the earliest target message cached in the second database can be deleted, and then the earliest target message cached in the second database can be selected from the remaining target messages in the second database for deletion, and so on until the second The number is less than or equal to the second threshold.
  • the second threshold is the threshold of the number of bells that the same user can save in the second database, and the second threshold can be set as required, which is not specifically limited here.
  • deletion method is not limited to the deletion in the chronological order of the cache to the second database, and can also be set to other deletion methods as required, which is not specifically limited again.
  • the method further includes:
  • the target message is transferred from the first database to the second database in the chronological order of being cached in the first database, until all The message processing capability of the second database is smaller than the preset message processing capability.
  • the message processing capability of the second database may be detected every third preset time interval, and if the message processing capability of the second database is less than the preset message processing capability, then each cluster is detected at every second preset time interval
  • the cached duration of the target messages in the first database, and the target messages in different clusters whose cached durations exceed the first preset duration are respectively transferred from the first database to the second database.
  • the message processing capability of the second database is greater than or equal to the preset message processing capability, it means that the second database can continue to receive the dump of persistent data, and the target message can be stored in the first database in the order of time From the first database to the second database, the transfer is stopped until the message processing capacity of the second database is less than the preset message processing capacity, which can not only improve the efficiency of message transfer, but also avoid high The amount of concurrency causes system instability.
  • the system may detect the cached duration of the target messages in each cluster in the first database at every second preset duration, and store the target messages in different clusters whose cache durations exceed the first preset duration from The first database is transferred to the second database; on this basis, it can be set to detect the message processing capability of the second database every third preset duration, if the message processing capability is greater than or equal to the preset message processing capacity, the target message is transferred from the first database to the second database in the chronological order of being cached in the first database, until the message processing capacity of the second database is less than the predetermined Set message processing capabilities.
  • the system can detect the cached duration of the target message in each cluster in the first database every second preset duration (eg, 1 hour); One test at ten o'clock, one test at eleven o'clock, and so on.
  • the message processing capability of the second database can be checked at a third preset time interval (eg 1 hour), and the check can be set to start at 9:30, then once at 9:30 and once at 10:30 , the detection is performed once at 11:30, and so on. Therefore, the detection message processing capability can be inserted within the time interval of the detection cache duration, which can improve the dumping efficiency.
  • the third preset duration is a time period for judging whether the second database currently has the capability of receiving the dump message, and the time period can be set as required.
  • the preset message processing capability is to determine whether the second database reaches the capability limit of the message processing capability. If the capability limit is exceeded, the second database is not suitable for continuing to receive dumped messages at this time.
  • the first database storage of the system can mainly use the following data structures:
  • the ordered queue Redis Sorted Set of the remote dictionary service It can store the user's short-term bell list, that is, cache the target message in real time.
  • Each user can be set to have a single first keyword key every day, the first member member is the specific content of the bell (that is, the specific content of the target message), and the score is the trigger timestamp.
  • the key contains time information (that is, the time when the target message is written to the fast message queue before consumption, or the time when the target message is cached to the Redis Sorted Set).
  • Redis Set a collection of remote dictionary services: Stores user state data to be persisted.
  • the second keyword key is the hash value obtained according to the user classification, which is used to divide the task into buckets (that is, classify the target message to form multiple clusters), which can improve the concurrent processing capability; the second member member is related to the user and time.
  • the current time can be accurate to the hour level, which means that in the Redis Set structure, each user has at most one member per hour.
  • the asynchronous persistence period of the redis cache is also set to one hour.
  • the second database storage of the system may primarily use the following data structures:
  • Pika Hash Map Stores the number of unread users' bells, the last time the bell was pulled, and other information. Each user has a separate third keyword key, and the third member member is each dimension (unread number, time, etc.).
  • the system will use distributed locks, start multiple threads to grab the main thread, and be responsible for traversing the messages to be consumed. After traversing, the messages to be consumed will be written to the message queue. After consuming the target messages to be consumed, they will be stored in the first message queue.
  • the bell data to be persisted can be extracted from the bell list of the first database according to the data structure in the first database (such as redis), and written into the second database, which can not only control the speed, but also protect the system. Stability, in addition to using message queues to ensure the reliability of persistent data. After the writing to the second database is completed, the list length of the second database needs to be checked, and if the deletion threshold (ie, the second threshold) is exceeded, deletion processing is required.
  • the user terminal may send request information for pulling the bell, and after receiving the request information, the bell system pulls the bell list from the first database or the second database as required.
  • the second database stores the complete historical bell list of the user one hour ago
  • the bell list in the first database stores the complete data of the current day. So when the user pulls the bell list, if the data is within an hour, we can directly pull the data from the first database list. If it is an hour ago, we can pull the data through the second database. Due to the high timeliness of the bell, users rarely pull the bell information an hour ago, so the data in the first database is used to a greater extent, which further improves the performance of the system and provides users with a better experience.
  • the above-mentioned embodiments of the present disclosure effectively combine the two storages of the first database and the second database, write to the cache in real time, persist data asynchronously, and delete useless bells. It not only maintains the timeliness and stability of the bell, but also minimizes the storage cost. Even in the case of high concurrency or network abnormalities, the system can recover quickly and minimize user losses.
  • a message processing apparatus 400 provided by an embodiment of the present disclosure includes:
  • a processing module 401 configured to obtain a target message and determine the priority of the target message
  • the first dump module 403 is configured to dump the target messages in the first database whose cache duration exceeds the first preset duration from the first database to the second database.
  • the target message is cached in the first database according to the priority of the target message, and if the target message is cached in the first database for longer than the first database With a preset duration, the target message is transferred from the first database to the second database, which can be written to the cache in real time and stored in persistent data. While maintaining efficient message processing, system stability is guaranteed and costs are reduced. .
  • the cache module 402 includes:
  • the target message is a high-priority message, caching the target message in the first database
  • the target message is cached in the first database after secondary consumption.
  • the apparatus further includes:
  • a first acquisition module for acquiring the first quantity of the target message buffered into the first database
  • a first deletion module configured to delete the target message in the chronological order of being cached in the first database until the target message is cached in the first database if the first number exceeds a first threshold The first number of messages is less than or equal to the first threshold.
  • the cache module 402 includes:
  • a classification unit configured to classify the target messages in the first database to form multiple clusters
  • a detection unit configured to detect the cached duration of the target message in each cluster in the first database at every second preset duration
  • the dumping unit is configured to dump the target messages whose cache duration exceeds the first preset duration in different clusters from the first database to the second database respectively.
  • the device further includes:
  • a second obtaining module configured to obtain the second quantity of the target messages cached in the second database
  • a second deletion module configured to delete the target message in the chronological order of being cached in the second database until the target message is cached in the second database if the second number exceeds a second threshold The second number of messages is less than or equal to the second threshold.
  • the apparatus further includes:
  • a detection module configured to detect the message processing capability of the second database every third preset duration
  • a second dumping module configured to dump the target message from the first database in the chronological order of being cached in the first database if the message processing capability is greater than or equal to the preset message processing capability into the second database until the message processing capacity of the second database is smaller than the preset message processing capacity.
  • the processing module 401 includes:
  • a first obtaining unit configured to obtain a message to be consumed in a message queue, where the message to be consumed is a message written into the message queue by a message producer;
  • the second acquiring unit is configured to consume the target message to be consumed in the messages to be consumed, and acquire the target message after consumption.
  • the above-mentioned embodiments of the present disclosure effectively combine the two storages of the first database and the second database, write to the cache in real time, persist data asynchronously, and delete useless bells. It not only maintains the timeliness and stability of the bell, but also minimizes the storage cost. Even in the case of high concurrency or network abnormalities, the system can recover quickly and minimize user losses.
  • this message processing apparatus embodiment is an apparatus corresponding to the above message processing method, and all implementations of the above method embodiments are applicable to this apparatus embodiment, and can also achieve the same technical effect. No longer.
  • Embodiments of the present disclosure also provide an electronic device. As shown in FIG. 5 , it includes a processor 501 , a communication interface 502 , a memory 503 and a communication bus 504 , wherein the processor 501 , the communication interface 502 , and the memory 503 communicate with each other through the communication bus 504 .
  • the memory 503 is used to store computer programs.
  • processor 501 When the processor 501 is configured to execute the program stored in the memory 503, some or all of the steps in the message processing method provided by the embodiment of the present disclosure are implemented.
  • the communication bus mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI for short) bus or an Extended Industry Standard Architecture (EISA for short) bus or the like.
  • PCI Peripheral Component Interconnect
  • EISA Extended Industry Standard Architecture
  • the communication bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
  • the communication interface is used for communication between the above-mentioned terminal and other devices.
  • the memory may include random access memory (Random Access Memory, RAM for short), or may include non-volatile memory (non-volatile memory), such as at least one disk memory.
  • RAM Random Access Memory
  • non-volatile memory such as at least one disk memory.
  • the memory may also be at least one storage device located away from the aforementioned processor.
  • the above-mentioned processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, referred to as CPU), a network processor (Network Processor, referred to as NP), etc.; may also be a digital signal processor (Digital Signal Processing, referred to as DSP) , Application Specific Integrated Circuit (ASIC), Field Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
  • CPU Central Processing Unit
  • NP Network Processor
  • DSP Digital Signal Processing
  • ASIC Application Specific Integrated Circuit
  • FPGA Field Programmable Gate Array
  • a computer-readable storage medium is also provided, where instructions are stored in the computer-readable storage medium, when the computer-readable storage medium is run on a computer, the computer is made to execute the above-mentioned embodiments. message processing method.
  • the device embodiments described above are only illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in One place, or it can be distributed over multiple network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment. Those of ordinary skill in the art can understand and implement it without creative effort.
  • Various component embodiments of the present disclosure may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof.
  • a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in the electronic device according to the embodiments of the present disclosure.
  • DSP digital signal processor
  • the present disclosure can also be implemented as apparatus or apparatus programs (eg, computer programs and computer program products) for performing some or all of the methods described herein.
  • Such a program implementing the present disclosure may be stored on a computer-readable medium, or may be in the form of one or more signals. Such signals may be downloaded from Internet sites, or provided on carrier signals, or in any other form.
  • Figure 6 illustrates another electronic device that may implement methods in accordance with the present disclosure.
  • the electronic device traditionally includes a processor 1010 and a computer program product or computer readable medium in the form of a memory 1020 .
  • the memory 1020 may be electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
  • the memory 1020 has storage space 1030 for program code 1031 for performing any of the method steps in the above-described methods.
  • the storage space 1030 for program codes may include various program codes 1031 for implementing various steps in the above methods, respectively.
  • the program codes can be read from or written to one or more computer program products.
  • These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. Such computer program products are typically portable or fixed storage units as described with reference to FIG. 7 .
  • the storage unit may have storage segments, storage spaces, etc. arranged similarly to the memory 1020 in the electronic device of FIG. 6 .
  • the program code may, for example, be compressed in a suitable form.
  • the storage unit includes computer readable code 1031', ie code readable by a processor such as 1010, for example, which, when executed by an electronic device, causes the electronic device to perform each of the methods described above. step.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本公开实施例提供了一种消息处理方法、装置及电子设备,涉及消息处理技术领域。该方法包括:获取目标消息,并确定所述目标消息的优先级;根据所述目标消息的优先级,将所述目标消息缓存至第一数据库中;将所述第一数据库中缓存时长超过第一预设时长的目标消息,从所述第一数据库转存至第二数据库中。上述方案,既可以实时写入缓存,还可以存储持久化数据,在保持高效处理消息的同时,保证系统稳定性并降低成本。

Description

消息处理方法、装置及电子设备
相关申请的交叉引用
本公开要求在2020年11月30日提交中国专利局、申请号为202011377144.0、名称为“消息处理方法、装置及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。
技术领域
本公开涉及消息处理技术领域,尤其涉及一种消息处理方法、装置及电子设备。
背景技术
铃铛作为即时的交互方式,时效性是该功能好坏的关键。如果每个消息都是零延迟的,对于用户来说,用户可以更快地得到实时的反馈,从而激发使用热情,另外,这种实时性无异于是一个即时的网络通话,也可以让用户进行更好地交流,对于社交链的建立有着重要的作用;而反之,如果消费的延迟很大,等待时间越长,用户的流失将会越大。
除了时效性外,铃铛的稳定性也是铃铛系统的基础。在社交应用程序(Application,APP)里面,铃铛容易出现蜂拥现象,譬如一个头部用户发布了一个视频,在短时间内可能会触发大量的点赞铃铛和评论铃铛,这对于一个系统的冲击是非常大的。因此,需要合理的处理蜂拥,保持系统的稳定性。
在已有的技术中,在数据的存储上,可以把所有用户的铃铛消息存储到关系型数据库,在用户拉取的时候按时间倒序排序分页拉取,可能会限制于系统规模,当用户数增多的时候,消息的并发量很大,数据库不再适用;即使选择使用远程字典服务redis作为缓存,为每一个用户构建一个消息列表,但由于数据量的庞大,此方案所耗费的成本较高。
概述
本公开提供一种消息处理方法、装置及电子设备,以便在一定程度上解决数据量较大以及系统稳定性较差的问题。
在本公开实施的第一方面,提供了一种消息处理方法,所述方法包括:
获取目标消息,并确定所述目标消息的优先级;
根据所述目标消息的优先级,将所述目标消息缓存至第一数据库中;
将所述第一数据库中缓存时长超过第一预设时长的目标消息,从所述第一数据库转存至第二数据库中。
在本公开实施的第二方面,提供了一种消息处理装置,所述装置包括:
处理模块,用于获取目标消息,并确定所述目标消息的优先级;
缓存模块,用于根据所述目标消息的优先级,将所述目标消息缓存至第一数据库中;
第一转存模块,用于将所述第一数据库中缓存时长超过第一预设时长的目标消息,从所述第一数据库转存至第二数据库中。
在本公开实施的第三方面,还提供了一种电子设备,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;
存储器,用于存放计算机程序;
处理器,用于执行存储器上所存放的程序时,实现如上所述的消息处理方法中的步骤。
在本公开实施的第四方面,还提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现如上所述的消息处理方法。
在本公开实施例的第五方面,还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行如上所述的消息处理方法。
针对在先技术,本公开具备如下优点:
本公开实施例中,通过获取目标消息,并确定目标消息的优先级,根据目标消息的优先级将目标消息缓存至第一数据库中,并且若目标消息在第一数据库中缓存时长超过第一预设时长,则将该目标消息从第一数据库转存至第二数据库中,既可以实时写入缓存,还可以存储持久化数据,在保持高效处理消息的同时,保证系统稳定性并降低成本。
上述说明仅是本公开技术方案的概述,为了能够更清楚了解本公开的技术手段,而可依照说明书的内容予以实施,并且为了让本公开的上述和其它目的、特征和优点能够更明显易懂,以下特举本公开的具体实施方式。
附图简述
为了更清楚地说明本公开实施例或现有技术中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍。
图1为本公开实施例提供的消息处理方法流程图;
图2为本公开实施例提供的消息处理系统的结构示意图;
图3为本公开实施例提供的消息处理方法具体流程图;
图4为本公开实施例提供的消息处理装置的结构框图;
图5为本公开实施例提供的一种电子设备的结构框图;
图6示意性地示出了用于执行根据本公开的方法的另一种电子设备的框图;并且
图7示意性地示出了用于保持或者携带实现根据本公开的方法的程序代码的存储单元。
详细描述
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请的说明书和权利要求书中的术语“第一”、“第二”等是用于区别类似的对象,而不用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施,且“第一”、“第二”等所区分的对象通常为一类,并不限定对象的个数,例如第一对象可以是一个,也可以是多个。此外,说明书以及权利要求中“和/或”表示所连接对象的至少其中之一,字符“/”,一般表示前后关联对象是一种“或”的关系。
在进行本公开实施例的说明时,首先对下面描述中所用到的一些概念进行解释说明。
铃铛:APP端内用户进行生产行为后,向指定人群触发的一种消息提示。譬如,用户A点赞了用户B的视频X,用户B就会收到一个类似“A对你的 视频X点了赞”的端内消息通知;同样,用户C关注了用户D,D会收到一个“用户C关注了你”的端内消息通知,诸如此类通知,统一称为“铃铛”。铃铛根据不同的生产场景,也会存在多个不同的子分类,譬如点赞铃铛、关注铃铛、评论铃铛等。
铃铛的时效性:指铃铛在触发之后是否能够即时反馈给用户。
在社交类的APP里面,为了提高用户的留存,建立紧密的社交链,如何去更好地完善用户的交互方式,提高用户的交互体验成为了APP的重中之重。“铃铛”,就是其中最重要的方式之一。
在一个日活千万的APP里,系统每天产生的铃铛个数会达到千万级,无法单纯使用数据库。如果系统直接使用redis缓存作为全存储,虽然可以有效地解决性能的问题,但是铃铛是一个时效性很高的消息,其重要性随着时间的推迟会逐渐减小,redis过多的旧消息导致成本较高。因此,本公开实施例提供了一种消息处理方法、装置及电子设备,针对存在的这些现象,引入了持久化存储的数据库,在保持铃铛高时效、高稳定的同时,可以降低系统成本。
具体的,如图1所示,本公开实施例提供了一种消息处理方法,所述方法具体包括:
步骤101,获取目标消息,并确定所述目标消息的优先级。
具体的,铃铛系统获取目标消息,并且确定目标消息的优先级,目标消息的优先级可以作为判断目标消息重要性的依据。
可选的,所述上述步骤101中获取目标消息,具体可以包括:
获取消息队列中的待消费消息,所述待消费消息是消息生产者写入所述消息队列的消息;
对所述待消费消息中的目标待消费消息进行消费,获取消费之后的目标消息。
具体的,如图2所示,铃铛系统包括:生产行为服务21、消息队列22、铃铛消费者23、第一数据库24以及第二数据库25。生产行为服务器21用于生产待消费消息,待消费消息写入消息队列22中;铃铛消费者23用于进行铃铛消费,即消费待消费消息;第一数据库24和第二数据库25均用户缓存目标消息。
具体的,如图3所示,触发待消费消息(即铃铛)的行为有很多,APP端内的各种行为都会产生铃铛,例如:视频点赞311、视频评论312、用户关注313、用户@314等,所有的这些消息都会写入消息队列,铃铛系统会逐一订阅消费。以视频点赞为例,消息生产者(即用户)给视频点赞后,会写入消息队列,在此可以定义此消息队列为快消息队列32。获取快消息队列32中的待消费消息,并对该待消费消息中的目标待消费消息进行第一次消费33,线程数可以调整。其中,消息队列的作用既是解耦服务,同时在消息高并发的时候,可以起到削峰限流的作用,有效提高了系统的稳定性。
并且,如图3所示,由于不同类型的铃铛的重要性是有差异的,例如:评论铃铛的重要性比点赞铃铛的重要性高;并且,铃铛对于不同的用户其重要性也是不一样的,对于一个经常不看铃铛的用户,或者说不在线的用户,铃铛的实时与否相对来说就变得次要了,此类用户的铃铛就可以设定为优先级低的消息。为了防止快消息队列堆积,可以判断优先级34,即判断铃铛的优先级,在第一次消费目标待消费消息得到目标消息后,确定该目标消息的优先级。
步骤102,根据所述目标消息的优先级,将所述目标消息缓存至第一数据库中。
具体的,在上述步骤102中,目标消息的优先级不同,则将所述目标消息缓存至第一数据库中所采用的方式不同。其中,第一数据库作为实时缓存数据库,可以为redis数据库,可以保持铃铛的时效性。
步骤103,将所述第一数据库中缓存时长超过第一预设时长的目标消息,从所述第一数据库转存至第二数据库中。
具体的,在上述步骤103中,如果第一数据库中的目标消息缓存时长超过第一预设时长,则将该目标消息从第一数据库转存至第二数据库中;如果第一数据库中的目标消息缓存时长小于或等于第一预设时长,则该目标消息不进行转存,依旧在第一数据库中缓存。
需要说明的是,第一预设时长为判断目标消息是否可以转存至第二数据库中作为持久化数据的时间限值。如果目标消息缓存至所述第一数据库的时间超过第一预设时长,则该目标消息需要转存至第二数据库中作为持久化数据;如果目标消息缓存至所述第一数据库的时间小于或等于第一预设时长, 则该目标消息需要继续在第一数据库中缓存。其中,第二数据库为缓存持久化数据数据库,可以为皮卡pika,能够提高系统性能,降低成本。
本公开上述实施例中,通过获取目标消息,并确定目标消息的优先级,根据目标消息的优先级将目标消息缓存至第一数据库中,并且若目标消息在第一数据库中缓存时长超过第一预设时长,则将该目标消息从第一数据库转存至第二数据库中,既可以实时写入缓存,还可以存储持久化数据,在保持高效处理消息的同时,保证系统稳定性并降低成本。
可选的,所述步骤102中根据所述目标消息的优先级,将所述目标消息缓存至第一数据库中,具体包括:
若所述目标消息为高优先级消息,则将所述目标消息缓存至所述第一数据库中;
若所述目标消息为低优先级消息,则将所述目标消息经过二次消费缓存至所述第一数据库中。
具体的,如图3所示,如果确定所述目标消息为高优先级消息,则可以直接将消费之后的目标消息缓存至第一数据库35中(即直接写入);如果确定所述目标消息为低优先级消息,则需要先将该目标消息放入慢消息队列36,然后进行二次消费37后缓存至第一数据库35中(即延后写入),避免快消息队列堆积时导致目标消息延迟缓存的问题。
需要说明的是,优先级的确定方式可以根据具体的功能定义,在此不做具体限定。
例如:用户铃铛的未读数可以作为确定目标消息优先级的因素,如果未读数超过了99,可以定义该用户为铃铛的懒惰用户,在铃铛快消息队列堆积的时候,该用户的铃铛消息会作为低优先级消息延迟写入,有效地应对了一些突发的高并发情况,而且能够提高用户体验。
可选的,所述步骤102中将所述目标消息缓存至第一数据库中之后,所述方法还可以包括:
获取缓存至所述第一数据库中的目标消息的第一数量;
若所述第一数量超过第一阈值,则将所述目标消息按照缓存至所述第一数据库中的时间顺序进行删除,直至缓存至所述第一数据库中的目标消息的第一数量小于或等于所述第一阈值。
具体的,获取缓存至第一数据库中的目标消息的第一数量,将所述第一数量与所述第一阈值进行比较,如果所述第一数量超过第一阈值,则将所述目标消息可以按照缓存至所述第一数据库中的时间顺序依次进行删除,直至剩余缓存至所述第一数据库中的目标消息的第一数量小于或等于第一阈值,换句话说,可以将最早缓存至第一数据库中的目标消息进行删除,然后在第一数据库中剩余的目标消息中再选择最早缓存至第一数据库中的目标消息进行删除,依次类推,直至第一数量小于或等于第一阈值。其中,所述第一阈值是同一用户在第一数据库中可以保存的铃铛数量阈值,第一阈值可以根据需要进行设定,在此不做具体限定。
例如:当触发一个铃铛,将该铃铛缓存至第一数据库中之后,需要对当前用户的铃铛列表长度进行评估。由于铃铛的分布有一个比较大的特点,越头部(重要性较高)的用户,其铃铛的数量会越大,而且是占据了铃铛总量的绝大部分,尾部铃铛的重要性较低,铃铛系统只会为每个用户存储第一阈值(如:2000个)数量的铃铛,因此,在实时写入第一数据库(如:redis)之后,需要判断其长度是否超过了删除阈值(即第一阈值),如果超过,会执行删除操作,保证每个用户列表的数据量不会过大,一来避免了单个用户缓存数量过大导致的性能问题,另外也可以避免在缓存分片中出现数据倾斜,导致缓存命中率下降的问题。
需要说明的是,删除的方式并不仅限定于按照缓存至所述第一数据库中的时间顺序删除,也可以根据需要设定为其他删除方式,再次不做具体限定。
可选的,所述步骤103中将所述第一数据库中缓存时长超过第一预设时长的目标消息,从所述第一数据库转存至第二数据库中,具体可以包括:
将所述第一数据库中的目标消息进行分类,形成多个集群;
每间隔第二预设时长,检测每一集群中的目标消息在所述第一数据库中的缓存时长;
将不同集群中缓存时长超过第一预设时长的目标消息,分别从所述第一数据库转存至所述第二数据库中。
具体的,将所述第一数据库中缓存的目标消息进行分类,可以形成多个集群,每一集群中包含至少一个目标消息。每间隔第二预设时长,判断每一集群中是否有缓存时长超过第一预设时长的目标消息,如果有,则按照不同 集群,分别将每一个集群中缓存时长超过第一预设时长的目标消息作为持久化数据转存至第二数据库中,通过第二数据库缓存该持久化数据,提高并发处理能力。
需要说明的是,所述第一预设时长为判断每一集群中是否含有缓存时长超过第一预设时长的目标消息的时间周期,所述第一预设时长可以根据需要进行具体设定,在此不做具体限定。
可选的,所述步骤103将所述第一数据库中缓存时长超过第一预设时长的目标消息,从所述第一数据库转存至第二数据库中之后,所述方法还可以包括:
获取缓存至所述第二数据库中的目标消息的第二数量;
若所述第二数量超过第二阈值,则将所述目标消息按照缓存至所述第二数据库中的时间顺序进行删除,直至缓存至所述第二数据库中的目标消息的第二数量小于或等于所述第二阈值。
具体的,获取缓存至所述第二数据库中的目标消息(即持久化数据)的第二数量,将所述第二数量与所述第二阈值进行比较,如果所述第二数量超过第二阈值,则将所述目标消息可以按照缓存至所述第二数据库中的时间顺序依次进行删除,直至剩余缓存至所述第二数据库中的目标消息的第二数量小于或等于第二阈值,换句话说,可以将最早缓存至第二数据库中的目标消息进行删除,然后在第二数据库中剩余的目标消息中再选择最早缓存至第二数据库中的目标消息进行删除,依次类推,直至第二数量小于或等于第二阈值。其中,所述第二阈值是同一用户在第二数据库中可以保存的铃铛数量阈值,第二阈值可以根据需要进行设定,在此不做具体限定。
需要说明的是,删除的方式并不仅限定于按照缓存至所述第二数据库中的时间顺序删除,也可以根据需要设定为其他删除方式,再次不做具体限定。
可选的,所述步骤102根据所述目标消息的优先级,将所述目标消息缓存至第一数据库中之后,所述方法还包括:
每间隔第三预设时长,检测第二数据库的消息处理能力;
若所述消息处理能力大于或等于预设消息处理能力,则将所述目标消息按照缓存至所述第一数据库中的时间顺序,从所述第一数据库转存至第二数据库中,直至所述第二数据库的消息处理能力小于所述预设消息处理能力。
具体的,可以每间隔第三预设时长检测一次第二数据库的消息处理能力,如果第二数据库的消息处理能力小于预设消息处理能力,则按照每间隔第二预设时长,检测每一集群中的目标消息在所述第一数据库中的缓存时长,并将不同集群中缓存时长超过第一预设时长的目标消息,分别从所述第一数据库转存至所述第二数据库中。如果第二数据库的消息处理能力大于或等于预设消息处理能力,则表示第二数据库可以继续接收持久化数据的转存,则可以按照缓存至所述第一数据库中的时间顺序,将目标消息从所述第一数据库转存至第二数据库中,直至所述第二数据库的消息处理能力小于所述预设消息处理能力停止转存,由此不仅可以提高消息转存效率,还可以避免高并发量导致系统不稳定。
其中,系统可以每间隔第二预设时长,检测每一集群中的目标消息在所述第一数据库中的缓存时长,并将不同集群中缓存时长超过第一预设时长的目标消息,分别从所述第一数据库转存至所述第二数据库中;在此基础上,可以设置每间隔第三预设时长检测第二数据库的消息处理能力,若所述消息处理能力大于或等于预设消息处理能力,则将所述目标消息按照缓存至所述第一数据库中的时间顺序,从所述第一数据库转存至第二数据库中,直至所述第二数据库的消息处理能力小于所述预设消息处理能力。
例如:系统可以每间隔第二预设时长(如:1小时),检测每一集群中的目标消息在所述第一数据库中的缓存时长;若从九点开始检测,则九点检测一次,十点检测一次,十一点检测一次,以此类推。在此基础上,可以设置每间隔第三预设时长(如:1小时)检测第二数据库的消息处理能力,可以设置从九点半开始检测,则九点半检测一次,十点半检测一次,十一点半检测一次,以此类推,由此,可以在检测缓存时长的时间段间隔之内插入检测消息处理能力,可以提高转存效率。
需要说明的是,所述第三预设时长是判断第二数据库当前是否具有可以接收转存消息的能力的时间周期,此时间周期可以根据需要进行设定。所述预设消息处理能力是判定第二数据库是否达到消息处理能力的能力限值,如果超过该能力限值,则第二数据库此时不适合再继续接收转存消息。
具体的,系统的第一数据库存储可以主要使用以下一些数据结构:
远程字典服务的有序队列Redis Sorted Set:可以存储用户的短期铃铛列 表,即实时缓存目标消息。可以设定每一个用户每天单独一个第一关键字key,第一成员member是铃铛的具体内容(即目标消息的具体内容),分数score是触发时间戳。此处可以定义key包含时间信息(即目标消息在消费之前写入快消息队列的时间,或者目标消息缓存至Redis Sorted Set的时间),在一个用户持续活跃时可以根据时间信息删除部分消息,避免一个用户持续活跃时,redis存储了过多的消息;另外,现有技术在member的构造上,把铃铛的具体内容映射成一个有特定含义的字符串,而本公开实施例不需要映射关系,可以节省存储空间,也减少了读取时的缓存访问次数,方便拉取时拼装消息。
远程字典服务的集合Redis Set:存储待持久化的用户状态数据。第二关键字key是根据用户分类得到的哈希值hash,用于把任务分桶(即将目标消息进行分类形成多个集群),可以提高并发处理能力;第二成员member是跟用户、时间相关的值,目前时间可以精确度取到小时级别,意味着在该Redis Set结构里面,每个用户每个小时至多存在一个member,同样的,redis缓存异步持久化的周期也定为一个小时。
系统的第二数据库存储可以主要使用以下数据结构:
皮卡的哈希表Pika Hash Map:存储用户铃铛的未读数量,上一次拉取铃铛的时间等信息,每一个用户单独一个第三关键字key,第三成员member是各个维度(未读数量、时间等)的信息。
例如:该系统会使用分布式锁,起多个线程去抢主线程,负责遍历待消费消息,遍历出来后把待消费消息写到消息队列,对目标待消费消息进行消费之后,存入第一数据库中,可以根据第一数据库(如:redis)中的数据结构,从第一数据库铃铛列表中提取待持久化的铃铛数据,并写入第二数据库,不仅可以控速,还可以保护系统的稳定性,另外用消息队列来保证持久化数据的可靠性。写入第二数据库完成后,需要检查第二数据库的列表长度,如果超出删除阈值(即第二阈值),需要做删除处理。
需要说明的是,上述Redis Sorted Set、Redis Set以及Pika Hash Map中具体内容的设定仅为示例,并不由此进行限定。
可选的,用户终端可以发送拉取铃铛的请求信息,铃铛系统接收到请求信息之后,根据需要从第一数据库或者第二数据库中拉取铃铛列表。
例如:该铃铛系统中,第二数据库存储了用户一个小时前的历史完整铃铛列表,而第一数据库的铃铛列表则存储了当天的完整数据。所以在用户拉取铃铛列表时,如果是一个小时内的数据,我们直接去第一数据库列表拉取数据即可,如果是一个小时之前,则通过第二数据库去拉取数据。基于铃铛的高时效性,用户很少会拉取一个小时之前的铃铛信息,因此更大程度的利用了第一数据库的数据,进一步提高了系统的性能,为用户提供更好的体验。
综上所述,在存储资源有限的情况下,本公开上述实施例有效地结合了第一数据库和第二数据库两种存储,实时写入缓存,异步持久化数据,对无用铃铛做删除处理,既保持了铃铛的时效性和稳定性,又最大限度的减少了存储成本,即使在高并发量或者网络异常的情况下,系统也能够迅速的恢复,并让用户的损失降低到最低。
如图4所示,本公开实施例提供的一种消息处理装置400,所述装置包括:
处理模块401,用于获取目标消息,并确定所述目标消息的优先级;
缓存模块402,用于根据所述目标消息的优先级,将所述目标消息缓存至第一数据库中;
第一转存模块403,用于将所述第一数据库中缓存时长超过第一预设时长的目标消息,从所述第一数据库转存至第二数据库中。
本公开上述实施例中,通过获取目标消息,并确定目标消息的优先级,根据目标消息的优先级将目标消息缓存至第一数据库中,并且若目标消息在第一数据库中缓存时长超过第一预设时长,则将该目标消息从第一数据库转存至第二数据库中,既可以实时写入缓存,还可以存储持久化数据,在保持高效处理消息的同时,保证系统稳定性并降低成本。
可选的,所述缓存模块402,包括:
若所述目标消息为高优先级消息,则将所述目标消息缓存至所述第一数据库中;
若所述目标消息为低优先级消息,则将所述目标消息经过二次消费缓存至所述第一数据库中。
可选的,所述将所述目标消息缓存至第一数据库中之后,所述装置还包括:
第一获取模块,用于获取缓存至所述第一数据库中的目标消息的第一数 量;
第一删除模块,用于若所述第一数量超过第一阈值,则将所述目标消息按照缓存至所述第一数据库中的时间顺序进行删除,直至缓存至所述第一数据库中的目标消息的第一数量小于或等于所述第一阈值。
可选的,所述缓存模块402,包括:
分类单元,用于将所述第一数据库中的目标消息进行分类,形成多个集群;
检测单元,用于每间隔第二预设时长,检测每一集群中的目标消息在所述第一数据库中的缓存时长;
转存单元,用于将不同集群中缓存时长超过第一预设时长的目标消息,分别从所述第一数据库转存至所述第二数据库中。
可选的,所述将所述第一数据库中缓存时长超过第一预设时长的目标消息,从所述第一数据库转存至第二数据库中之后,所述装置还包括:
第二获取模块,用于获取缓存至所述第二数据库中的目标消息的第二数量;
第二删除模块,用于若所述第二数量超过第二阈值,则将所述目标消息按照缓存至所述第二数据库中的时间顺序进行删除,直至缓存至所述第二数据库中的目标消息的第二数量小于或等于所述第二阈值。
可选的,所述根据所述目标消息的优先级,将所述目标消息缓存至第一数据库中之后,所述装置还包括:
检测模块,用于每间隔第三预设时长,检测第二数据库的消息处理能力;
第二转存模块,用于若所述消息处理能力大于或等于预设消息处理能力,则将所述目标消息按照缓存至所述第一数据库中的时间顺序,从所述第一数据库转存至第二数据库中,直至所述第二数据库的消息处理能力小于所述预设消息处理能力。
可选的,所述处理模块401,包括:
第一获取单元,用于获取消息队列中的待消费消息,所述待消费消息是消息生产者写入所述消息队列的消息;
第二获取单元,用于对所述待消费消息中的目标待消费消息进行消费,获取消费之后的目标消息。
综上所述,在存储资源有限的情况下,本公开上述实施例有效地结合了第一数据库和第二数据库两种存储,实时写入缓存,异步持久化数据,对无用铃铛做删除处理,既保持了铃铛的时效性和稳定性,又最大限度的减少了存储成本,即使在高并发量或者网络异常的情况下,系统也能够迅速的恢复,并让用户的损失降低到最低。
需要说明的是,该消息处理装置实施例是与上述消息处理方法相对应的装置,上述方法实施例的所有实现方式均适用于该装置实施例中,也能达到与其相同的技术效果,在此不再赘述。
本公开实施例还提供了一种电子设备。如图5所示,包括处理器501、通信接口502、存储器503和通信总线504,其中,处理器501,通信接口502,存储器503通过通信总线504完成相互间的通信。
存储器503,用于存放计算机程序。
处理器501用于执行存储器503上所存放的程序时,实现本公开实施例提供的一种消息处理方法中的部分或者全部步骤。
上述电子设备提到的通信总线可以是外设部件互连标准(Peripheral Component Interconnect,简称PCI)总线或扩展工业标准结构(Extended Industry Standard Architecture,简称EISA)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
通信接口用于上述终端与其他设备之间的通信。
存储器可以包括随机存取存储器(Random Access Memory,简称RAM),也可以包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。可选的,存储器还可以是至少一个位于远离前述处理器的存储装置。
上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,简称CPU)、网络处理器(Network Processor,简称NP)等;还可以是数字信号处理器(Digital Signal Processing,简称DSP)、专用集成电路(Application Specific Integrated Circuit,简称ASIC)、现场可编程门阵列(Field-Programmable Gate Array,简称FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。
在本公开提供的又一实施例中,还提供了一种计算机可读存储介质,该 计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述实施例中所述的消息处理方法。
在本公开提供的又一实施例中,还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述实施例中所述的消息处理方法。
以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。
本公开的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本公开实施例的电子设备中的一些或者全部部件的一些或者全部功能。本公开还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本公开的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。
例如,图6示出了可以实现根据本公开的方法的另一种电子设备。该电子设备传统上包括处理器1010和以存储器1020形式的计算机程序产品或者计算机可读介质。存储器1020可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器1020具有用于执行上述方法中的任何方法步骤的程序代码1031的存储空间1030。例如,用于程序代码的存储空间1030可以包括分别用于实现上面的方法中的各种步骤的各个程序代码1031。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,紧致盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为如参考图7所述的便携式或者固定存储单元。 该存储单元可以具有与图6的电子设备中的存储器1020类似布置的存储段、存储空间等。程序代码可以例如以适当形式进行压缩。通常,存储单元包括计算机可读代码1031’,即可以由例如诸如1010之类的处理器读取的代码,这些代码当由电子设备运行时,导致该电子设备执行上面所描述的方法中的各个步骤。
本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
以上所述仅为本公开的较佳实施例而已,并非用于限定本公开的保护范围。凡在本公开的精神和原则之内所作的任何修改、等同替换、改进等,包含在本公开的保护范围内。

Claims (11)

  1. 一种消息处理方法,其特征在于,所述方法包括:
    获取目标消息,并确定所述目标消息的优先级;
    根据所述目标消息的优先级,将所述目标消息缓存至第一数据库中;
    将所述第一数据库中缓存时长超过第一预设时长的目标消息,从所述第一数据库转存至第二数据库中。
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述目标消息的优先级,将所述目标消息缓存至第一数据库中,包括:
    若所述目标消息为高优先级消息,则将所述目标消息缓存至所述第一数据库中;
    若所述目标消息为低优先级消息,则将所述目标消息经过二次消费缓存至所述第一数据库中。
  3. 根据权利要求1所述的方法,其特征在于,所述将所述目标消息缓存至第一数据库中之后,所述方法还包括:
    获取缓存至所述第一数据库中的目标消息的第一数量;
    若所述第一数量超过第一阈值,则将所述目标消息按照缓存至所述第一数据库中的时间顺序进行删除,直至缓存至所述第一数据库中的目标消息的第一数量小于或等于所述第一阈值。
  4. 根据权利要求1所述的方法,其特征在于,所述将所述第一数据库中缓存时长超过第一预设时长的目标消息,从所述第一数据库转存至第二数据库中,包括:
    将所述第一数据库中的目标消息进行分类,形成多个集群;
    每间隔第二预设时长,检测每一集群中的目标消息在所述第一数据库中的缓存时长;
    将不同集群中缓存时长超过第一预设时长的目标消息,分别从所述第一数据库转存至所述第二数据库中。
  5. 根据权利要求1所述的方法,其特征在于,所述将所述第一数据库中缓存时长超过第一预设时长的目标消息,从所述第一数据库转存至第二数据库中之后,所述方法还包括:
    获取缓存至所述第二数据库中的目标消息的第二数量;
    若所述第二数量超过第二阈值,则将所述目标消息按照缓存至所述第二数据库中的时间顺序进行删除,直至缓存至所述第二数据库中的目标消息的第二数量小于或等于所述第二阈值。
  6. 根据权利要求1所述的方法,其特征在于,所述根据所述目标消息的优先级,将所述目标消息缓存至第一数据库中之后,所述方法还包括:
    每间隔第三预设时长,检测第二数据库的消息处理能力;
    若所述消息处理能力大于或等于预设消息处理能力,则将所述目标消息按照缓存至所述第一数据库中的时间顺序,从所述第一数据库转存至第二数据库中,直至所述第二数据库的消息处理能力小于所述预设消息处理能力。
  7. 根据权利要求1所述的方法,其特征在于,所述获取目标消息,包括:
    获取消息队列中的待消费消息,所述待消费消息是消息生产者写入所述消息队列的消息;
    对所述待消费消息中的目标待消费消息进行消费,获取消费之后的目标消息。
  8. 一种消息处理装置,其特征在于,所述装置包括:
    处理模块,用于获取目标消息,并确定所述目标消息的优先级;
    缓存模块,用于根据所述目标消息的优先级,将所述目标消息缓存至第一数据库中;
    第一转存模块,用于将所述第一数据库中缓存时长超过第一预设时长的目标消息,从所述第一数据库转存至第二数据库中。。
  9. 一种电子设备,其特征在于,包括:处理器、通信接口、存储器和通信总线;其中,处理器、通信接口以及存储器通过通信总线完成相互间的通信;
    存储器,用于存放计算机程序;
    处理器,用于执行存储器上所存放的程序时,实现如权利要求1至7任一项所述的消息处理方法中的步骤。
  10. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现如权利要求1至7任一项所述的消息处理方法。
  11. 一种计算机程序产品,包括计算机可读代码,当所述计算机可读代码在电子设备上运行时,导致所述电子设备执行根据权利要求1至7任一项 所述的消息处理方法。
PCT/CN2021/134525 2020-11-30 2021-11-30 消息处理方法、装置及电子设备 WO2022111733A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011377144.0 2020-11-30
CN202011377144 2020-11-30

Publications (1)

Publication Number Publication Date
WO2022111733A1 true WO2022111733A1 (zh) 2022-06-02

Family

ID=81754055

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/134525 WO2022111733A1 (zh) 2020-11-30 2021-11-30 消息处理方法、装置及电子设备

Country Status (1)

Country Link
WO (1) WO2022111733A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117093272A (zh) * 2023-10-07 2023-11-21 飞腾信息技术有限公司 指令发送方法及处理器
CN117896380A (zh) * 2024-03-14 2024-04-16 广州云积软件技术有限公司 用于云考试的高并发信息处理方法、系统和装置

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20100038800A (ko) * 2008-10-06 2010-04-15 에스케이텔레콤 주식회사 캐시서버에 저장된 데이터 갱신방법, 그 캐시서버 및 컨텐츠 제공시스템
CN102110121A (zh) * 2009-12-24 2011-06-29 阿里巴巴集团控股有限公司 一种数据处理方法及其系统
US9684687B1 (en) * 2014-03-10 2017-06-20 Ca, Inc. Multi-phase data expiration path for a database
CN107451224A (zh) * 2017-07-17 2017-12-08 广州特道信息科技有限公司 一种基于大数据并行计算的聚类方法及系统
CN109460438A (zh) * 2018-09-26 2019-03-12 中国平安人寿保险股份有限公司 消息数据存储方法、装置、计算机设备和存储介质
CN110765088A (zh) * 2019-10-22 2020-02-07 北京天融信网络安全技术有限公司 一种日志处理方法及电子设备

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20100038800A (ko) * 2008-10-06 2010-04-15 에스케이텔레콤 주식회사 캐시서버에 저장된 데이터 갱신방법, 그 캐시서버 및 컨텐츠 제공시스템
CN102110121A (zh) * 2009-12-24 2011-06-29 阿里巴巴集团控股有限公司 一种数据处理方法及其系统
US9684687B1 (en) * 2014-03-10 2017-06-20 Ca, Inc. Multi-phase data expiration path for a database
CN107451224A (zh) * 2017-07-17 2017-12-08 广州特道信息科技有限公司 一种基于大数据并行计算的聚类方法及系统
CN109460438A (zh) * 2018-09-26 2019-03-12 中国平安人寿保险股份有限公司 消息数据存储方法、装置、计算机设备和存储介质
CN110765088A (zh) * 2019-10-22 2020-02-07 北京天融信网络安全技术有限公司 一种日志处理方法及电子设备

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117093272A (zh) * 2023-10-07 2023-11-21 飞腾信息技术有限公司 指令发送方法及处理器
CN117093272B (zh) * 2023-10-07 2024-01-16 飞腾信息技术有限公司 指令发送方法及处理器
CN117896380A (zh) * 2024-03-14 2024-04-16 广州云积软件技术有限公司 用于云考试的高并发信息处理方法、系统和装置
CN117896380B (zh) * 2024-03-14 2024-05-31 广州云积软件技术有限公司 用于云考试的高并发信息处理方法、系统和装置

Similar Documents

Publication Publication Date Title
WO2022111733A1 (zh) 消息处理方法、装置及电子设备
CN109947668B (zh) 存储数据的方法和装置
WO2016206600A1 (zh) 一种信息流数据的处理方法和装置
WO2018121404A1 (zh) 一种超时监控方法及装置
WO2014019349A1 (zh) 一种文件合并方法和装置
US20190361607A1 (en) Providing combined data from a cache and a storage device
CN110995776A (zh) 区块链的区块分发方法、装置、计算机设备和存储介质
CN109842621A (zh) 一种减少token存储数量的方法及终端
US11044209B2 (en) Asymmetric co-operative queue management for messages
CN113672166A (zh) 数据处理方法、装置、电子设备及存储介质
WO2023142905A1 (zh) 任务调度方法、装置、终端设备及存储介质
WO2021087990A1 (zh) 标签更新方法、装置、电子设备及存储介质
WO2021087970A1 (zh) 标签数据的更新方法、装置、电子设备及存储介质
CN114116634B (zh) 一种缓存方法、装置及可读存储介质
WO2018077092A1 (zh) 应用于分布式文件系统的存盘方法、装置及分布式文件系统
CN115599828A (zh) 一种信息处理方法、装置、设备、存储介质
Lee et al. Energy-efficient storage policy for instant messenger services
US11683254B1 (en) Rate limit and burst limit enhancements for request processing
CN112613912B (zh) 高并发场景下的优惠券领取系统设计
CN116501549A (zh) 一种数据缓存方法、装置、电子设备及存储介质
CN113220212A (zh) 存储节点的调度方法、装置、存储节点、设备及可读介质
CN117149463A (zh) 消息处理方法、装置、计算机可读存储介质及终端设备
CN115730108A (zh) 一种数据处理方法、装置、电子设备和存储介质
WO2021087981A1 (zh) 标签数据的更新方法、装置、电子设备及存储介质
CN117632795A (zh) 缓存数据访问频次的统计方法、系统、装置、设备及介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21897233

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21897233

Country of ref document: EP

Kind code of ref document: A1