Data center consumer disaster recovery method, device and data center system

By receiving heartbeat information in the data center to determine the number of target consumers and controlling their consumption messages in the first data center, the message accumulation problem caused by consumer downtime is solved, consumers are disaster recovery is achieved, and the availability and processing speed of the data center are ensured.

CN116089119BActive Publication Date: 2025-08-19中国邮政储蓄银行股份有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211686149.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-27
Publication Date
2025-08-19
Estimated Expiration
2042-12-27

AI Technical Summary

Technical Problem

Some consumers in the data center have caused the problem of message accumulation. The increase in the number of consumer processing programs in the existing technology cannot completely solve the problem of message backlog in extreme cases.

Method used

By receiving a plurality of first heartbeat information, determining the target number based on the heartbeat information and predetermined information, controlling the target consumer to consume messages in the first data center, and sending the information to the backup message middleware to realize the consumer's disaster recovery.

Benefits of technology

It avoids message accumulation, maintains the on-site integrity of the data center, facilitates analysis of abnormal downtime causes, reduces the trap of consumer restarts, and reduces network time-consuming and machine resource costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116089119B_ABST
    Figure CN116089119B_ABST
Patent Text Reader

Abstract

The present application provides a method, device and data center system for consumer disaster recovery in a data center. The method includes: upon receiving multiple first heartbeat messages, determining a target number based on the multiple first heartbeat messages and first predetermined information, wherein the first heartbeat message is sent by a first consumer, the first consumer is a consumer working normally in the first data center, the second consumer is a consumer in the second data center, the first predetermined information is the number of third consumers, the third consumer is a second consumer that consumes messages in the first data center, and the target number is the total number of the first and third consumers; when the target number is less than the configured number, controlling a target consumer among the multiple second consumers to consume messages in the first data center, and sending a second predetermined information to the backup message middleware, wherein the second predetermined information is information characterizing the target consumer's consumption of messages in the first data center. The present application solves the problem of message accumulation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method and device for consumer disaster recovery in a data center, a computer-readable storage medium, a processor, and a data center system. Background Art

[0002] During system development, message-based middleware services are used to perform asynchronous processing tasks and decouple upstream and downstream applications. Downstream processing applications are called consumers. Consumers receive messages from upstream systems from the message-based middleware service. These messages are typically formatted as a protocol message and then processed. If a downstream consumer fails, messages sent from upstream systems will accumulate in the middleware service. While message-based middleware services can accumulate messages, this is not possible indefinitely. Excessive accumulation increases the delay of subsequent messages, so the reliability of the consumer processing applications must be improved. Typically, the number of consumer processing applications is increased to improve processing speed and prevent single points of failure. However, extreme situations can occur, such as failures in most or all consumer processing nodes. In these cases, consumption is slow or messages are not processed by the application, leading to a gradual backlog of messages as they continue to be sent from upstream systems. Summary of the Invention

[0003] The main purpose of this application is to provide a data center consumer disaster recovery method, device, computer-readable storage medium, processor and data center system to solve the problem of message accumulation caused by the downtime of some consumers in the data center in the prior art.

[0004] According to one aspect of an embodiment of the present invention, a consumer disaster recovery method for a data center is provided, which is applied to a target consumer. The method includes: when receiving multiple first heartbeat messages, determining a target number based on the multiple first heartbeat messages and first predetermined information, the first heartbeat message is the heartbeat message sent by each first consumer, the first heartbeat message includes identification information of the first consumer, the first consumer is a consumer working normally in the first data center, the first predetermined information is information representing the number of third consumers, the third consumer is a second consumer consuming messages in the first data center, the second consumer is a consumer in the second data center, the target consumer is one of the multiple second consumers, and the target number is the total number of the first consumers and the third consumers; when the target number is less than the configured number, controlling the target consumer to consume messages in the first data center, and sending second predetermined information to the backup message middleware, the backup message middleware is the message middleware of the second data center, and the second predetermined information is information representing the target consumer consuming messages in the first data center.

[0005] Optionally, when multiple first heartbeat messages are received, the target quantity is determined based on the multiple first heartbeat messages and the first predetermined information, including: when multiple first heartbeat messages are received, starting a random duration delay; when the delay duration reaches the random duration, determining the number of the first consumers based on the multiple first heartbeat messages; and determining the target quantity based on the number of the first consumers and the number of the third consumers.

[0006] Optionally, controlling the target consumer to consume messages in the first data center includes: controlling the target consumer to communicate with the main message middleware, where the main message middleware is the message middleware of the first data center; and controlling the target consumer to read messages from the main message middleware.

[0007] Optionally, the method also includes: generating a second heartbeat message when the target consumer operates normally, the second heartbeat message including identification information of the target consumer; controlling the target consumer to send the second heartbeat message to the main message middleware or a third-party device, the third-party device being a device that communicates with each of the first consumers.

[0008] Optionally, before determining the target quantity based on multiple first heartbeat information and first reservation information, the method also includes: obtaining the first reservation information from the backup message middleware, the first heartbeat information being sent by the backup message middleware via broadcast when receiving the first heartbeat information sent by each first consumer, or being sent by a third-party device when receiving the first heartbeat information sent by each first consumer.

[0009] Optionally, when the target quantity is greater than or equal to the configured quantity, the method further includes: when the target quantity is greater than the configured quantity and the target consumer consumes messages in the first data center, controlling the target consumer to stop consuming messages in the first data center and sending a third predetermined information to the backup message middleware, wherein the third predetermined information is information indicating that the target consumer does not consume messages in the first data center; when the target quantity is equal to the configured quantity, controlling the target consumer to maintain a current consumption state, wherein the current consumption state is a state of consuming messages in the first data center or a state of not consuming messages in the first data center.

[0010] According to another aspect of an embodiment of the present invention, a consumer disaster recovery device for a data center is also provided, which is applied to a target consumer and includes: a determination unit for determining a target quantity based on multiple first heartbeat messages and first predetermined information when receiving multiple first heartbeat messages, the first heartbeat information being the heartbeat information sent by each first consumer, the first heartbeat information including identification information of the first consumer, the first consumer being a consumer working normally in the first data center, the first predetermined information being information representing the number of third consumers, the third consumer being a second consumer consuming messages in the first data center, the second consumer being a consumer in the second data center, the target consumer being one of multiple second consumers, and the target quantity being the total number of the first consumers and the third consumers; a first control unit for controlling the target consumer to consume messages in the first data center when the target quantity is less than the configured quantity, and sending a second predetermined information to the backup message middleware, the backup message middleware being the message middleware of the second data center, the second predetermined information being information representing the target consumer consuming messages in the first data center.

[0011] According to yet another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein the program executes any one of the methods described above.

[0012] According to yet another aspect of an embodiment of the present invention, a processor is provided, wherein the processor is configured to run a program, wherein any one of the methods is executed when the program is run.

[0013] According to another aspect of an embodiment of the present invention, a data center system is also provided, including: a first data center, including a main message middleware and multiple first consumers, and the multiple first consumers are used to read messages from the main message middleware; a second data center, including a backup message middleware and multiple second consumers, and the multiple second consumers are used to read messages from the backup message middleware; wherein, the first consumer and the second consumer respectively include: one or more processors, a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of the described methods.

[0014] Adopting the technical solution of the present application, in the consumer disaster recovery method of the data center, when receiving the first heartbeat information sent by multiple first consumers, first, based on the multiple first heartbeat information and the first predetermined information representing the number of third consumers, determine the target number representing the total number of first consumers and third consumers, wherein the first consumer is a consumer working normally in the first data center, the second consumer is a consumer in the second data center, the third consumer is a second consumer that consumes messages in the first data center, and the target consumer is one of the multiple second consumers; thereafter, when the target number is less than the configured number, control the target consumer to consume messages in the first data center, and send the second predetermined information representing the target consumer consuming messages in the first data center to the message middleware of the second data center. When the present application detects that the number of consumers consuming messages from the first data center does not meet the configured number, it controls the target consumer in the second data center to consume the messages from the first data center, thereby achieving consumer disaster recovery and avoiding the problem of message accumulation in the first data center due to lack of consumers. In addition, the number of consumers consuming messages from the first data center does not meet the configured number, indicating that some consumers in the first data center have experienced abnormal downtime. This application performed a failover after the consumers in the first data center crashed, and transferred the tasks that should be processed by the crashed consumers to the consumers in the backup data center. On the one hand, it maintained the on-site integrity of the first data center, which is very beneficial for analyzing the causes of abnormal downtime. On the other hand, it is convenient to repair consumers after finding the causes, avoiding consumers falling into the trap of infinite restarts. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The drawings that constitute part of this application are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an improper limitation on this application. In the drawings:

[0016] Figure 1 A schematic diagram of a process flow of a method for customer disaster recovery in a data center according to an embodiment of the present application is shown;

[0017] Figure 2 A structural block diagram of a consumer disaster recovery device in a data center according to an embodiment of the present application is shown;

[0018] Figure 3 shows a structural diagram of a data center system according to an embodiment of the present application;

[0019] Figure 4 A flowchart of a data center system according to an embodiment of the present application is shown;

[0020] Figure 5 A workflow diagram of a data center system according to another embodiment of the present application is shown. DETAILED DESCRIPTION

[0021] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0022] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.

[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0024] It should be understood that when an element (such as a layer, film, region, or substrate) is described as being "on" another element, the element may be directly on the other element or intervening elements may be present. Moreover, in the specification and claims, when it is described that an element is "connected to" another element, the element may be "directly connected to" the other element or "connected to" the other element through a third element.

[0025] For ease of description, some nouns or terms involved in the embodiments of the present application are explained below:

[0026] Message middleware: A message broker responsible for storing and forwarding messages. It receives and stores messages from producers, prepares pull requests for consumers, and stores message-related metadata, including consumer groups, consumption progress offsets, and topic and queue information.

[0027] Producer: Responsible for producing messages. Generally, the business system is responsible for producing messages. A message producer will send the messages generated in the business application system to the message middleware.

[0028] Consumer: Responsible for consuming messages. Generally, the backend system is responsible for asynchronous consumption. A message consumer pulls messages from the message middleware and provides them to the application.

[0029] As mentioned in the background technology, in the prior art, some consumers in the data center crash and cause message accumulation. In order to solve the problem, a typical embodiment of the present application provides a data center consumer disaster recovery method, device, computer-readable storage medium, processor and data center system.

[0030] According to an embodiment of the present application, a consumer disaster recovery method for a data center is provided, and the method is applied to a target consumer.

[0031] Figure 1 FIG. 1 is a flow chart of a method for consumer disaster recovery in a data center according to an embodiment of the present application. Figure 1 As shown, the method includes the following steps:

[0032] Step S101: Upon receiving multiple first heartbeat messages, determine a target quantity based on the multiple first heartbeat messages and first predetermined information, wherein the first heartbeat messages are heartbeat messages sent by each first consumer, the first heartbeat messages include identification information of the first consumer, the first consumer is a consumer operating normally in a first data center, the first predetermined information is information representing the number of third consumers, the third consumer is a second consumer consuming messages in the first data center, the second consumer is a consumer in a second data center, the target consumer is one of the multiple second consumers, and the target quantity is the total number of the first consumers and the third consumers;

[0033] The identification information of the first consumer may be the name of the first consumer or the ID number of the first consumer, and is a unique identifier of the first consumer. The first heartbeat information also includes the identification information of the data center where the first consumer is located, i.e., the identification information of the first data center. The identification information of the first data center may be the name of the first data center or the ID number of the first data center, and is a unique identifier of the first data center.

[0034] The first data center and the second data center of the present application serve as backups for each other, and the first consumer and the second consumer consume the same type of messages and have consistent consumption logic.

[0035] In a specific embodiment, when multiple first heartbeat messages are received, a target number is determined based on the multiple first heartbeat messages and the first predetermined information, including: when multiple first heartbeat messages are received, a random delay is initiated; when the delay reaches the random delay, the number of first consumers is determined based on the multiple first heartbeat messages; and the target number is determined based on the number of first consumers and the number of third consumers. When the first heartbeat message is received, by initiating a random delay, the target number is determined based on the first heartbeat message only after the delay ends. This can prevent multiple second consumers from competing for processing the first heartbeat message at the same time, causing inaccurate target data.

[0036] In another specific embodiment, the target number is determined based on multiple first heartbeat information and first predetermined information, including: periodically determining the target number based on multiple first heartbeat information and first predetermined information, that is, when multiple first heartbeat information are received, starting a random duration delay every predetermined time; when the delay duration reaches the random duration, determining the number of the first consumers based on multiple first heartbeat information; determining the target number based on the number of the first consumers and the number of the third consumers.

[0037] In the present application, the predetermined duration is 1 minute, and the random duration can be 10ms, 15ms, 20ms and 25ms.

[0038] It should be noted that each second consumer in the second data center can be used as a target consumer for running the method of this application. In order to further avoid the problem of consumer competition, different second consumers correspond to different random durations.

[0039] Of course, the solution to avoid startup quantity errors is not limited to the described solution of random startup time delay. In other embodiments, the consumption information of all second consumers (including those that have started consumption in the first data center and those that have not started consumption in the first data center) can also be obtained through heartbeats. According to the consumption information, the second consumers that have not started consumption in the first data center are sorted, and the required number of second consumers are started in sequence, so that the startup information of each node can be kept consistent.

[0040] Step S102, when the target quantity is less than the configured quantity, controls the target consumer to consume messages in the first data center, and sends second predetermined information to the backup message middleware, the backup message middleware is the message middleware of the second data center, and the second predetermined information is information representing that the target consumer consumes messages in the first data center.

[0041] Those skilled in the art can flexibly set the configuration quantity, such as 4, 5 or other values.

[0042] When the target quantity is less than the configured quantity, controlling the target consumer to consume messages in the first data center includes: when the target quantity is less than the configured quantity and the second data center is in disaster recovery consumption mode, controlling the target consumer to consume messages in the first data center.

[0043] In order to further solve the problem of message accumulation caused by downtime of some consumers in the data center in the prior art, in another embodiment of the present application, controlling the target consumer to consume messages in the first data center includes: controlling the target consumer to communicate with the main message middleware, the main message middleware being the message middleware of the first data center; and controlling the target consumer to read messages from the main message middleware. By controlling the target consumer to read messages from the main message middleware, consumer disaster recovery is further achieved, the problem of message accumulation in the first data center due to lack of consumers is further avoided, and the high availability of the first data center and the fast task processing speed are further ensured, and the business will basically not be delayed due to the downtime of some consumers in the first data center.

[0044] In addition, the method further includes: generating a second heartbeat message when the target consumer is operating normally, the second heartbeat message including identification information of the target consumer; and controlling the target consumer to send the second heartbeat message to the primary message middleware or a third-party device, the third-party device being a device that communicates with each of the first consumers. In other words, the first consumer and the second consumer send heartbeat messages to each other. In this way, if some consumers in the second data center go down, consumers in the first data center can read messages from the backup message middleware, thereby avoiding problems such as data accumulation and service processing delays in the second data center.

[0045] The third-party device may be a third-party cache center or a third-party registration center. The number of consumers may be perceived by periodically querying cache information to update the local heartbeat maintenance list.

[0046] According to another specific embodiment of the present application, before determining the target quantity based on multiple first heartbeat messages and first predetermined information, the method also includes: obtaining the first predetermined information from the backup message middleware, the first heartbeat message being sent by the backup message middleware in a broadcast manner when receiving the first heartbeat message sent by each first consumer, or being sent by a third-party device in a case where it receives the first heartbeat message sent by each first consumer. When the backup message middleware receives each first heartbeat message, it broadcasts the first heartbeat message so that each second consumer in the second data center can receive it, or when the third-party device receives each first heartbeat message, it forwards the first heartbeat message to each second consumer in the second data center, thereby achieving flexible forwarding of the first heartbeat message and ensuring that each second consumer receives and processes the first heartbeat message.

[0047] To further ensure that the first heartbeat information is widely disseminated and that every second consumer can receive it, in one embodiment, the method further includes: upon receiving multiple first heartbeat information messages, broadcasting the multiple first heartbeat information messages so that other second consumers within the communication range of the target consumer can receive them.

[0048] According to another specific embodiment of the present application, when the target number is greater than or equal to the configured number, the method further includes: when the target number is greater than the configured number and the target consumer consumes messages in the first data center, controlling the target consumer to stop consuming messages in the first data center and sending a third predetermined information to the backup message middleware, wherein the third predetermined information is information indicating that the target consumer does not consume messages in the first data center; when the target number is equal to the configured number, controlling the target consumer to maintain the current consumption state, wherein the current consumption state is a state of consuming messages in the first data center or a state of not consuming messages in the first data center. This achieves consumer recovery and retraction in the data center, that is, the target consumer will only access across centers when a consumer in the first data center fails, and there is no excessive cross-center access processing during normal times.

[0049] In addition, the method further includes: when the target quantity is greater than the configured quantity and the target consumer does not consume messages in the first data center, controlling the target consumer to maintain the current consumption state, that is, the state of not consuming messages in the first data center.

[0050] This application makes friendly use of hot standby applications between multiple data centers, which can ensure smooth processing of consumption processing logic, avoid a large backlog of messages at once, and ensure the consumption processing speed as much as possible.

[0051] In the consumer disaster recovery method of the data center, when a first heartbeat message sent by a plurality of first consumers is received, first, based on the plurality of the first heartbeat messages and the first predetermined information representing the number of third consumers, a target number representing the total number of first consumers and third consumers is determined, wherein the first consumer is a consumer working normally in the first data center, the second consumer is a consumer in the second data center, the third consumer is a second consumer consuming messages in the first data center, and the target consumer is one of the plurality of the second consumers; thereafter, when the target number is less than the configured number, the target consumer is controlled to consume messages in the first data center, and the second predetermined information representing the target consumer consuming messages in the first data center is sent to the message middleware of the second data center. When the present application detects that the number of consumers consuming messages from the first data center does not meet the configured number, it controls the target consumer in the second data center to consume the messages from the first data center, thereby achieving consumer disaster recovery and avoiding the problem of message accumulation in the first data center due to lack of consumers. In addition, the number of consumers consuming messages from the first data center does not meet the configured number, indicating that some consumers in the first data center have experienced abnormal downtime. This application performed a failover after the consumers in the first data center crashed, and transferred the tasks that should be processed by the crashed consumers to the consumers in the backup data center. On the one hand, it maintained the on-site integrity of the first data center, which is very beneficial for analyzing the causes of abnormal downtime. On the other hand, it is convenient to repair consumers after finding the causes, avoiding consumers falling into the trap of infinite restarts.

[0052] The existing solution to the problem of recovery after a message consumption application fails is to add a layer of listeners between the message middleware and the consumer. The listener is responsible for monitoring the status of the consumer and restarting the consumer if a consumer fails. At the same time, the listener forwards the message to the available consumer node. This solution uses a listener layer between the message middleware and the consumer to implement consumer fault handling. First, adding a layer of processing will increase network time consumption, and there is a situation where the consumption processing time consumption increases. At the same time, it will increase the cost of machine resources. At the same time, the newly added listener layer itself may also fail. If the listener layer itself fails, the problem still cannot be solved. The method of the present application can achieve recovery after a message consumption application fails without adding a listener, ensuring that the network time consumption is small and the machine resource cost is low.

[0053] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0054] The present application also provides a data center consumer disaster recovery device, which is applied to target consumers. It should be noted that the data center consumer disaster recovery device of the present application embodiment can be used to execute the data center consumer disaster recovery method provided in the present application embodiment. The following describes the data center consumer disaster recovery device provided in the present application embodiment.

[0055] Figure 2 Schematic diagram of a consumer disaster recovery device in a data center according to an embodiment of the present application. Figure 2 As shown, the device includes:

[0056] A determination unit 10 is configured to determine a target quantity based on the plurality of first heartbeat messages and first predetermined information when receiving a plurality of first heartbeat messages, wherein the first heartbeat messages are heartbeat messages sent by each first consumer, the first heartbeat messages include identification information of the first consumer, the first consumer is a consumer operating normally in the first data center, the first predetermined information is information representing the number of third consumers, the third consumer is a second consumer consuming messages in the first data center, the second consumer is a consumer in the second data center, the target consumer is one of the plurality of second consumers, and the target quantity is the total number of the first consumers and the third consumers;

[0057] The identification information of the first consumer may be the name of the first consumer or the ID number of the first consumer, and is a unique identifier of the first consumer. The first heartbeat information also includes the identification information of the data center where the first consumer is located, i.e., the identification information of the first data center. The identification information of the first data center may be the name of the first data center or the ID number of the first data center, and is a unique identifier of the first data center.

[0058] The first data center and the second data center of the present application serve as backups for each other, and the first consumer and the second consumer consume the same type of messages and have consistent consumption logic.

[0059] In a specific embodiment, the determination unit includes: a starting module for starting a random-duration delay when a plurality of the first heartbeat messages are received; a first determination module for determining the number of the first consumers based on the plurality of the first heartbeat messages when the delay reaches the random duration; and a second determination module for determining the target number based on the number of the first consumers and the number of the third consumers. When the first heartbeat message is received, by starting a random-duration delay so that the target number is determined based on the first heartbeat message after the delay ends, it is possible to prevent multiple second consumers from competing for processing the first heartbeat message at the same time, thereby preventing the determined target data from being inaccurate.

[0060] In another specific embodiment, the determination unit includes: a third determination module, used to periodically determine the target number based on multiple first heartbeat information and first predetermined information, that is, the third determination module is used to start a random duration delay every predetermined time period when multiple first heartbeat information are received; the third determination module is also used to determine the number of the first consumers based on multiple first heartbeat information when the delay duration reaches the random duration; and determine the target number based on the number of the first consumers and the number of the third consumers.

[0061] In the present application, the predetermined duration is 1 minute, and the random duration can be 10ms, 15ms, 20ms and 25ms.

[0062] It should be noted that each second consumer in the second data center can be used as a target consumer for running the device of this application. In order to further avoid the problem of consumer competition, different second consumers correspond to different random time lengths.

[0063] Of course, the solution to avoid startup quantity errors is not limited to the described solution of random startup time delay. In other embodiments, the consumption information of all second consumers (including those that have started consumption in the first data center and those that have not started consumption in the first data center) can also be obtained through heartbeats. According to the consumption information, the second consumers that have not started consumption in the first data center are sorted, and the required number of second consumers are started in sequence, so that the startup information of each node can be kept consistent.

[0064] The first control unit 20 is used to control the target consumer to consume messages in the first data center when the target quantity is less than the configured quantity, and send second predetermined information to the backup message middleware, the backup message middleware is the message middleware of the second data center, and the second predetermined information is information representing that the target consumer consumes messages in the first data center.

[0065] Those skilled in the art can flexibly set the configuration quantity, such as 4, 5 or other values.

[0066] The first control unit includes: a control module, which is used to control the target consumer to consume messages in the first data center when the target quantity is smaller than the configured quantity and the second data center is in a disaster recovery consumption mode.

[0067] In order to further solve the problem of message accumulation caused by the downtime of some consumers in the data center in the prior art, in another embodiment of the present application, the control module includes: a first control submodule, which is used to control the communication connection between the target consumer and the main message middleware, and the main message middleware is the message middleware of the first data center; a second control submodule, which is used to control the target consumer to read messages from the main message middleware. By controlling the target consumer to read messages from the main message middleware, consumer disaster recovery is further achieved, and the problem of message accumulation in the first data center due to the lack of consumers is further avoided, which further ensures that the first data center has high availability and fast task processing speed, and the business will basically not be delayed due to the downtime of some consumers in the first data center.

[0068] In addition, the device also includes: a generation unit for generating a second heartbeat message when the target consumer is operating normally, wherein the second heartbeat message includes the identification information of the target consumer; and a second control unit for controlling the target consumer to send the second heartbeat message to the main message middleware or a third-party device, wherein the third-party device is a device that communicates with each of the first consumers. In other words, the first consumer and the second consumer send heartbeat messages to each other, so that when some consumers in the second data center go down, the consumers in the first data center can read messages from the backup message middleware, thereby avoiding problems such as data accumulation and business processing delays in the second data center.

[0069] The third-party device may be a third-party cache center or a third-party registration center. The number of consumers may be perceived by periodically querying cache information to update the local heartbeat maintenance list.

[0070] According to another specific embodiment of the present application, the device further includes: an acquisition unit for acquiring the first predetermined information from the backup message middleware before determining the target quantity based on multiple first heartbeat messages and first predetermined information, wherein the first heartbeat message is sent by the backup message middleware in a broadcast manner when the backup message middleware receives the first heartbeat message sent by each first consumer, or is sent by a third-party device in a case where the backup message middleware receives the first heartbeat message sent by each first consumer. When the backup message middleware receives each first heartbeat message, it propagates the first heartbeat message in a broadcast manner so that each second consumer in the second data center can receive it, or when the third-party device receives each first heartbeat message, it forwards the first heartbeat message to each second consumer in the second data center, thereby realizing flexible forwarding of the first heartbeat message and ensuring that each second consumer will receive the first heartbeat message and process the first heartbeat message.

[0071] To further ensure that the first heartbeat information is widely disseminated and that every second consumer can receive it, in one embodiment, the apparatus further includes: a sending unit configured to, upon receiving multiple first heartbeat information messages, broadcast the multiple first heartbeat information messages so that other second consumers within the communication range of the target consumer can receive them.

[0072] According to another specific embodiment of the present application, the device further includes: a third control unit for controlling the target consumer to stop consuming messages in the first data center and sending a third predetermined information to the backup message middleware when the target number is greater than or equal to the configured number, and when the target number is greater than the configured number and the target consumer consumes messages in the first data center; and sending a third predetermined information to the backup message middleware, wherein the third predetermined information is information indicating that the target consumer does not consume messages in the first data center; and a fourth control unit for controlling the target consumer to maintain a current consumption state when the target number is equal to the configured number, wherein the current consumption state is a state of consuming messages in the first data center or a state of not consuming messages in the first data center. This achieves consumer recovery and retraction in the data center, that is, the target consumer will only access across centers when a consumer in the first data center fails, and there is no excessive cross-center access processing during normal times.

[0073] In addition, the device also includes: a fifth control unit, which is used to control the target consumer to maintain the current consumption state, that is, the state of not consuming messages in the first data center, when the target quantity is greater than the configured quantity and the target consumer does not consume messages in the first data center.

[0074] This application makes friendly use of hot standby applications between multiple data centers, which can ensure smooth processing of consumption processing logic, avoid a large backlog of messages at once, and ensure the consumption processing speed as much as possible.

[0075] In the consumer disaster recovery device of the data center, when receiving the first heartbeat information sent by multiple first consumers, the determination unit determines the target number representing the total number of first consumers and third consumers based on the multiple first heartbeat information and the first predetermined information representing the number of third consumers, wherein the first consumer is a consumer working normally in the first data center, the second consumer is a consumer in the second data center, the third consumer is a second consumer who consumes messages in the first data center, and the target consumer is one of the multiple second consumers; when the target number is less than the configured number, the first control unit controls the target consumer to consume messages in the first data center, and sends the second predetermined information representing the target consumer consuming messages in the first data center to the message middleware of the second data center. When the present application detects that the number of consumers consuming messages from the first data center does not meet the configured number, it controls the target consumer in the second data center to consume the messages from the first data center, thereby achieving consumer disaster recovery and avoiding the problem of message accumulation in the first data center due to lack of consumers. In addition, the number of consumers consuming messages from the first data center does not meet the configured number, indicating that some consumers in the first data center have experienced abnormal downtime. This application performed a failover after the consumers in the first data center crashed, and transferred the tasks that should be processed by the crashed consumers to the consumers in the backup data center. On the one hand, it maintained the on-site integrity of the first data center, which is very beneficial for analyzing the causes of abnormal downtime. On the other hand, it is convenient to repair consumers after finding the causes, avoiding consumers falling into the trap of infinite restarts.

[0076] The existing solution to the problem of recovery after a message consumption application fails is to add a layer of listeners between the message middleware and the consumer. The listener is responsible for monitoring the status of the consumer and restarting the consumer if a consumer fails. At the same time, the listener forwards the message to the available consumer node. This solution uses a listener layer between the message middleware and the consumer to implement consumer fault handling. First, adding a layer of processing will increase network time consumption, and there is a situation where the consumption processing time consumption increases. At the same time, it will increase the cost of machine resources. At the same time, the newly added listener layer itself may also fail. If the listener layer itself fails, the problem still cannot be solved. The device of the present application can achieve recovery after a message consumption application fails without adding a listener, ensuring that the network time consumption is small and the machine resource cost is low.

[0077] The consumer disaster recovery device of the data center includes a processor and a memory. The determination unit and the first control unit are stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions.

[0078] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be configured, and kernel parameters can be adjusted to address the existing problem of message accumulation caused by downtime of some consumers in the data center.

[0079] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0080] An embodiment of the present invention provides a computer-readable storage medium having a program stored thereon. When the program is executed by a processor, the method for consumer disaster recovery in the data center is implemented.

[0081] An embodiment of the present invention provides a processor, which is used to run a program, wherein the program executes the customer disaster recovery method of the data center when running.

[0082] An embodiment of the present invention provides a device, comprising a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, at least the following steps are performed:

[0083] Step S101: Upon receiving multiple first heartbeat messages, determine a target quantity based on the multiple first heartbeat messages and first predetermined information, wherein the first heartbeat messages are heartbeat messages sent by each first consumer, the first heartbeat messages include identification information of the first consumer, the first consumer is a consumer operating normally in a first data center, the first predetermined information is information representing the number of third consumers, the third consumer is a second consumer consuming messages in the first data center, the second consumer is a consumer in a second data center, the target consumer is one of the multiple second consumers, and the target quantity is the total number of the first consumers and the third consumers;

[0084] Step S102, when the target quantity is less than the configured quantity, controls the target consumer to consume messages in the first data center, and sends second predetermined information to the backup message middleware, the backup message middleware is the message middleware of the second data center, and the second predetermined information is information representing that the target consumer consumes messages in the first data center.

[0085] The devices in this article can be servers, PCs, PADs, mobile phones, etc.

[0086] The present application also provides a computer program product, which, when executed on a data processing device, is adapted to execute a program for initializing at least the following method steps:

[0087] Step S101: Upon receiving multiple first heartbeat messages, determine a target quantity based on the multiple first heartbeat messages and first predetermined information, wherein the first heartbeat messages are heartbeat messages sent by each first consumer, the first heartbeat messages include identification information of the first consumer, the first consumer is a consumer operating normally in a first data center, the first predetermined information is information representing the number of third consumers, the third consumer is a second consumer consuming messages in the first data center, the second consumer is a consumer in a second data center, the target consumer is one of the multiple second consumers, and the target quantity is the total number of the first consumers and the third consumers;

[0088] Step S102, when the target quantity is less than the configured quantity, controls the target consumer to consume messages in the first data center, and sends second predetermined information to the backup message middleware, the backup message middleware is the message middleware of the second data center, and the second predetermined information is information representing that the target consumer consumes messages in the first data center.

[0089] According to another typical embodiment of the present application, there is also provided a Figure 3 The data center system shown includes: a first data center, including a main message middleware and multiple first consumers, and the multiple first consumers are used to read messages from the main message middleware; a second data center, including a backup message middleware and multiple second consumers, and the multiple second consumers are used to read messages from the backup message middleware; wherein, the first consumer and the second consumer respectively include: one or more processors, a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of the described methods.

[0090] In the data center system, the first consumer of the first data center and the second consumer of the second data center are both used to execute the data center consumer disaster recovery method. When the method detects that the number of consumers consuming messages from the first data center (or the second data center) does not meet the configured number, the method controls the target consumer in the second data center (or the first data center) to consume the messages from the first data center (or the second data center), thereby achieving consumer disaster recovery and avoiding the problem of message accumulation in the first data center (or the second data center) due to the lack of consumers, thereby ensuring that the message processing reliability of the data center system is high. In addition, if the number of consumers consuming messages from the first data center (or the second data center) does not meet the configured number, it means that some consumers in the first data center (or the second data center) have experienced a downtime anomaly. In this application, after the consumer in the first data center (or the second data center) goes down, a failover is performed, and the tasks that the downtime consumer should handle are transferred to the consumer in the backup data center. On the one hand, the on-site integrity of the first data center (or the second data center) is maintained, which is very beneficial for analyzing the cause of the abnormal downtime. On the other hand, it is convenient to repair the consumer after finding the cause, avoiding the consumer falling into the trap of infinite restart, thereby ensuring the high system security performance of the data center system.

[0091] The first data center also includes a first producer, and the second data center also includes a second producer. The first producer and the second producer may be the same or different. It should be noted that the first data center and the second data center of this application serve as backups for each other.

[0092] Of course, the number of data centers in the data center system is not limited to two, but can also be three, four or other numbers.

[0093] like Figure 4 As shown, the workflow of the data center system is described by taking the scenario where the number of consumer machines in data center 1 is down to 2 and at least 4 machines are required to be available as an example.

[0094] The number of consumers in the first data center (hereinafter referred to as the source data center for ease of description) is reduced to 2, and the configured number is 4. When the second data center (hereinafter referred to as the current data center for ease of description) receives that the number of source data centers is 2 and the number of consumers in the current data center plus the number of consumers in the source data center is less than the configured 4, it starts the consumer instance in the source data center. Each time the current data center starts a consumer in the source data center, it will send the second predetermined information (also a heartbeat information, such as Figure 4The heartbeat shown in (shown in) is sent to the message middleware of this data center (i.e., the backup message middleware), which will update the number of consumers in this data center. If the number of consumers in this data center plus the number of consumers in the source data center is greater than or equal to 4, consumers in the source data center will no longer be started.

[0095] Figure 4 Consumer 1 has the shortest delay and is executed first. It checks that the number of consumers from this data center to the source data center is 0, and the number of consumers from the source data center is 2. If the sum is less than 4, then consumer 1 is started to the source data center and a second reservation message is sent to this data center. Then, when consumer 2's delay is reached, it checks that the number of consumers from this data center is 1, and the number of consumers from the source data center is 2. If the sum is less than 4, then consumer 2 is started to the source data center and a second reservation message is sent to this data center. Then, when consumers 3 and 4's delay is reached, it is found that the number of consumers from this data center to the source data center is 2, and the sum is sufficient, so consumers from the source data center are no longer started. Due to the random delay and real-time feedback of the second reservation information, the number of consumers from this data center consuming from the source data center can be precisely controlled.

[0096] like Figure 5 As shown in the figure, when one consumer of source data center 1 is restored, that is, the number of consumers becomes 3, the processing flow of the data center system is as follows:

[0097] Consumer 1 of this data center has the shortest delay and is the first to find that the number of consumers of this data center plus the three consumers of the source data center is greater than four. It will stop the previously started consumer 1 of the source data center and stop the second scheduled information (also the heartbeat information, such as Figure 5 ) is sent. Consumer 2, when its scheduled task executes, finds that the combination of 1 in its own data center and 3 in the source data center meets the requirements and resumes consumption from the source data center. Consumers 3 and 4, finding that the requirements are met and not requiring any action, terminate their scheduled tasks. Similarly, when the source data center returns to 4 available nodes, Consumer 2 in its own data center will also deactivate the consumer instance that previously started consuming from the source data center.

[0098] This process describes how, after a consumer application failure, consumer processing is automatically transferred to another data center. After recovery, the transferred application processing is automatically removed. The entire process is delayed by the duration of the scheduled task's window.

[0099] In the embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0100] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0101] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0102] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The integrated unit may be implemented in the form of hardware or software functional units.

[0103] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk, etc. Various media that can store program codes.

[0104] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:

[0105] 1) In the consumer disaster recovery method of the data center described in the present application, when a first heartbeat message sent by a plurality of first consumers is received, first, based on the plurality of the first heartbeat messages and the first predetermined information representing the number of third consumers, a target number representing the total number of first consumers and third consumers is determined, wherein the first consumer is a consumer working normally in the first data center, the second consumer is a consumer in the second data center, the third consumer is a second consumer consuming messages in the first data center, and the target consumer is one of the plurality of the second consumers; thereafter, when the target number is less than the configured number, the target consumer is controlled to consume messages in the first data center, and the second predetermined information representing the target consumer consuming messages in the first data center is sent to the message middleware of the second data center. When the present application detects that the number of consumers consuming messages from the first data center does not meet the configured number, it controls the target consumer in the second data center to consume the messages from the first data center, thereby achieving consumer disaster recovery and avoiding the problem of message accumulation in the first data center due to lack of consumers. In addition, the number of consumers consuming messages from the first data center does not meet the configured number, indicating that some consumers in the first data center have experienced abnormal downtime. This application performed a failover after the consumers in the first data center crashed, and transferred the tasks that should be processed by the crashed consumers to the consumers in the backup data center. On the one hand, it maintained the on-site integrity of the first data center, which is very beneficial for analyzing the causes of abnormal downtime. On the other hand, it is convenient to repair consumers after finding the causes, avoiding consumers falling into the trap of infinite restarts.

[0106] 2) In the consumer disaster recovery device of the data center described in the present application, when receiving the first heartbeat information sent by multiple first consumers, the determination unit determines the target number representing the total number of first consumers and third consumers based on the multiple first heartbeat information and the first predetermined information representing the number of third consumers, wherein the first consumer is a consumer working normally in the first data center, the second consumer is a consumer in the second data center, the third consumer is a second consumer consuming messages in the first data center, and the target consumer is one of the multiple second consumers; when the target number is less than the configured number, the first control unit controls the target consumer to consume messages in the first data center, and sends the second predetermined information representing the target consumer consuming messages in the first data center to the message middleware of the second data center. When it is detected that the number of consumers consuming messages from the first data center does not meet the configured number, the present application realizes consumer disaster recovery by controlling the target consumer in the second data center to consume the messages of the first data center, thereby avoiding the problem of message accumulation in the first data center due to lack of consumers. In addition, the number of consumers consuming messages from the first data center does not meet the configured number, indicating that some consumers in the first data center have experienced abnormal downtime. This application performed a failover after the consumers in the first data center crashed, and transferred the tasks that should be processed by the crashed consumers to the consumers in the backup data center. On the one hand, it maintained the on-site integrity of the first data center, which is very beneficial for analyzing the causes of abnormal downtime. On the other hand, it is convenient to repair consumers after finding the causes, avoiding consumers falling into the trap of infinite restarts.

[0107] 3) In the data center system described in the present application, the first consumer of the first data center and the second consumer of the second data center are both used to execute the consumer disaster recovery method of the data center. When the method detects that the number of consumers consuming messages from the first data center (or the second data center) does not meet the configured number, the target consumer in the second data center (or the first data center) consumes the messages from the first data center (or the second data center), thereby achieving consumer disaster recovery and avoiding the problem of message accumulation in the first data center (or the second data center) due to the lack of consumers, thereby ensuring that the message processing reliability of the data center system is high. In addition, if the number of consumers consuming messages from the first data center (or the second data center) does not meet the configured number, it means that some consumers in the first data center (or the second data center) have experienced a downtime anomaly. The present application performs a failover after the consumer in the first data center (or the second data center) goes down, and transfers the tasks that the downtime consumer should handle to the consumer in the backup data center. On the one hand, the on-site integrity of the first data center (or the second data center) is maintained, which is very beneficial for analyzing the cause of the abnormal downtime. On the other hand, it is convenient to repair the consumer after finding the cause, avoiding the consumer from falling into the trap of infinite restart, thereby ensuring the high system security performance of the data center system.

[0108] The above description is merely a preferred embodiment of the present application and is not intended to limit the present application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.

Claims

1. A data center consumer disaster recovery method, the method being applied to target consumers, characterized in that: The method comprises: In the case of receiving multiple first heartbeat messages, determining a target quantity according to the multiple first heartbeat messages and the first predetermined information, wherein the first heartbeat message is a heartbeat message sent by each first consumer, the first heartbeat message includes identification information of the first consumer, the first consumer is a consumer working normally in the first data center, the first predetermined information is information representing the number of third consumers, the third consumer is a second consumer that consumes messages in the first data center, the second consumer is a consumer in the second data center, the target consumer is one of the multiple second consumers, the target quantity is the total number of the first consumers and the third consumers, the first consumer and the second consumer consume the same type of messages and have the same consumption logic, and the second consumer can consume information both in the first data center and in the second data center; When the target quantity is less than the configured quantity, the target consumer is controlled to consume messages in the first data center, and a second predetermined information is sent to the backup message middleware, where the backup message middleware is the message middleware of the second data center. The second predetermined information is information representing that the target consumer consumes messages in the first data center.

2. The method according to claim 1, characterized in that In the case where multiple first heartbeat information is received, determining a target quantity according to the multiple first heartbeat information and the first predetermined information includes: When receiving a plurality of the first heartbeat information, starting a random time delay; When the delay duration reaches the random duration, determining the number of the first consumers according to the plurality of first heartbeat information; The target quantity is determined according to the quantity of the first consumers and the quantity of the third consumers.

3. The method according to claim 1, characterized in that Controlling the target consumer to consume messages in the first data center includes: Controlling the communication connection between the target consumer and the main message middleware, where the main message middleware is the message middleware of the first data center; Control the target consumer to read messages from the main message middleware.

4. The method according to claim 3, characterized in that The method further comprises: When the target consumer operates normally, generating second heartbeat information, wherein the second heartbeat information includes identification information of the target consumer; The target consumer is controlled to send the second heartbeat information to the main message middleware or a third-party device, where the third-party device is a device that communicates with each of the first consumers.

5. The method according to claim 4, characterized in that Before determining the target quantity based on the plurality of first heartbeat information and the first predetermined information, the method further includes: obtaining the first predetermined information from the backup message middleware, The first heartbeat information is sent by the backup message middleware in a broadcasting manner when it receives the first heartbeat information sent by each first consumer, or is sent by a third-party device when it receives the first heartbeat information sent by each first consumer.

6. The method according to any one of claims 1 to 5, characterized in that In a case where the target quantity is greater than or equal to the configured quantity, the method further includes: When the target quantity is greater than the configured quantity and the target consumer consumes messages in the first data center, controlling the target consumer to stop consuming messages in the first data center and sending third predetermined information to the backup message middleware, where the third predetermined information is information indicating that the target consumer does not consume messages in the first data center; When the target quantity is equal to the configured quantity, the target consumer is controlled to maintain a current consumption state, where the current consumption state is a state of consuming messages in the first data center or a state of not consuming messages in the first data center.

7. A consumer disaster recovery device in a data center, the device being applied to a target consumer, characterized in that: The device comprises: a determination unit for determining a target quantity based on the plurality of first heartbeat messages and first predetermined information when receiving a plurality of first heartbeat messages, wherein the first heartbeat information is heartbeat information sent by each first consumer, the first heartbeat information includes identification information of the first consumer, the first consumer is a consumer operating normally in the first data center, the first predetermined information is information representing the number of third consumers, the third consumer is a second consumer consuming messages in the first data center, the second consumer is a consumer in the second data center, the target consumer is one of the plurality of second consumers, the target quantity is the total number of the first consumers and the third consumers, the first consumer and the second consumer consume the same type of messages and have the same consumption logic, and the second consumer can consume information in both the first data center and the second data center; A first control unit is used to control the target consumer to consume messages in the first data center when the target quantity is less than the configured quantity, and send second predetermined information to the backup message middleware, where the backup message middleware is the message middleware of the second data center, and the second predetermined information is information representing that the target consumer consumes messages in the first data center.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 6.

9. A processor, characterized in that: The processor is configured to run a program, wherein the program executes the method according to any one of claims 1 to 6 when running.

10. A data center system, characterized in that: include: A first data center includes a main message middleware and a plurality of first consumers, wherein the plurality of first consumers are used to read messages from the main message middleware; A second data center includes a backup message middleware and a plurality of second consumers, wherein the plurality of second consumers are used to read messages from the backup message middleware; The first consumer and the second consumer respectively include: one or more processors, a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of claims 1 to 6.

Citation Information

Patent Citations

  • Data center disaster tolerance method, device and equipment and storage medium

    CN112506702A

  • KR20190139006A