A message middleware disaster recovery processing method, device and equipment
By deploying message middleware clusters in multiple computer rooms and giving priority to local message servers, the problem of long access times for Kafka clients was solved, more efficient disaster recovery was achieved, and service availability and stability were ensured.
Patent Information
- Application Number
- CN202310267043.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-16
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2043-03-16
AI Technical Summary
In Kafka deployed in multiple data centers, network access between remote data centers takes a long time, which causes timeouts when Kafka clients access services, affecting service availability and stability.
Deploy message middleware clusters in the first and second computer rooms respectively, and determine the primary and secondary replicas of the same partition in each computer room. Give priority to using the local message server for message production and consumption, and switch replicas across computer rooms for disaster recovery when an exception occurs.
The local-priority message path design reduces the time spent on cross-data center access, improves the efficiency of disaster recovery processing, and ensures the availability and stability of services.
Smart Images

Figure CN116185667B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the technical field of message middleware, and in particular to a message middleware disaster recovery processing method, apparatus, and device. Background Art
[0002] In the internet industry, message middleware is often used to process large amounts of highly concurrent data. For example, Kafka, a distributed, multi-replicated message middleware that supports massive data processing, is widely used by many companies. As a core component connecting upstream and downstream applications, Kafka's disaster recovery capabilities need to be enhanced to ensure service availability.
[0003] In order to enhance disaster recovery capabilities, the common practice is to deploy services in multiple computer rooms. By deploying services in multiple computer rooms, when the services in the local computer room go down as a whole, the services in the neighboring computer room can continue to provide services.
[0004] The Kafka server is deployed in multiple computer rooms, and the Kafka client is also deployed in multiple computer rooms. The producers and consumers corresponding to the same topic in multiple computer rooms are the same. Producers and consumers can access the parts of the entire Kafka cluster distributed in different computer rooms to send and receive messages.
[0005] A core issue facing multi-data center deployment is that network access between remote data centers is time-consuming. For example, timeouts often occur when Kafka clients access Kafka services. Therefore, a more efficient message middleware disaster recovery solution is needed. Summary of the Invention
[0006] One or more embodiments of this specification provide a message middleware disaster recovery processing method, device, equipment and storage medium to solve the following technical problems: A core problem faced by multi-computer room deployment is that network access between remote computer rooms is time-consuming. For example, when the Kafka client accesses the Kafka service, timeouts often occur. Based on this, a more efficient message middleware disaster recovery processing solution is needed.
[0007] To solve the above technical problems, one or more embodiments of this specification are implemented as follows:
[0008] One or more embodiments of this specification provide a message middleware disaster recovery method, in which a message middleware cluster, a message production client, and a message consumption client are deployed in a first computer room and a second computer room, respectively. Each message middleware cluster includes multiple message servers. The method includes:
[0009] The message production client in the first computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the first computer room. The message production client in the second computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the second computer room.
[0010] The message consumption client in the first computer room consumes the in-computer room messages obtained from the primary replica of the first partition in the first computer room; the message consumption client in the second computer room consumes the in-computer room messages obtained from the primary replica of the first partition in the second computer room;
[0011] The message production client in the first computer room, if the corresponding message server in the first computer room is unavailable, produces a cross-computer room message and sends it to the primary replica of the first partition in the second computer room;
[0012] The message consumption client in the second computer room consumes the cross-computer room messages obtained from the primary copy of the first partition in the second computer room.
[0013] One or more embodiments of this specification provide a message middleware disaster recovery device, wherein a message middleware cluster, a message production client, and a message consumption client are deployed in a first computer room and a second computer room, respectively. Each message middleware cluster includes multiple message servers. The device includes:
[0014] The message production and sending module of the message production client belonging to the first computer room determines one or more message servers where the primary replica of the first partition is located in the computer room where the message is produced, and under normal circumstances, produces messages in the computer room and sends them to the one or more message servers in the first computer room; the message production and sending module of the message production client belonging to the second computer room determines one or more message servers where the primary replica of the first partition is located in the computer room where the message is produced, and under normal circumstances, produces messages in the computer room and sends them to the one or more message servers in the second computer room;
[0015] The message convergence consumption module of the message consumption client belonging to the first computer room consumes the computer room-use messages obtained from the primary replica of the first partition in the first computer room; the message convergence consumption module of the message consumption client belonging to the second computer room consumes the computer room-use messages obtained from the primary replica of the first partition in the second computer room;
[0016] A cross-computer room sending module of the message production client in the first computer room generates a cross-computer room message and sends it to the primary replica of the first partition in the second computer room if the corresponding message server in the first computer room is unavailable;
[0017] The message auxiliary consumption module of the message consumption client belonging to the second computer room consumes the cross-computer room messages obtained from the primary copy of the first partition in the second computer room.
[0018] One or more embodiments of this specification provide a message middleware disaster recovery device, wherein a message middleware cluster, a message production client, and a message consumption client are deployed in a first computer room and a second computer room, respectively. Each message middleware cluster includes multiple message servers. The device includes:
[0019] at least one processor; and,
[0020] a memory communicatively connected to the at least one processor; wherein,
[0021] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
[0022] A message production client in the first computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the first computer room. A message production client in the second computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the second computer room.
[0023] A message consumption client in the first computer room consumes computer room-use messages obtained from the primary replica of the first partition in the first computer room; a message consumption client in the second computer room consumes computer room-use messages obtained from the primary replica of the first partition in the second computer room;
[0024] A message production client for the first computer room. If the corresponding message server of the first computer room is unavailable, it produces cross-computer room messages and sends them to the primary replica of the first partition in the second computer room.
[0025] It is a message consumption client of the second computer room, consuming cross-computer room messages obtained from the primary copy of the first partition in the second computer room.
[0026] One or more embodiments of this specification provide a non-volatile computer storage medium storing computer-executable instructions. A message middleware cluster, a message production client, and a message consumption client are deployed in a first computer room and a second computer room, respectively. Each message middleware cluster includes multiple message servers. The computer-executable instructions are configured to:
[0027] A message production client in the first computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the first computer room. A message production client in the second computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the second computer room.
[0028] A message consumption client in the first computer room consumes computer room-use messages obtained from the primary replica of the first partition in the first computer room; a message consumption client in the second computer room consumes computer room-use messages obtained from the primary replica of the first partition in the second computer room;
[0029] A message production client for the first computer room. If the corresponding message server of the first computer room is unavailable, it produces cross-computer room messages and sends them to the primary replica of the first partition in the second computer room.
[0030] It is a message consumption client of the second computer room, consuming cross-computer room messages obtained from the primary copy of the first partition in the second computer room.
[0031] At least one of the above-mentioned technical solutions adopted in one or more embodiments of this specification can achieve the following beneficial effects: a set of message middleware clusters are deployed in different computer rooms respectively, then for the same data partition, there are master copies in different computer rooms. Based on this, by actively controlling the message path, local priority is achieved, and the message traffic is converged as much as possible in the local computer room, avoiding the large-scale cross-computer room access to the master copy in traditional solutions. Under normal circumstances, the message server of the local computer room is used first, and the message consumption client of the local computer room is given priority to consume messages, which reduces access time. When the message server of a computer room is unavailable, the message server or message consumption client of other computer rooms is used instead to forward and consume, thereby achieving a more efficient disaster recovery effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0033] Figure 1 This is a diagram of a common message middleware cluster deployment and message interaction solution;
[0034] Figure 2 A schematic diagram of a message middleware disaster recovery method provided in one or more embodiments of this specification;
[0035] Figure 3 One or more embodiments of this specification provide Figure 2 An implementation scheme of , a schematic diagram of message interaction under normal circumstances;
[0036] Figure 4 One or more embodiments of this specification provide Figure 2 An implementation scheme, a message interaction diagram when the message server in one of the computer rooms is unavailable;
[0037] Figure 5 One or more embodiments of this specification provide Figure 2 An implementation scheme, a message interaction diagram when a message consumption client in one of the computer rooms is unavailable;
[0038] Figure 6 One or more embodiments of this specification provide Figure 2 An implementation scheme, a message interaction diagram when a message production client in one of the computer rooms is unavailable;
[0039] Figure 7 A schematic diagram of the structure of a message middleware disaster recovery processing device provided in one or more embodiments of this specification;
[0040] Figure 8 A schematic diagram of the structure of a message middleware disaster recovery processing device provided in one or more embodiments of this specification. DETAILED DESCRIPTION
[0041] The embodiments of this specification provide a message middleware disaster recovery processing method, apparatus, device, and storage medium.
[0042] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0043] In order to facilitate understanding of the advantages of the solution of this application, taking the message middleware Kafka as an example, the general solution is explained in more detail, involving the Kafka server, Kafka client, topics, and partitions. The Kafka client is divided into Kafka producers and Kafka consumers, which are usually nested in the application.
[0044] A Kafka server is also called a broker. A Kafka server machine is called a broker, and a Kafka server cluster consists of multiple brokers. Brokers receive messages from producers, store them in the file system, and return them to consumers when they consume them.
[0045] The Kafka producer, also known as Producer, is responsible for producing messages and sending them to the Kafka server.
[0046] Kafka consumer, also known as Consumer, is responsible for consuming messages from the Kafka server.
[0047] A topic is also called a topic, which can be understood as a queue. A topic classifies messages, and producers and consumers are facing the same topic.
[0048] Partitions are also called partitions. To achieve scalability and improve concurrency, a very large topic can be distributed to multiple brokers. A topic can be divided into multiple partitions. The data of the same topic in different partitions is not repeated. Each partition is an ordered queue, which is represented by a folder.
[0049] In a typical multi-data center disaster recovery solution, the Kafka servers in multiple data centers form a cluster, and all data is backed up in two data centers. Kafka clients access topic partition data randomly. If the primary copy of the topic partition is in the local data center, the access time will be shorter. If the primary copy is in a remote data center, the access time will be longer. Although the disaster recovery capability is enhanced, this increase in time will affect the availability and stability of the service.
[0050] Intuitively, see Figure 1 , Figure 1 This is a diagram of a common message middleware cluster deployment and message interaction solution. Figure 1 In the example, when the Producer in Data Center 1 sends the message of Topic 1 to partition p2, since the primary copy of p2 (i.e., p2-master) is in Data Center 2, the message needs to be sent to Broker 3 in Data Center 2. Similarly, when the Consumer in Data Center 1 consumes the message of partition p2 of Topic 1, it also needs to access Broker 3 in Data Center 2. The long physical distance between the data centers increases the access time and the risk of access timeout.
[0051] In view of this, the solution of this application can solve the problem of high access time between clients and servers in Kafka multi-data center disaster recovery scenarios by optimizing the deployment relationship between clusters and data centers and adopting a local priority mode. The solution of this application is described in detail below.
[0052] Figure 2 This is a flowchart of a message middleware disaster recovery method provided for one or more embodiments of this specification. A message middleware cluster, as well as a message production client and a message consumption client, are deployed in a first computer room and a second computer room, respectively. Each message middleware cluster includes multiple message servers, and the message middleware can be a distributed, multi-copy message middleware.
[0053] It should be noted that the following examples are based on two data centers. Following the same principles, the solution can be expanded to multiple data centers. In the Kafka scenario, the message production client is the Producer, the message consumption client is the Consumer, and the message server is the Broker. Other message middleware similar to Kafka can also implement this solution.
[0054] Figure 2 The process in includes the following steps:
[0055] S202: The message production client of the first computer room determines one or more message servers where the primary copy of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers of the first computer room; the message production client of the second computer room determines one or more message servers where the primary copy of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers of the second computer room.
[0056] In one or more embodiments of the present specification, for the same partition, there are master copies and slave copies. When the master copy is available, the master copy is used first. In the traditional solution, there is only one master copy. However, in the solution of the present application, since a set of middleware clusters are deployed in different computer rooms, there are multiple master copies for the same partition. For example, each computer room has a master copy of the same partition (in order to avoid conflicts between master copies in the computer room as much as possible, this situation can be mainly considered). The master copies will be located on a message server in the corresponding computer room. For the sake of convenience, the same partition is called the first partition. The first partition in the first computer room and the first partition in the second computer room are the same partition, but they are distributed in different computer rooms. The partition here, in the scenario of Kafka, can refer to the partition divided by the topic. Of course, similar to this method of partitioning based on the message queue, a part of the data divided by other rules from the global data can also be used as a partition. The partitioning rules are diverse, such as partitioning based on distributed data tables, partitioning based on hash maps, partitioning based on disk storage locations, and so on.
[0057] In one or more embodiments of this specification, the first partition refers to a partition for storing messages currently to be produced and forwarded. Each computer room contains one or more message production clients and one or more message consumption clients. A correspondence between partitions and message production clients and message consumption clients can be established. Then, the message production client only sends messages to be consumed to its corresponding partition, and the message consumption client only obtains the messages produced by its corresponding message production client from its corresponding partition. Taking the Kafka scenario as an example, there is a correspondence between Topic and Producer and Consumer, and the partition is divided from the Topic, so the partition also follows this correspondence. The master copy of the first partition has only one in the first computer room and the second computer room respectively, and the master copy has corresponding slave copies in its own computer room and / or other computer rooms.
[0058] When the first and second computer rooms are located remotely from each other, the cost of cross-computer room communication increases, which is particularly advantageous for the solution of this application. From the perspective of either computer room, that computer room is considered a local computer room, while the other computer room is considered a remote computer room. Normal operation means that within the computer room, the corresponding message production clients, message consumption clients, and message servers are in an available state, and the master replica currently in that computer room is in an available state.
[0059] S204: The message consumption client of the first computer room consumes the in-computer room messages obtained from the primary copy of the first partition in the first computer room; the message consumption client of the second computer room consumes the in-computer room messages obtained from the primary copy of the first partition in the second computer room.
[0060] The message here refers to the message that needs to be consumed and is the carrier of data. The message production client encapsulates the data into a message and sends it to the corresponding message server. The corresponding message consumption client can pull the message from the message server (responsible for message forwarding) and then parse it locally into the required data.
[0061] Under normal circumstances, step S204 is executed, and the message production client and message consumption client in the computer room access the master copy in the computer room to complete the production, forwarding and consumption of messages. There is no need to interact with messages across computer rooms, and the messages in this computer room are converged within the local computer room for processing.
[0062] S206: If the corresponding message server of the first computer room is unavailable, the message production client of the first computer room produces a cross-computer room message and sends it to the master copy of the first partition in the second computer room.
[0063] In one or more embodiments of this specification, the corresponding message server in the first computer room may be temporarily unavailable due to a crash, offline, or reboot. This constitutes an abnormal situation, and the corresponding message cannot be received or forwarded within the first computer room, causing the disaster recovery mechanism to kick in. In this case, if the message production client in the first computer room continues to produce messages, cross-computer room interaction will occur to avoid a backlog of messages that cannot be consumed, and the messages will be placed on the primary replica of the first partition in the second computer room. Under normal circumstances, the messages will be placed on the primary replica of the first partition in the first computer room.
[0064] S208: The message consumption client of the second computer room consumes the cross-computer room message obtained from the primary copy of the first partition in the second computer room.
[0065] In one or more embodiments of the present specification, in the abnormal case of step S206, step S208 is further executed. Although the message consumption client in the first computer room can also be used at this time, in order to avoid a second cross-computer room interaction, the message consumption client in the second computer room is used to consume the cross-computer room message in the computer room. The message consumption client in the first computer room can be temporarily idle and wait for the message server in the first computer room to resume the available state before converging subsequent messages back to their respective computer rooms.
[0066] Steps S206 and S208 are described by taking an exception occurring in the first computer room as an example. If a similar exception occurs in the second computer room, similar processing can be performed using the corresponding available terminal in the first computer room.
[0067] pass Figure 2The method uses a message middleware cluster deployed in different computer rooms. For the same data partition, there are master copies in different computer rooms. Based on this, by actively controlling the message path, local priority is achieved, and the message traffic is converged to the local computer room as much as possible, avoiding the traditional solution of accessing the master copy across computer rooms in large quantities. Under normal circumstances, the message server of the local computer room is used first, and the message consumption client of the local computer room is given priority to consume messages, which reduces access time. When the message server of a computer room is unavailable, the message server or message consumption client of other computer rooms is used instead to forward and consume, thereby achieving a more efficient disaster recovery effect.
[0068] based on Figure 2 This specification also provides some specific implementation plans and extension plans of the method, which will be described below.
[0069] In one or more embodiments of the present specification, in actual applications, some message middleware may use topics to classify messages, such as Kafka, Rocket MQ, and Rabbit MQ. In this case, the above partitions are obtained by dividing the topics again. When exchanging messages in a computer room, it is necessary to determine the master copy of the same partition of the same topic in the different computer rooms where they are located. Specifically, for example, the same topic is determined in the different computer rooms where they are located (for the sake of convenience of description, also referred to as a designated topic), and the target partitions corresponding to the respective target partitions are determined in the multiple partitions of the same topic. Among the target partitions on the multiple message servers in the different computer rooms where they are located, the target partition that is in a dominant position is determined as the master copy of the same partition (i.e., the first partition) of the same topic. From the perspective of the first computer room, it includes: determining the designated topic in the computer room where it is located, determining the first partition that is currently the target partition among the multiple partitions of the designated topic, wherein the first partition in the computer room where it is located is currently used as the target partition in different computer rooms, and determining the target partition that is in a dominant position among the target partitions on the multiple message servers in the computer room where it is located as the master copy of the first partition of the designated topic.
[0070] Intuitively, see Figure 3 , Figure 3 One or more embodiments of this specification provide Figure 2 An implementation scheme, a message interaction diagram under normal circumstances, in the Kafka scenario, exemplarily, shows two computer rooms, computer room 1 serves as the first computer room mentioned above, and computer room 2 serves as the second computer room mentioned above. Exemplarily, two Brokers are shown in each computer room, two Topics are shown in each Broker, and two Partitions are shown in each Topic.
[0071] As you can see, in Figure 3 In the multi-computer room scenario, each computer room is deployed with its own cluster and supporting clients. It is assumed that the message production clients in different computer rooms are the same. The Producers in Computer Room 1 and Computer Room 2 can send messages to the same Topic, and the consumption effects of Computer Room 1 and Computer Room 2 are the same. Through deployment, the Kafka cluster in each computer room will be discovered by the Producers and Consumers in all computer rooms. For Producers, the expectation is that the traffic converges within the computer room (lower time consumption) and the availability of message sending. For Consumers, the expectation is that the traffic converges within the computer room (sending and receiving in the same computer room, lower time consumption) and that there are people consuming messages.
[0072] Through different cluster deployment methods, Figure 3 and Figure 1 In comparison, the status of some partitions has changed, so that the master copy of the same partition of the same topic is available in each computer room. For example, for the master copy p2-master of the p2 partition of Topic1, it can be seen that there is p2-master on Broker2 in Computer Room 1 and p2-master on Broker3 in Computer Room 2. The p2 partition can be used as the first partition mentioned above. The following embodiments mainly use the p2 partition as the first partition and Topic1 as the designated topic as an example. Of course, the p1 partition, Topic2 and even more partitions and topics can also be handled similarly. Different partitions or topics may correspond to different clients, and the corresponding relationship between them can be determined in advance.
[0073] For the same computer room, the master copies of multiple partitions of the same topic in the computer room are located on different message servers in the computer room to prevent the master copies of multiple partitions in the current computer room from being unavailable due to the unavailability of one message server. Each of the multiple partitions also has a master copy in at least one other computer room. The master copy in the same computer room has at least one slave copy, and the master copy and the slave copy are located on different message servers in the computer room. In this way, as long as all message servers in the computer room are unavailable (which will cause the master copy on it to be unavailable), priority will be given to switching to the slave copy of the available message server in the computer room, thus avoiding cross-computer room message interaction. For example, for computer room 1, there is one slave copy (i.e. p2) of the p2 partition of Topic1, which is located on Broker1, avoiding being on the same Broker as the p2-master (on Broker2) in computer room 1. There is also one slave copy, which is located on Broker4 in computer room 2, avoiding being on the same Broker as the p2-master (on Broker3) in computer room 2.
[0074] exist Figure 3 This is a normal situation. The Producer in this computer room will only send messages to the Broker in this computer room. Similarly, the Consumer in this computer room will only consume messages received by the Broker in this computer room. Messages in the same computer room will converge in the same computer room, thereby reducing the time it takes for the Kafka client to access the Kafka server.
[0075] Assume that the Producer and Consumer shown correspond to Topic 1, specifically to the P2 partition of Topic 1. As can be seen, for Data Center 1, the Producer in Data Center 1 produces messages and sends them to the p2-master of Topic 1 on Broker 2. The Consumer in Data Center 1 obtains and consumes messages from the p2-master of Topic 1 on Broker 2. These messages are converged within Data Center 1. Similarly, for Data Center 2, the Producer in Data Center 2 produces messages and sends them to the p2-master of Topic 1 on Broker 3. The Consumer in Data Center 2 obtains and consumes messages from the p2-master of Topic 1 on Broker 3. These messages are converged within Data Center 2. This process does not generate unnecessary cross-data Center message interactions.
[0076] Figure 2 The process in also involves the situation where the message server is unavailable. Accordingly, one or more embodiments of this specification also provide Figure 2An implementation scheme is a message interaction diagram when the message server in one of the computer rooms is unavailable, as shown in FIG. Figure 4 shown.
[0077] exist Figure 4 In the figure, all the Brokers originally shown in computer room 1 are unavailable, and the Producer in computer room 1 may still be producing messages. In order to allow these consumers to have a consumption path, the Producer in computer room 1 is actively controlled to send the produced messages to the Broker in computer room 2 (specifically, the p2-master of Topic 1 of Broker 3). The sent messages are consumed by the Consumer in computer room 2 in this computer room. Since the Consumers in different computer rooms are the same, the messages in computer room 1 can be consumed by the Consumer in computer room 2. The Consumer in computer room 1 will not consume the messages from the p2-master in computer room 2 across computer rooms to avoid further increase in cross-computer room overhead.
[0078] In addition to exceptions on the message server, message production and consumption clients may also become unavailable. Taking the topic-based scenario as an example, we will continue to use the idea of local priority and message convergence to illustrate this.
[0079] In one or more embodiments of the present specification, if the message consumption client of the second computer room is unavailable, the message consumption client of the first computer room obtains the in-computer room message generated by the message generation client of the first computer room from the master copy of the first partition of the designated topic in the first computer room, and consumes the in-computer room message; not only that, in this abnormal situation, since the messages generated by the message production client of the second computer room may be accumulated in this computer room, the message consumption client of the first computer room also consumes the messages on behalf of the first computer room across computer rooms, including: the message consumption client of the first computer room also obtains the message generated by the message generation client of the second computer room from the master copy of the first partition of the designated topic in the second computer room, and consumes the messages.
[0080] Similarly, if the message consumption client in the first computer room is unavailable and the second computer room is normal, the message consumption client in the second computer room can consume the messages produced in the first computer room across computer rooms.
[0081] Intuitively, see Figure 5 , Figure 5 One or more embodiments of this specification provide Figure 2 An implementation scheme is shown, which is a message interaction diagram when a message consumption client in one of the computer rooms is unavailable.
[0082] exist Figure 5In the example, when all consumers originally displayed in Data Center 2 become unavailable, Data Center 2's producers are still producing and sending messages to the brokers in Data Center 2. If they don't consume messages, a message backlog will occur. In serious cases, the entire broker cluster may become unavailable. Therefore, active control is implemented to allow Data Center 1's consumers to consume Data Center 2's messages simultaneously with Data Center 1's messages. Since the consumers in different Data Centers are the same, Data Center 1's consumers can still consume Data Center 2's messages. A similar process can be applied when Data Center 1's consumers become unavailable.
[0083] In one or more embodiments of the present specification, if the corresponding message production client of the first computer room is unavailable, the message production client of the second computer room still produces messages as messages for use within the computer room, and sends them to the master copy of the first partition of the designated topic in the second computer room, but does not send them to the first computer room. In this abnormal situation, since the message production client in the second computer room is available and sufficient to process the messages in the second computer room, there is still no cross-computer room interaction, and the message consumption client of the first computer room can temporarily remain idle, which may include: if the corresponding message production client of the first computer room is unavailable, the message consumption client of the second computer room obtains the messages for use within the computer room generated by the message production client of the second computer room from the master copy of the first partition of the designated topic in the second computer room, and consumes the messages for use within the computer room; the message consumption client of the first computer room does not consume the messages generated by the message production client of the second computer room across computer rooms.
[0084] Intuitively, see Figure 6 , Figure 6 One or more embodiments of this specification provide Figure 2 An implementation scheme is provided, which is a message interaction diagram when a message production client in one of the computer rooms is unavailable.
[0085] exist Figure 6 In the example, when all producers in Data Center 1 are unavailable, since this data center has no message source, its brokers do not need to forward messages, and its consumers do not need to consume messages. Data Center 2, on the other hand, continues to produce, forward, and consume messages as normal. A similar approach can be applied when the producers in Data Center 2 are unavailable.
[0086] It can be seen from this that Figures 3 to 6In this example, multiple Kafka clusters are deployed in multiple data centers. Under normal circumstances, the local data center's brokers and consumers are prioritized for message consumption, converging traffic within the local data center and reducing access time. If a broker or consumer in one data center experiences an anomaly, brokers or consumers in other data centers can take over, thus achieving disaster recovery. Furthermore, if a producer in one data center experiences an anomaly, consumption capacity in that data center is temporarily idled while message convergence in other data centers is maintained. Compared to traditional multi-data center disaster recovery, this approach preserves disaster recovery capabilities while reducing access time.
[0087] In addition, it should be noted that Figures 3 to 6 In the example, it is also possible to divide only the partitions without dividing the topics. This may facilitate the implementation of other message middlewares other than topic-based message middleware such as Kafka. However, dividing the topics also brings unique advantages to the solution of this application, including: further breaking up and granularizing the scale of the master copies of the partitions, so that the relatively smaller-scale master copies are more evenly distributed in the computer room (especially the solution of this application increases the total number of master copies, so this new demand is brought about). In this way, when several brokers among the multiple brokers in the computer room, or part of a single broker, are unavailable, the impact on the global master copy is smaller, the disaster recovery is more robust, and it is also convenient to continue to converge the messages in the computer room.
[0088] Based on the same idea, one or more embodiments of this specification also provide devices and apparatuses corresponding to the above methods, such as Figure 7 、 Figure 8 The apparatus and device can accordingly execute the above method and related optional solutions.
[0089] Figure 7 A schematic diagram of the structure of a message middleware disaster recovery processing device provided for one or more embodiments of this specification includes a message middleware cluster, a message production client, and a message consumption client deployed in a first computer room and a second computer room, respectively. Each message middleware cluster includes multiple message servers. The device includes:
[0090] The message production and sending module 702 of the message production client belonging to the first computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages used in the computer room and sends them to the one or more message servers in the first computer room. The message production and sending module 704 of the message production client belonging to the second computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages used in the computer room and sends them to the one or more message servers in the second computer room.
[0091] The message convergence consumption module 706 of the message consumption client belonging to the first computer room consumes the computer room-use messages obtained from the primary replica of the first partition in the first computer room; the message convergence consumption module 708 of the message consumption client belonging to the second computer room consumes the computer room-use messages obtained from the primary replica of the first partition in the second computer room;
[0092] The cross-computer room sending module 710 of the message production client belonging to the first computer room generates a cross-computer room message and sends it to the master copy of the first partition in the second computer room if the corresponding message server of the first computer room is unavailable;
[0093] The message auxiliary consumption module 712 of the message consumption client belonging to the second computer room consumes the cross-computer room messages obtained from the primary copy of the first partition in the second computer room.
[0094] Optionally, the message production sending module 702 or 704 of the message production client belonging to the first computer room or the second computer room determines the master copy of the first partition of the specified topic in the computer room where it is located, and the specified topic corresponding to the first partition determined by the message production clients in different computer rooms is the same topic.
[0095] Optionally, the designated topics are located on multiple message servers in the corresponding computer room;
[0096] The message production and sending module 702 or 704 of the message production client belonging to the first computer room or the second computer room determines a designated topic in the computer room where the client is located;
[0097] Determine a first partition currently serving as a target partition among the multiple partitions of the designated topic, wherein each of the different computer rooms currently serves as the target partition as the first partition in the computer room where the computer room is located;
[0098] Among the target partitions on multiple message servers in the computer room where the computer room is located, a target partition that is in a dominant position is determined as the primary copy of the first partition of the designated topic.
[0099] Optionally, for the same computer room, the master copies of multiple partitions of a specified topic in the computer room are located on different message servers in the computer room; and each of the multiple partitions also has a master copy in at least one other computer room.
[0100] Optionally, it also includes:
[0101] The cross-computer room consumption module 714 of the message consumption client belonging to the first computer room obtains the in-computer room messages generated by the message generation client of the first computer room from the master copy of the first partition of the specified topic of the first computer room, and consumes the in-computer room messages, and also obtains the messages generated by the message generation client of the second computer room from the master copy of the first partition of the specified topic of the second computer room, and consumes the messages.
[0102] Optionally, it also includes:
[0103] The cross-computer room sending module 716 of the message production client belonging to the second computer room will still produce messages as messages for internal use in the computer room if the corresponding message production client of the first computer room is unavailable, and send them to the master copy of the first partition of the designated topic in the second computer room, but will not send them to the first computer room.
[0104] Optionally, if the corresponding message production client of the first computer room is unavailable, the device further includes:
[0105] The message convergence and consumption module 708 of the message consumption client belonging to the second computer room obtains the in-computer room message generated by the message generation client of the second computer room from the master copy of the first partition of the designated topic in the second computer room, and consumes the in-computer room message;
[0106] The message convergence and consumption module 706 of the message consumption client of the first computer room does not consume the messages produced by the message production client of the second computer room across computer rooms.
[0107] Optionally, the first computer room and the second computer room are remote computer rooms;
[0108] The message middleware is a distributed multi-copy message middleware, and the topic is a queue obtained by message classification.
[0109] Figure 8A schematic diagram of the structure of a message middleware disaster recovery processing device provided for one or more embodiments of this specification includes a message middleware cluster, a message production client, and a message consumption client deployed in a first computer room and a second computer room, respectively. Each message middleware cluster includes multiple message servers. The device includes:
[0110] at least one processor; and,
[0111] a memory communicatively connected to the at least one processor; wherein,
[0112] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
[0113] A message production client in the first computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the first computer room. A message production client in the second computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the second computer room.
[0114] A message consumption client in the first computer room consumes computer room-use messages obtained from the primary replica of the first partition in the first computer room; a message consumption client in the second computer room consumes computer room-use messages obtained from the primary replica of the first partition in the second computer room;
[0115] A message production client for the first computer room. If the corresponding message server of the first computer room is unavailable, it produces cross-computer room messages and sends them to the primary replica of the first partition in the second computer room.
[0116] It is a message consumption client of the second computer room, consuming cross-computer room messages obtained from the primary copy of the first partition in the second computer room.
[0117] Based on the same idea, one or more embodiments of this specification further provide a non-volatile computer storage medium storing computer-executable instructions. A message middleware cluster, a message production client, and a message consumption client are deployed in a first computer room and a second computer room, respectively. Each message middleware cluster includes multiple message servers. The computer-executable instructions are configured as follows:
[0118] A message production client in the first computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the first computer room. A message production client in the second computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the second computer room.
[0119] A message consumption client in the first computer room consumes computer room-use messages obtained from the primary replica of the first partition in the first computer room; a message consumption client in the second computer room consumes computer room-use messages obtained from the primary replica of the first partition in the second computer room;
[0120] A message production client for the first computer room. If the corresponding message server of the first computer room is unavailable, it produces cross-computer room messages and sends them to the primary replica of the first partition in the second computer room.
[0121] It is a message consumption client of the second computer room, consuming cross-computer room messages obtained from the primary copy of the first partition in the second computer room.
[0122] In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD through their own programming, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.
[0123] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the means for implementing various functions included therein can also be considered as structures within the hardware component. Or even, the means for implementing various functions can be considered as both a software module implementing the method and a structure within the hardware component.
[0124] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0125] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0126] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, the embodiments of this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0127] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0128] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0129] This specification may be described in the general context of computer-executable instructions, such as program modules, executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media, including storage devices.
[0130] The various embodiments in this specification are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from the other embodiments. In particular, the device, apparatus, and non-volatile computer storage medium embodiments are generally similar to the method embodiments, so their descriptions are relatively simplified. For relevant details, refer to the descriptions of the method embodiments.
[0131] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0132] The foregoing description is merely one or more embodiments of this specification and is not intended to limit this specification. It will be apparent to those skilled in the art that various modifications and variations may be made to one or more embodiments of this specification. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of one or more embodiments of this specification are intended to be within the scope of the claims of this specification.
Claims
1. A message middleware disaster recovery method, wherein a message middleware cluster, a message production client, and a message consumption client are deployed in a first computer room and a second computer room, respectively. Each message middleware cluster includes multiple message servers. The method comprises: The message production client in the first computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the first computer room. The message production client in the second computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the second computer room. The message consumption client in the first computer room consumes the in-computer room messages obtained from the primary replica of the first partition in the first computer room; the message consumption client in the second computer room consumes the in-computer room messages obtained from the primary replica of the first partition in the second computer room; The message production client in the first computer room, if the corresponding message server in the first computer room is unavailable, produces a cross-computer room message and sends it to the primary replica of the first partition in the second computer room; The message consumption client in the second computer room consumes the cross-computer room messages obtained from the primary copy of the first partition in the second computer room.
2. The method according to claim 1, wherein determining the primary replica of the first partition in the computer room where the first partition is located specifically comprises: The master copy of the first partition of the specified topic is determined in the computer room where the computer room is located, and the specified topic corresponding to the first partition determined by the message production clients in different computer rooms is the same topic.
3. The method according to claim 2, wherein the designated topics are located on multiple message servers in the corresponding computer room; Determining the primary replica of the first partition of the specified topic in the computer room where the user is located specifically includes: Determine the designated topic in your own computer room; Determine a first partition currently serving as a target partition among the multiple partitions of the designated topic, wherein each of the different computer rooms currently serves as the target partition as the first partition in the computer room where the computer room is located; Among the target partitions on multiple message servers in the computer room where the computer room is located, a target partition that is in a dominant position is determined as the primary copy of the first partition of the designated topic.
4. According to the method as claimed in claim 1 or 2, for the same computer room, the master copies of multiple partitions of a specified topic in the computer room are located on different message service terminals in the computer room; and each of the multiple partitions also has a master copy in at least one other computer room.
5. The method of claim 2, further comprising: The message consumption client of the first computer room obtains the in-computer room messages generated by the message generation client of the first computer room from the master copy of the first partition of the designated topic in the first computer room, and consumes the in-computer room messages, and also obtains the messages generated by the message generation client of the second computer room from the master copy of the first partition of the designated topic in the second computer room, and consumes the messages.
6. The method of claim 2, further comprising: If the corresponding message production client of the first computer room is unavailable, the message production client of the second computer room will still produce messages as messages for internal use in the computer room and send them to the master copy of the first partition of the designated topic in the second computer room, but not to the first computer room.
7. The method according to claim 6, wherein if the corresponding message production client of the first computer room is unavailable, the method further comprises: The message consumption client of the second computer room obtains the internal message generated by the message generation client of the second computer room from the primary copy of the first partition of the designated topic in the second computer room, and consumes the internal message; The message consumption client in the first computer room does not consume messages produced by the message production client in the second computer room across computer rooms.
8. The method according to claim 2, wherein the first computer room and the second computer room are remote computer rooms; The message middleware is a distributed multi-copy message middleware, and the topic is a queue obtained by message classification.
9. A message middleware disaster recovery device, comprising: a message middleware cluster, a message production client, and a message consumption client deployed in a first computer room and a second computer room, respectively; each message middleware cluster includes multiple message servers; and the device comprises: A message production and sending module of a message production client belonging to the first computer room determines one or more message servers where the primary replica of the first partition is located in the computer room where the module is located, and normally produces messages used in the computer room and sends them to the one or more message servers in the first computer room; A message production and sending module of a message production client belonging to the second computer room determines one or more message servers where the primary replica of the first partition is located in the computer room where the module is located, and normally produces messages in the computer room and sends them to the one or more message servers in the second computer room; A message convergence consumption module of a message consumption client belonging to the first computer room consumes in-computer room messages obtained from the primary replica of the first partition in the first computer room; A message convergence consumption module of a message consumption client belonging to the second computer room consumes in-computer room messages obtained from the primary replica of the first partition in the second computer room; A cross-computer room sending module of the message production client in the first computer room generates a cross-computer room message and sends it to the primary replica of the first partition in the second computer room if the corresponding message server in the first computer room is unavailable; The message auxiliary consumption module of the message consumption client belonging to the second computer room consumes the cross-computer room messages obtained from the primary copy of the first partition in the second computer room.
10. The device as described in claim 9, the message production and sending module of the message production client belonging to the first computer room or the second computer room determines the master copy of the first partition of the specified topic in the computer room where it is located, and the specified topic corresponding to the first partition determined by the message production clients in different computer rooms is the same topic.
11. The device according to claim 10, wherein the designated topics are located on multiple message servers in the corresponding computer room; The message production and sending module of the message production client belonging to the first computer room or the second computer room determines a designated topic in the computer room where the message production client is located; Determine a first partition currently serving as a target partition among multiple partitions of the specified topic, wherein: In different computer rooms, the first partition in the computer room where the computer room is located is currently used as the target partition; Among the target partitions on multiple message servers in the computer room where the computer room is located, a target partition that is in a dominant position is determined as the primary copy of the first partition of the designated topic.
12. The device as described in claim 9 or 10, for the same computer room, the master copies of multiple partitions of a specified topic in the computer room are located on different message service terminals in the computer room; and each of the multiple partitions also has a master copy in at least one other computer room.
13. The apparatus of claim 10, further comprising: The cross-computer room consumption module of the message consumption client belonging to the first computer room obtains the in-computer room messages generated by the message generation client of the first computer room from the master copy of the first partition of the designated topic of the first computer room, and consumes the in-computer room messages, and also obtains the messages generated by the message generation client of the second computer room from the master copy of the first partition of the designated topic of the second computer room, and consumes the messages.
14. The apparatus of claim 10, further comprising: The cross-computer room sending module of the message production client belonging to the second computer room will still produce messages as messages for internal use in the computer room if the corresponding message production client of the first computer room is unavailable, and send them to the master copy of the first partition of the designated topic in the second computer room, but not to the first computer room.
15. The apparatus according to claim 14, wherein if the corresponding message production client of the first computer room is unavailable, the apparatus further comprises: The message convergence and consumption module of the message consumption client belonging to the second computer room obtains the in-computer room message generated by the message generation client of the second computer room from the master copy of the first partition of the designated topic in the second computer room, and consumes the in-computer room message; The message convergence consumption module of the message consumption client of the first computer room does not consume messages produced by the message production client of the second computer room across computer rooms.
16. The device according to claim 10, wherein the first computer room and the second computer room are remote computer rooms; The message middleware is a distributed multi-copy message middleware, and the topic is a queue obtained by message classification.
17. A message middleware disaster recovery processing device, comprising a message middleware cluster, a message production client, and a message consumption client deployed in a first computer room and a second computer room, respectively. Each message middleware cluster includes multiple message servers. The device comprises: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, wherein the instructions are executed by the at least one processor to enable the at least one processor to perform: A message production client in the first computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the first computer room. A message production client in the second computer room determines one or more message servers where the primary replica of the first partition is located in its own computer room, and under normal circumstances, produces messages for use in the computer room and sends them to the one or more message servers in the second computer room. A message consumption client in the first computer room consumes computer room-use messages obtained from the primary replica of the first partition in the first computer room; a message consumption client in the second computer room consumes computer room-use messages obtained from the primary replica of the first partition in the second computer room; A message production client for the first computer room. If the corresponding message server of the first computer room is unavailable, it produces cross-computer room messages and sends them to the primary replica of the first partition in the second computer room. It is a message consumption client of the second computer room, consuming cross-computer room messages obtained from the primary copy of the first partition in the second computer room.
Citation Information
Patent Citations
Machine room disaster tolerance processing method, terminal and storage medium
CN112291082A
Disaster recovery method and system for message-oriented middleware
CN113342573A