Data request processing method, device, system, computer equipment and medium

The client creates two connection sessions in a dual-cluster scenario and automatically switches to the standby cluster to handle data requests. This solves the problem of slow service switching in the existing technology and achieves high availability and fast response.

CN114422567BActive Publication Date: 2024-10-11ALIBABA CLOUD COMPUTING CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202111499493.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-09
Publication Date
2024-10-11
Estimated Expiration
2041-12-09

AI Technical Summary

Technical Problem

In a dual-cluster or multi-cluster scenario, the service switching speed is slow and the high availability of the service cannot be guaranteed. The existing technology requires users to manually update the client configuration and restart the client, making the switching process time-consuming and unreliable.

Method used

The client creates two connection sessions, one for maintaining a connection with the primary cluster and one for maintaining a connection with the standby cluster. It prioritizes access to the primary cluster according to the configuration information. If the primary cluster does not return normally, it automatically sends concurrent requests to the standby cluster for processing, achieving fast Switching and high availability.

Benefits of technology

It enables the client to automatically and quickly switch to the backup cluster when a problem occurs in the primary cluster, avoiding user operations and ensuring high availability of services and rapid processing of data requests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114422567B_ABST
    Figure CN114422567B_ABST
Patent Text Reader

Abstract

One or more embodiments of the present specification provide a method, apparatus, system, computer device, and computer-readable storage medium for processing data requests. The method is applied to a client, and is used to: create a first connection session for maintaining a connection with a primary cluster, and create a second connection session for maintaining a connection with a standby cluster, wherein both the primary cluster and the standby cluster are distributed database clusters; obtain configuration information; if the configuration information indicates that the client preferentially accesses the primary cluster, the data request is preferentially sent to the primary cluster for processing based on the first connection session; if the primary cluster does not return a processing result normally, the data request is concurrently sent to the standby cluster based on the second connection session, so that the standby cluster processes the data request.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of computer technology, and in particular, to a method, apparatus, system, computer equipment, and computer-readable storage medium for processing data requests. Background Art

[0002] Continuous service availability is the lifeline of the business and one of the core values ​​of distributed storage systems. For online services, they are more sensitive to service availability and have higher requirements for data reliability. Therefore, dual clusters or multiple clusters are often used in scenarios such as online services. In dual cluster or multiple cluster scenarios, in some related technologies, users use clients to connect to the primary cluster. If users find that the primary cluster has problems, users need to manually update the client's connection configuration so that the client connects to the backup cluster. After the update, the client needs to be restarted. Only after the client is restarted can it switch to access the backup cluster. This switching process requires users to discover cluster problems, manually update, and restart the client. Therefore, the switching speed is slow and the high availability of the service cannot be guaranteed. Summary of the invention

[0003] To overcome the problems existing in the related art, this specification provides a method, apparatus, system, computer device and computer-readable storage medium for processing data requests.

[0004] According to a first aspect of an embodiment of this specification, a method for processing a data request is provided, the method being applied to a client, the method comprising:

[0005] Creating a first connection session for maintaining connection with a primary cluster, and creating a second connection session for maintaining connection with a standby cluster, wherein both the primary cluster and the standby cluster are distributed database clusters;

[0006] Get configuration information;

[0007] If the configuration information indicates that the client preferentially accesses the primary cluster, the data request is preferentially sent to the primary cluster for processing based on the first connection session;

[0008] If the active cluster fails to return the processing result normally, the data request is concurrently sent to the standby cluster based on the second connection session, so that the standby cluster processes the data request.

[0009] According to a second aspect of an embodiment of this specification, a data request processing device is provided, the device comprising:

[0010] Multi-cluster access module and automatic perception module; among them,

[0011] The multi-cluster access module is used to: create a first connection session for maintaining connection with a primary cluster and a second connection session for maintaining connection with a standby cluster, wherein both the primary cluster and the standby cluster are distributed database clusters; obtain configuration information; if the configuration information indicates that the client accesses the primary cluster first, send the data request to the primary cluster for processing first based on the first connection session; if the primary cluster does not return the processing result normally, send the data request to the standby cluster concurrently based on the second connection session, so that the standby cluster processes the data request;

[0012] The automatic sensing module is used to collect the response results of the primary cluster and / or the backup cluster to the data request, and determine whether the primary cluster and / or the backup cluster fails to return a normal processing result.

[0013] According to a third aspect of an embodiment of this specification, a data request processing system is provided, the system comprising a primary cluster and a backup cluster, the primary cluster and the backup cluster being both distributed database clusters; the system further comprising at least one client; the client being configured to:

[0014] Creating a first connection session for maintaining connection with the active cluster and a second connection session for maintaining connection with the standby cluster;

[0015] Get configuration information;

[0016] If the configuration information indicates that the client preferentially accesses the primary cluster, the data request is preferentially sent to the primary cluster for processing based on the first connection session;

[0017] If the active cluster fails to return the processing result normally, the data request is concurrently sent to the standby cluster based on the second connection session, so that the standby cluster processes the data request.

[0018] According to a fourth aspect of an embodiment of this specification, a computer device is provided, including:

[0019] processor;

[0020] a memory for storing processor-executable instructions;

[0021] The processor implements the embodiment of the method for processing data requests described in the first aspect above by running the executable instructions.

[0022] According to a fifth aspect of the embodiments of this specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps in the embodiment of the method for processing data requests described in the first aspect above are implemented.

[0023] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:

[0024] In an embodiment of the present specification, the client creates two connection sessions, the first connection session is used to maintain a connection with the primary cluster, and the second connection session is used to maintain a connection with the standby cluster, so that the client can maintain a connection state with the primary cluster and the standby cluster, and the client obtains configuration information, and the client's data request can be sent according to the instructions of the configuration information; if the configuration information indicates that the client gives priority to accessing the primary cluster, the data request is sent to the primary cluster for processing based on the first connection session; if the primary cluster does not return the processing result normally, the data request is sent to the standby cluster concurrently based on the second connection session, so that the standby cluster processes the data request; therefore, the client can automatically and quickly access another cluster according to the cluster's processing of the data request, and the switching process does not require user operation, which can ensure the high availability of the service and enable the data request to be processed quickly.

[0025] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and, together with the description, serve to explain the principles of the specification.

[0027] Figure 1A It is an application scenario diagram of a method for processing a data request according to an exemplary embodiment of this specification.

[0028] Figure 1B It is a flowchart of a method for processing a data request according to an exemplary embodiment of the present specification.

[0029] Figure 2A It is a schematic diagram of a multi-cluster access module according to an exemplary embodiment of this specification.

[0030] Figure 2B This is a schematic diagram of a processing process of a cluster switching module according to an exemplary embodiment of this specification.

[0031] Figure 2C This is a schematic diagram of automatic sensing processing of an automatic sensing module according to an exemplary embodiment of the present specification.

[0032] Figure 3 It is a hardware structure diagram of a computer device where a data request processing device is located according to an exemplary embodiment of this specification.

[0033] Figure 4 It is a block diagram of a data request processing device shown in this specification according to an exemplary embodiment. DETAILED DESCRIPTION

[0034] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.

[0035] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this specification. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0036] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0037] Continuous service availability is the lifeline of the business and one of the core values ​​of the distributed storage system. For online services, they are more sensitive to service availability and have higher requirements for data reliability. Therefore, dual clusters or multiple clusters are often used in scenarios such as online services. Through dual clusters or multiple clusters, disaster recovery can provide better service stability for online services. Disaster recovery means that when the main cluster is detected to be unavailable, the traffic can be switched to the backup cluster, thereby improving service availability.

[0038] like Figure 1A FIG. 1 is a schematic diagram of an application scenario of a data request processing method according to an exemplary embodiment of the present specification. Figure 1A In the figure, two clusters are taken as an example to show a main cluster and a standby cluster, wherein the cluster has at least two servers; in actual applications, more standby clusters may be included as needed, which is not limited in this embodiment. Figure 1AThe client is also included. The client here refers to a client that needs to access the cluster to obtain services provided by the cluster. There are one or more clients.

[0039] like Figure 1A As shown, in a scenario including dual clusters, if the primary cluster cannot meet the user's high availability requirements, the traffic can be switched to the backup cluster. However, in actual applications, there is a problem that the switching speed is slow and cannot meet the high availability requirements.

[0040] Taking the HBase cluster as an example, the HBase cluster is a distributed data storage cluster. It is a storage cluster built by the NoSQL database and storage system under the Hadoop ecosystem. It is widely used in online systems such as search, product orders, consumption records, monitoring systems or chat push.

[0041] The existing HBase has a synchronization (Replication) mechanism, that is, a data synchronization mechanism between clusters. Replication can synchronize the data in the main HBase cluster to the backup HBase cluster in real time. Therefore, when the main HBase cluster fails, users can still access the backup HBase cluster, thus achieving high availability.

[0042] However, the client of the HBase cluster only supports access to a single HBase cluster, that is, the client of the HBase cluster only supports configuring the address of one HBase cluster. Therefore, during the entire life cycle, requests can only be sent to the address of the configured HBase cluster. If the configured HBase cluster fails and cannot provide services, the user needs to operate the client, first stop the HBase cluster process, modify the configuration of the HBase cluster so that its access address points to the new available HBase cluster, and then restart the client. Only then can the client connect to the available HBase cluster and start accessing the available HBase cluster.

[0043] It can be seen that the above switching process requires user operation, which takes more than a minute, and requires restarting the client. The client cannot work during the restart process, resulting in business loss during the restart process and inability to provide normal services. In addition, the decision to switch depends on manual judgment of cluster failures, the decision time is not fixed, and the impact time of the failure cannot be estimated. In addition, when there are multiple clients, users are required to operate one by one. Therefore, the above switching method is slow, resulting in low processing efficiency for data requests, and cannot achieve the purpose of high availability.

[0044] Based on this, this specification provides an embodiment of a method for processing a data request. In this embodiment, the client runs at least two connection tasks, each of which is used to maintain a connection state with a corresponding cluster. Figure 1BAs shown, Figure 1B This is a flowchart of a data request processing method according to an exemplary embodiment of the present specification, comprising the following steps:

[0045] In step 120, a first connection session for maintaining connection with a primary cluster is created, and a second connection session for maintaining connection with a standby cluster is created, wherein both the primary cluster and the standby cluster are distributed database clusters;

[0046] In step 122, configuration information is obtained;

[0047] In step 124, if the configuration information indicates that the client preferentially accesses the primary cluster, the data request is preferentially sent to the primary cluster for processing based on the first connection session;

[0048] In step 126, if the active cluster does not return the processing result normally, the data request is concurrently sent to the standby cluster based on the second connection session, so that the standby cluster processes the data request.

[0049] The number of clusters in this embodiment can be two or more, that is, one main cluster and at least one backup cluster. The client of this embodiment can create at least two connection sessions during operation, and the at least two connection sessions include a first connection session and a second connection session. The first connection session maintains connection with the main cluster, and the second connection session maintains connection with the backup cluster; optionally, in the case of multiple backup clusters, the second connection session can be one, that is, it only maintains connection with one backup cluster, or the second connection session can be two or more, and each second connection session maintains connection with a backup cluster. That is, the number of clusters in this embodiment is at least two, and the number of connection tasks running in the corresponding client can be more than two. The number of connection tasks can be the same as the number of clusters, or it can be less than the number of clusters.

[0050] In some examples, the connection session can be specifically implemented using threads, that is, the client creates at least two connection threads. For example, a first connection thread and a second connection thread are running in the client, and the first connection thread is used to create a first connection session that is connected to the primary cluster, and the second connection thread is used to create a second connection session that is connected to the backup cluster, that is, each connection thread is used to maintain a connection state with the corresponding cluster.

[0051] In some examples, the lifecycles of the first connection thread and the second connection thread can be flexibly configured as needed. For example, each connection thread can have a different lifecycle, such as having different creation times and / or different release times. In other scenarios, optionally, the first connection thread and the second connection thread of this embodiment can maintain the same lifecycle, that is, they can be created and released at the same time. For example, if the user needs the function of connecting to the cluster, the first connection thread and the second connection thread can be created at the same time. When the user does not need to connect to the cluster, the first connection thread and the second connection thread can be released at the same time. Therefore, when the user needs to connect to the cluster, by creating the first connection thread and the second connection thread at the same time, the high availability of the service can be guaranteed. When the user does not need to connect to the cluster, the first connection thread and the second connection thread are released at the same time, thereby reducing the resource occupation of the connection process.

[0052] In this embodiment, since the client runs the first connection session and the second connection session, the client can quickly and automatically switch to access different clusters. The client of this embodiment can obtain configuration information, and the configuration information is used to indicate the cluster that the client preferentially accesses. The configuration information can be input by the user through the client, or can be automatically generated by the client according to the operation status of the cluster.

[0053] In this embodiment, the client maintains a connection with the primary and standby clusters, and the client's data request can be sent according to the instructions of the configuration information. Taking the configuration information used to instruct the client to give priority to accessing the primary cluster as an example, the configuration information instructs the client to give priority to accessing the primary cluster, and based on the first connection session, the data request is sent to the primary cluster for processing; after receiving the data request, the primary cluster will process it. If the primary cluster operates normally, the client can receive the normal processing result in time. If the primary cluster does not return the processing result normally due to some reasons, such as network jitter or the primary cluster does not work properly, the scheme of this embodiment can send the data request to the standby cluster concurrently based on the second connection session, so that the standby cluster processes the data request.

[0054] As an example, in some scenarios, after sending a data request to the main cluster, if the main cluster returns the result normally, the processing of the data request ends; if an error message returned by the main cluster is received, or the result returned by the main cluster for the data request is not received within the set time, it can be determined that the main cluster did not return the processing result normally. In order to ensure the high availability effect, the client of this embodiment is also connected to the backup cluster, so the data request can be sent to the backup cluster for processing. It can be seen that the data request of this embodiment can be sent to another cluster for processing if the cluster with priority access fails to return the normal processing result in time. Based on this, the client may receive the normal processing results of the data request returned by two clusters respectively. In this embodiment, if the normal processing results of the same data request returned by the main cluster and the backup cluster are received respectively, the normal processing result with a later return time is discarded, that is, the normal processing result with the fastest return is selected, and the other normal processing result with a slower return can be discarded, thereby achieving a quick response to the data request.

[0055] Among them, if the main cluster fails to return the processing result normally, the condition that the data request needs to be sent to the standby cluster through the connection session corresponding to the standby cluster can be flexibly configured as needed, and this embodiment does not limit this. As an example, this condition can be implemented in a variety of ways, such as being set based on the response time of the data request, such as not receiving a normal processing result within a set time after issuing the data request, or it can also be determined based on the error message fed back by the cluster, such as receiving an error message fed back by the cluster for the data request; it can also be determined in combination with the number of times, such as the number of consecutive error messages received or consecutive timeouts exceeding the set number, etc. This embodiment does not limit this.

[0056] In some examples, different processing methods may be set according to different feedbacks from the current clusters. As an example, if the primary cluster does not return the processing result normally, the data request is sent to the standby cluster via the second connection session so that the standby cluster processes the data request, including:

[0057] If it is determined that the processing of the primary cluster has timed out according to the response result of the primary cluster to the data request, the data request is concurrently sent to the standby cluster through the second connection session, so that the standby cluster processes the data request;

[0058] If it is determined according to the response result that the primary cluster fails, the configuration information is updated so that the client preferentially accesses the backup cluster, and based on the second connection session, the data request is switched to be sent preferentially to the backup cluster for processing, and the data request is concurrently sent to the primary cluster for processing through the first connection session.

[0059] In this embodiment, after the data request is sent to the main cluster, the response result of the main cluster to the data request can be collected. This embodiment sets two processing methods for different feedback situations. Among them, if it is found that the main cluster has timed out in processing the data request, the data request can be sent to the standby cluster through the connection task corresponding to the standby cluster, so that the standby cluster processes the data request. Based on this, when the main cluster fails to return the normal processing result in time, since it maintains a connection with the standby cluster, the client can quickly send the data request to the standby cluster so that the standby cluster processes the data request. Among them, the determination of the main cluster's processing timeout for the data request can be flexibly configured as needed. As an example, the timeout period can be set as needed. The client starts timing after sending the data request. If the normal processing result is not received within the set timeout period, it can be determined that the main cluster has timed out in processing the data request.

[0060] In another processing method, cluster failures can be dealt with by switching traffic from the main cluster to prioritize access to the backup cluster. If the main cluster is determined to have failed based on the response result of the main cluster to the data request, the configuration information is updated so that the client prioritizes access to the backup cluster to trigger the execution of the processing flow. Since the configuration information is updated so that the client prioritizes access to the backup cluster and triggers the execution of the processing flow, the backup cluster is used as the cluster to be accessed first in the processing flow, and data requests are sent to the backup cluster first, thereby automatically identifying cluster failures and ensuring high availability of the service. Among them, the determination of the main cluster failure can be flexibly configured as needed, such as the number of consecutive error messages received or the number of consecutive timeouts exceeding the set number, etc., which is not limited in this embodiment.

[0061] For the above-mentioned failure scenario, as needed, optionally, when the primary cluster fails and switches to the backup cluster, it can also be determined whether the primary cluster has recovered to normal, so as to switch back to the backup cluster after recovery. As an example, after the data request is switched to be sent to the backup cluster for processing based on the second connection session, the method further includes:

[0062] If it is determined according to the response result that the primary cluster has recovered to normal, after the configuration information is updated so that the client preferentially accesses the primary cluster, the data request is switched back to be preferentially sent to the primary cluster for processing based on the first connection session.

[0063] As an example, if the main cluster fails, the scheme of this embodiment switches the traffic to the standby cluster, that is, the data request is sent to the standby cluster first; at the same time, in order to realize the switchback operation, the scheme of this embodiment also sends the data request to the main cluster concurrently, so as to determine the time when the main cluster recovers to normal according to the processing of the data request by the main cluster. At this time, it is sent to the standby cluster first and concurrently to the main cluster, that is, it is sent to the standby cluster first and then to the main cluster. If the main cluster fails, the sent data request cannot receive the normal processing result. If the main cluster recovers to normal, the main cluster can process the sent data request and return the normal processing result. Based on this, after determining that the main cluster recovers to normal according to the response result of the main cluster to the data request, the configuration information can be updated again, and the configuration information can be updated to allow the client to access the main cluster first. The updated configuration information indicates that the client accesses the main cluster first, and triggers the execution of the processing of sending the data request to the main cluster first, thereby achieving the purpose of switching from the standby cluster to the main cluster and achieving the switchback after the failure recovery of the main cluster.

[0064] In actual applications, the cluster may provide services to multiple clients of the user. Each client can use the above solution to identify that the cluster currently accessed with priority has failed, automatically implement cluster switching, and improve the high availability of data requests. Among them, the process of the client identifying that the cluster has failed is that the client needs to identify it after issuing a data request. In order to further improve the processing efficiency of data requests, in this embodiment, when a client finds that the cluster currently accessed with priority has failed and needs to be switched, since the client is also connected to another cluster in this embodiment, other clients can also perform cluster switching, so that other clients can perform cluster switching in advance before discovering the cluster failure, thereby improving the processing efficiency of data requests. As an example, the method also includes: after determining that the main cluster has failed, sending a cluster switching message to the standby cluster through the second connection session, so that other clients connected to the standby cluster will update the configuration information to allow the client to access the standby cluster first after listening to the cluster switching message issued by the standby cluster.

[0065] Taking the cluster currently accessed as the main cluster and the cluster to be switched as the standby cluster as an example, in this embodiment, after the client finds that the main cluster has a fault and needs to be switched, it sends a cluster switching message to the standby cluster. In this embodiment, the standby cluster can publish the cluster switching message after receiving the cluster switching message from the client; and based on the design of the client of the present application solution, multiple other clients also maintain connection with the standby cluster, and other clients can listen to the messages published by the standby cluster. When listening to the cluster switching message published by the standby cluster, each other client can determine that the main cluster has a fault, so that other clients can switch to the standby cluster in time.

[0066] In actual applications, multiple clients may simultaneously identify the failure of the primary cluster and send cluster switching messages to the standby cluster. In order to prevent multiple clients from simultaneously sending cluster switching instructions to the standby cluster, in this embodiment, the sending of the cluster switching message to the standby cluster may include: sending a request to hold the automatic switching lock to the standby cluster, and after holding the automatic switching lock returned by the standby cluster based on the holding request, sending the cluster switching message to the standby cluster. That is, the client sends the cluster switching message to the standby cluster only after receiving the automatic switching lock returned by the standby cluster.

[0067] Taking the cluster currently accessed with priority as the main cluster and the cluster to be switched as the standby cluster as an example, in the scheme of this embodiment, after the client finds that the main cluster fails and needs to be switched, it can request the standby cluster to hold the automatic switching lock. The automatic switching lock can only be held by one client at any time. If the automatic switching lock of the current standby cluster is not held by the client, after a client requests to hold the automatic switching lock, the standby cluster can return the automatic switching lock to the client. Based on the client's request to hold the automatic switching lock, the standby cluster can determine that the client needs to switch to this cluster due to other cluster failures. Therefore, the standby cluster can publish a cluster switching message, so that other clients can update the configuration information to allow the client to access the standby cluster first after listening to it. Since the configuration information of other clients has been updated to allow the client to access the standby cluster first, other clients can quickly complete the cluster switch. After that, the data requests of other clients can be processed by the standby cluster. Among them, since the automatic switching lock can only be held by one client at any one time, the automatic switching lock can only be returned to one client. The client that receives the automatic switching lock can update its own configuration information; other clients that have not obtained the automatic switching lock can receive the cluster switching message issued by the standby cluster and update their own configuration information according to the cluster switching message issued by the standby cluster.

[0068] The above embodiment describes the process of the client actively executing the switch. In this embodiment, the client can also receive the cluster switch instruction triggered by the user. As an example, the cluster usually runs a coordination service. The user who manages the cluster can trigger the cluster switch message through the coordination service and / or the client. Through the scheme of this embodiment, the user only needs to operate the cluster switch message once to trigger other clients connected to the cluster to perform cluster switching. For example, the cluster switch message sent by the user through the coordination service of a cluster can be sent to the coordination service of other clusters. The cluster switch message triggered by the user through the client can also be sent to the coordination service of each cluster. The client of this embodiment can be connected to the coordination service of each cluster, so it can monitor whether each cluster has generated a cluster switch message. As an example, after the client is running, it can register a monitoring task in the coordination service of each cluster to monitor whether the coordination service of each cluster generates a cluster switch message. In order to ensure the high availability of the switch, since the client and the primary and standby clusters are connected, the cluster switch message on the primary and standby clusters can be monitored at the same time. Usually, different clusters are deployed in different computer rooms. By monitoring the cluster switch messages of the primary cluster and the standby cluster at the same time, it can be guaranteed that the cluster switch message can still be normally monitored in the case of a single computer room failure. Among them, the cluster switching message is used to indicate the cluster that the client accesses first. After the client listens to the cluster switching message, it can update the configuration information according to the instruction of the cluster switching message, thereby triggering the subsequent processing flow according to the configuration information and switching the traffic to the cluster indicated in the cluster switching message.

[0069] In some scenarios, a user may send multiple cluster switching messages in succession. Due to the uncertainty of network communication, a cluster switching message sent first may be monitored later. In view of this situation, the cluster switching message of this embodiment carries a timestamp. As an example, the format of the cluster switching message can be<target,timestamp,type> , where target indicates the switching target, timestamp indicates the timestamp, and type indicates the message type. Based on this, the cluster switching instruction carrying the latest timestamp can be used as a benchmark to determine whether cluster switching needs to be performed based on the timestamp of the cluster switching message.

[0070] As an example, the obtaining of configuration information includes:

[0071] Listening to a cluster switching message carrying a timestamp issued by the primary cluster and / or the backup cluster, where the cluster switching message is used to indicate a cluster that the client preferentially accesses;

[0072] If the timestamp of the cluster switching message is greater than the update time of the configuration information, update the configuration information using the cluster switching message;

[0073] If the timestamp of the cluster switching message is less than the update time of the configuration information, the cluster switching message is discarded.

[0074] In this embodiment, after receiving the cluster switching instruction, the client can determine whether to update the configuration information according to the timestamp of the cluster switching instruction, thereby ensuring the accuracy of the switching action.

[0075] As an example, after the client receives a switching message carrying a first timestamp, since it is the first time to receive the switching message, according to the initial setting of 0, the first timestamp is compared with 0, and it can be determined that the first timestamp is newer, and according to the instruction of the cluster switching message, it switches to the second cluster. Afterwards, the client receives a switching message carrying a second timestamp, and compares the second timestamp with the first timestamp. Since the time of the second timestamp is before the first timestamp, the switching message carrying the second timestamp can be discarded and not executed, and the latest switching message carrying the first timestamp is used as the standard, thereby ensuring that the switching action is executed according to the latest switching message, thereby ensuring the accuracy of the switching action.

[0076] Next, the method for processing data requests in the embodiment of this specification will be described through an embodiment.

[0077] The core of the active-standby cluster switching mainly involves two issues, namely how to switch and how to make decisions. The key to switching is to establish a new connection, and the key to decision-making is to determine whether the active cluster is faulty. This embodiment solves the problem of connection establishment through the simultaneous access capability of multiple clusters. The switching action can be completed without restarting. At the same time, the execution results are analyzed to provide automatic decision-making capabilities, thereby realizing the active-standby automatic switching solution that is actively perceived by the client.

[0078] This embodiment is described by taking two active and standby clusters as an example. In actual applications, there may be one or more standby clusters as required. As an example, the client of this embodiment may include the following three modules: a multi-cluster access module, a cluster switching module, and an automatic sensing module.

[0079] Multi-cluster access module (MultiConnection+MultiExecutor), which can support access to the main cluster and the backup cluster at the same time. Traditional clients only support access to a single cluster. In a fault scenario, the client connection configuration needs to be modified, and then the client needs to be restarted to complete the switching between clusters. This process takes more than ten minutes to complete and the time consumed is positively correlated with the number of clients. At the same time, the business cannot be accessed normally during the switching process, which is detrimental to the business. The multi-cluster access module of this embodiment mainly solves this problem, supports simultaneous access to the main and backup clusters, switches in seconds in fault scenarios, and is transparent to upper-layer businesses without interruption.

[0080] Cluster switching module (SwitchTracker): The cluster switching module mainly solves three difficulties in cluster switching: how the client perceives the switching operation, how to ensure high availability of switching in the network disconnection scenario, and how to identify erroneous and expired switching messages to ensure the accuracy of the switching action.

[0081] Automatic sensing module (AutoSwitch): The core function is to accurately judge the failure of the main cluster and then issue a switching command to automatically switch the main and standby clusters, and automatically switch back after the failure is restored.

[0082] The following is a detailed description of each module:

[0083] Multi-cluster access module (MultiConnection+MultiExecutor):

[0084] like Figure 2A As shown, it is a schematic diagram of a multi-cluster access module shown in this specification according to an exemplary embodiment. The client needs to establish a corresponding connection Connection to access the cluster. In this embodiment, multiple connections MultiConnection are created; from the user's perspective, MultiConnection is equivalent to Connection. Connections to the main cluster and the backup cluster are established simultaneously inside MultiConnection, so that the client can be connected to both clusters, wherein the two Connections refer to two processes; optionally, the life cycles of the two Connections are the same, that is, they are created and released together.

[0085] When the client accesses the cluster to obtain data, the actual request when the user accesses the cluster through MultiConnection will be executed through MultiExecutor;

[0086] Among them, the execution process of MultiExecutor is:

[0087] According to the settings, if the current settings are to access the main cluster, the request will be sent to the main cluster first; if the main cluster is normal, the client can normally receive the return result from the main cluster, that is, it can receive the execution result of the request from the main cluster within normal time.

[0088] If the primary cluster is not in a normal state, the client cannot receive the return result from the primary cluster normally; for example, the client may have waited for a certain period of time and failed to receive the return result from the primary cluster, or the primary cluster returned an error message, etc. Based on this, MultiExecutor can concurrently access the standby cluster or switch to the standby cluster.

[0089] As an example, in some scenarios, after sending a data request to the main cluster, if the main cluster returns the result normally, the processing of the data request ends; if an error message returned by the main cluster is received, or the result returned by the main cluster for the data request is not received within the set time, it can be determined that the main cluster currently fails to process the data request normally. In order to ensure the effect of high availability, in this embodiment, since the connection with the standby cluster is also maintained, the standby cluster can be accessed concurrently. Therefore, when the main cluster cannot return the processing result of the data request in time, the client of this embodiment can send the data request to the standby cluster for processing because it is also connected to the standby cluster. In this embodiment, after the data request is sent to the main cluster first, since the normal feedback from the main cluster is not received in time, the client also sends it to the standby cluster concurrently; based on this, after the client sends it concurrently to the standby cluster, it may receive normal processing results returned by both the main cluster and the standby cluster. If both are received at the same time, the client can take any one of them as the processing result of the data request; if not at the same time, the first received one can be taken as the processing result of the data request.

[0090] If it is determined that the main cluster fails, the solution of this embodiment has the ability to access multiple clusters. In the failure scenario, the client is also connected to the backup cluster. Therefore, the client can automatically and quickly complete the switch of cluster access, that is, after determining that the main cluster fails, all data requests can be sent to the backup cluster through the backup cluster's Connection. Therefore, through the above-mentioned dual Connection design, in the failure scenario, the client of this embodiment only needs to swap the dual Connection roles to complete the cluster switch. The whole process is completed in seconds and is transparent to the user. The business is completely unaware and no user operation is required. At the same time, this implementation method has zero intrusion on the native client code, and removing the dependency on the version can flexibly support the hybrid deployment mode of self-built and public cloud HBase clusters.

[0091] like Figure 2B As shown, it is a schematic diagram of the processing process of the cluster switching module (SwitchTracker) of this embodiment. The cluster switching module of this embodiment is used to monitor whether a cluster switching message actively sent by a cluster-side user is received; as an example, a coordination service is configured in the cluster of this embodiment. Taking the HBase cluster as an example, its coordination service is Zookeeper. The Zookeeper is a distributed, open source distributed application coordination service, that is, an application that provides consistency services for distributed applications. Zookeeper can be considered as the manager of the cluster, which can monitor the status of each node in the cluster and perform the next reasonable operation according to the feedback submitted by the node. The functions provided include: configuration maintenance, domain name service, distributed synchronization, group service, etc.

[0092] In this embodiment, the user can input the cluster switching instruction through Zookeeper. The cluster switching instruction in this embodiment can be received synchronously by other clusters after the Zookeeper of any cluster receives it. The cluster switching module can monitor whether the Zookeeper of the main cluster and the Zookeeper of the standby cluster obtain the cluster switching message to perceive the switching action. In order to ensure the high availability of the switching, since the client maintains a connection state with both the main cluster and the standby cluster, the cluster switching module can simultaneously monitor the cluster switching message on the main and standby HBase cluster Zookeeper. Usually, the main cluster and the standby cluster are deployed in different computer rooms respectively. The cluster switching module of this embodiment can ensure that the cluster switching message can still be normally monitored in the case of a single computer room failure by simultaneously monitoring the cluster switching message of the main cluster and the standby cluster. After the cluster switching module monitors the cluster switching message, the cluster switching message can be sent to the multi-cluster access module according to the indication of the cluster switching message. The multi-cluster access module updates the configuration information according to the cluster switching message, thereby controlling the multi-cluster access module to switch all traffic to the cluster indicated in the cluster switching message.

[0093] As an example, a user may send multiple cluster switching messages in succession. Due to the uncertainty of network communication, a switching message sent first may be monitored later. In view of this situation, the switching message of this embodiment carries a timestamp. As an example, the format of the switching message can be<target,timestamp,type> , where target represents the switching target, timestamp is the timestamp, and type is the message type. Based on this, the switching message carrying the latest timestamp can be used as a benchmark. Through the timestamp, the cluster switching module can determine whether a multi-cluster access module is required to perform a switching operation based on the timestamp of the switching message. As an example, after the cluster switching module receives the switching message carrying the first timestamp, since it is the first time to receive the switching message, according to the initial setting of 0, the first timestamp is compared with 0, and it can be determined that the first timestamp is newer. According to the instruction of the switching message, the cluster switches from the standby cluster to the main cluster. Afterwards, the cluster switching module receives the switching message carrying the second timestamp, and compares the second timestamp with the first timestamp. Since the time of the second timestamp is before the first timestamp, the switching message carrying the second timestamp can be discarded and not executed, and the latest switching message carrying the first timestamp is used as the standard, thereby ensuring that the switching action is executed based on the latest switching message, thereby ensuring the accuracy of the switching action.

[0094] like Figure 2CAs shown, this specification shows an automatic perception processing schematic diagram of an automatic perception module according to an exemplary embodiment. The automatic perception module of this embodiment is used to automatically perceive whether it is necessary to automatically switch clusters. As an example, the cluster failure scenarios may be as follows: room-level failures such as network outages and power outages make it impossible to connect to the cluster normally, resulting in all cluster data requests being thrown errors; or, the entire cluster is down due to a software bug; or, the cluster access timeout is caused by a slow disk or a bad disk of a server in the cluster. These failure scenarios, from the user's perspective, are cluster access errors or cluster access timeouts. The automatic perception module of this embodiment will collect the execution results of the data request returned by MultiExecutor from the currently accessed cluster, and according to the set fault conditions (such as consecutively received error messages or the number of consecutive timeouts exceeding the set number, etc.), it can be determined that the currently accessed cluster has a fault and needs to be switched.

[0095] Taking the case where the main cluster fails and needs to be switched to the standby cluster as an example, after the automatic perception module determines that the currently accessed cluster has a fault and needs to be switched, it can obtain the automatic switching lock on the standby cluster Zookeeper. This operation can prevent multiple clients from sending multiple switching messages at the same time. After obtaining the lock, the automatic perception module sends an automatic switching message to the multi-cluster access module, so that the multi-cluster access module switches the main and standby clusters. After the switch is completed, the automatic perception module can enter the recovery state, in which the execution results of MultiExecutor continue to be collected; if the main cluster is restored to normal, the original data request sent to the main cluster can be processed, that is, MultiExecutor can receive the normal execution results returned by the main cluster. Through the collected normal execution results, according to the set conditions (for example, the number of consecutive normal execution results received exceeds the set number, etc.), it can be determined that the main cluster has been restored to normal. At this time, the switchback operation can be performed, that is, switching from the currently accessed standby cluster back to the main cluster. The switching operation is as described above. After the switch is completed, the automatic perception module can be restored from the recovery state to the normal state.

[0096] As an example, Figure 2C As shown, the working process of the automatic perception module may include: determining whether it is in a recovering state, if not in a recovering state, determining whether the main cluster throws an error / times out; if the main cluster throws an error or times out, further monitoring to determine whether it throws an error / times out continuously, if the continuous error / timeout is greater than a specified number, a request to obtain a switching lock for the standby cluster may be made, and after obtaining the switching lock, a switching message is sent to the multi-cluster access module, so that the multi-cluster access module switches from accessing the main cluster to accessing the standby cluster under the instruction of the switching message, that is, data requests give priority to accessing the standby cluster, and the automatic perception module may enter a switching state after the switching is completed.

[0097] The automatic sensing module is in the recovery state. In this state, data requests give priority to accessing the standby cluster and are also sent concurrently to the main cluster determined to be faulty. The automatic sensing module continues to collect the processing results of the main cluster on the data request. If the main cluster begins to recover, the automatic sensing module can begin to collect the normal processing results returned by the main cluster. Through the collected normal execution results, according to the set conditions (for example, the number of consecutive normal execution results received exceeds the set number, etc.), it can be determined that the main cluster has recovered. At this time, a switchback operation can be performed. The switchback operation is consistent with the aforementioned switching operation. A request can be made to obtain the switching lock of the main cluster. After obtaining the switching lock, a switching instruction is sent to the multi-cluster access module, so that the multi-cluster access module switches from accessing the standby cluster to accessing the main cluster under the instruction of the switching message, that is, the data request gives priority to accessing the standby cluster, that is, switches from the currently accessed standby cluster back to the main cluster. After the switch is completed, the automatic sensing module can be restored from the recovery state to the normal state.

[0098] In this embodiment, through the cooperation of multiple cluster access modules, cluster switching modules and automatic perception modules, the client can automatically perceive and perform cluster switching in the event of a fault. This solves the shortcomings of the original solution that the client switching clusters is time-consuming and detrimental to the business. Automatic switching can be achieved in seconds without the upper-layer business being aware of it, thus ensuring the continuous availability of the business to the greatest extent and bringing the availability of the cluster to a new level.

[0099] The solution of this embodiment can be implemented in the form of a plug-in, so as to achieve zero intrusion on the original client code and support hybrid cloud deployment. In the fault scenario, the client can actively perceive and automatically switch clusters. Innovative use of multi-cluster access and switching perception realizes the master-slave switching capability that does not require the client to restart, is unaware of the business, and is completed in seconds. On this basis, it achieves automatic fault perception and provides automatic switching decision-making capabilities to minimize the impact of faults on availability.

[0100] Corresponding to the embodiments of the aforementioned method for processing data requests, the embodiments of this specification also provide embodiments of a device for processing data requests and a computer device used therein.

[0101] The embodiments of the processing device for data request in this specification can be applied to computer devices, such as servers or terminal devices. The device embodiments can be implemented by software, hardware, or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor of the file processing in which it is located reading the corresponding computer program instructions in the non-volatile memory into the memory for execution. From the hardware level, such as Figure 3 The figure is a hardware structure diagram of the computer device where the processing device of the data request of this specification is located, except Figure 3In addition to the processor 310, memory 330, network interface 320, and non-volatile memory 340 shown, the computer device where the data request processing device 331 is located in the embodiment may also include other hardware according to the actual function of the computer device, which will not be described in detail.

[0102] like Figure 4 As shown, Figure 4 is a block diagram of a data request processing device according to an exemplary embodiment of the present specification, the device comprising:

[0103] Multi-cluster access module 41 and automatic sensing module 42; wherein,

[0104] The multi-cluster access module 41 is used to: create a first connection session for maintaining connection with a primary cluster and a second connection session for maintaining connection with a standby cluster, wherein both the primary cluster and the standby cluster are distributed database clusters; obtain configuration information; if the configuration information indicates that the client preferentially accesses the primary cluster, preferentially send the data request to the primary cluster for processing based on the first connection session; if the primary cluster does not return the processing result normally, concurrently send the data request to the standby cluster based on the second connection session, so that the standby cluster processes the data request;

[0105] The automatic sensing module 42 is used to collect the response results of the primary cluster and / or the backup cluster to the data request, and determine whether the primary cluster and / or the backup cluster fails to return a normal processing result.

[0106] In some examples, a first connection thread and a second connection thread are running in the client, the first connection thread is used to create a first connection session connected to the primary cluster, and the second connection thread is used to create a second connection session connected to the standby cluster.

[0107] In some examples, the first connection thread and the second connection thread are created and released at the same time.

[0108] In some examples, the method further comprises:

[0109] If normal processing results for the same data request respectively returned by the primary cluster and the backup cluster are received, the normal processing result returned later is discarded.

[0110] In some examples, if the active cluster does not return the processing result normally, sending the data request to the standby cluster through the second connection session so that the standby cluster processes the data request includes:

[0111] If it is determined that the processing of the primary cluster has timed out according to the response result of the primary cluster to the data request, the data request is concurrently sent to the standby cluster through the second connection session, so that the standby cluster processes the data request;

[0112] If it is determined according to the response result that the primary cluster fails, the configuration information is updated so that the client preferentially accesses the backup cluster, and based on the second connection session, the data request is switched to be sent preferentially to the backup cluster for processing, and the data request is concurrently sent to the primary cluster for processing through the first connection session.

[0113] In some examples, after switching the data request based on the second connection session to be preferentially sent to the standby cluster for processing, the method further includes:

[0114] If it is determined according to the response result that the primary cluster has recovered to normal, after the configuration information is updated so that the client preferentially accesses the primary cluster, the data request is switched back to be preferentially sent to the primary cluster for processing based on the first connection session.

[0115] In some examples, the method further comprises:

[0116] After determining that the primary cluster fails, a cluster switching message is sent to the standby cluster through the second connection session, so that other clients connected to the standby cluster update configuration information to preferentially access the standby cluster after listening to the cluster switching message issued by the standby cluster.

[0117] In some examples, the sending a cluster switching message to the standby cluster includes:

[0118] A holding request for the automatic switching lock is sent to the standby cluster, and after holding the automatic switching lock returned by the standby cluster based on the holding request, the cluster switching message is sent to the standby cluster.

[0119] In some examples, obtaining configuration information includes:

[0120] Listening to a cluster switching message carrying a timestamp issued by the primary cluster and / or the backup cluster, where the cluster switching message is used to indicate a cluster that the client preferentially accesses;

[0121] If the timestamp of the cluster switching message is greater than the update time of the configuration information, update the configuration information using the cluster switching message;

[0122] If the timestamp of the cluster switching message is less than the update time of the configuration information, the cluster switching message is discarded.

[0123] In some examples, the cluster includes an HBase cluster.

[0124] Accordingly, an embodiment of the present specification further provides a data request processing system, the system comprising at least two clusters and at least one client; at least two connection tasks are running in the client, each of the connection tasks is used to maintain a connection state with a corresponding cluster;

[0125] The client is configured to:

[0126] Acquire configuration information, where the configuration information is used to instruct the client to preferentially access the first cluster;

[0127] The following processing flow is performed according to the configuration information:

[0128] The cluster that the client preferentially accesses indicated in the configuration information is used as the target cluster, and the data request is preferentially sent to the target cluster through the connection task corresponding to the target cluster for processing;

[0129] If the target cluster does not return a normal processing result, the data request is sent to the second cluster through a connection task corresponding to the second cluster, so that the second cluster processes the data request.

[0130] Correspondingly, an embodiment of the present specification also provides a computer device, comprising: a processor; a memory for storing processor executable instructions; wherein the processor implements an embodiment of the method for processing data requests described in the first aspect above by running the executable instructions.

[0131] Accordingly, an embodiment of the present specification also provides a computer-readable storage medium on which computer instructions are stored. When the instructions are executed by a processor, the steps in the embodiment of the method for processing data requests described in the first aspect above are implemented.

[0132] The implementation process of the functions and effects of each module in the above-mentioned data request processing device is specifically described in the implementation process of the corresponding steps in the above-mentioned data request processing method, which will not be repeated here.

[0133] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying creative labor.

[0134] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0135] The step division of the above methods is only for the purpose of clear description. When implemented, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent; adding insignificant modifications to the algorithm or process or introducing insignificant designs without changing the core design of the algorithm and process are all within the scope of protection of this patent.

[0136] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention claimed herein. The specification is intended to cover any variations, uses or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not claimed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.

[0137] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

[0138] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.

Claims

1. A method for processing a data request, the method being applied to a client, the method comprising: Creating a first connection session for maintaining connection with a primary cluster and creating a second connection session for maintaining connection with a standby cluster, so that the client is respectively in a connected state with the primary cluster and the standby cluster; the primary cluster and the standby cluster are both distributed database clusters; Acquire configuration information, where the configuration information is used to indicate a cluster that the client accesses first; If the configuration information indicates that the client preferentially accesses the primary cluster, the data request is preferentially sent to the primary cluster for processing based on the first connection session; If it is determined that the primary cluster fails according to the response result of the primary cluster to the data request, the configuration information is updated so that the client preferentially accesses the standby cluster, so that the client switches the data request to be preferentially sent to the standby cluster for processing based on the second connection session according to the updated configuration information, and sends a cluster switching message to the standby cluster through the second connection session, so that other clients that are connected to the standby cluster update the configuration information so that the client preferentially accesses the standby cluster after listening to the cluster switching message issued by the standby cluster; Wherein, the obtaining of configuration information includes: monitoring a cluster switching message carrying a timestamp issued by the primary cluster and / or the backup cluster, the cluster switching message being used to indicate a cluster that the client accesses first; if the timestamp of the cluster switching message is greater than the update time of the configuration information, using the cluster switching message to update the configuration information; if the timestamp of the cluster switching message is less than the update time of the configuration information, discarding the cluster switching message; The sending of the cluster switching message to the standby cluster includes: sending a holding request for an automatic switching lock to the standby cluster, and after holding the automatic switching lock returned by the standby cluster based on the holding request, sending the cluster switching message to the standby cluster.

2. According to the method of claim 1, a first connection thread and a second connection thread are running in the client, the first connection thread is used to create a first connection session connected to the primary cluster, and the second connection thread is used to create a second connection session connected to the standby cluster. 3 . The method according to claim 2 , wherein the first connection thread and the second connection thread are created and released at the same time.

4. The method according to claim 1, further comprising: If it is determined that the processing of the primary cluster has timed out according to the response result of the primary cluster to the data request, the data request is concurrently sent to the standby cluster based on the second connection session, so that the standby cluster processes the data request; If normal processing results for the same data request respectively returned by the primary cluster and the backup cluster are received, the normal processing result returned later is discarded.

5. The method according to claim 1, wherein the step of switching the data request based on the second connection session to be sent to the standby cluster for processing first, comprises: Based on the second connection session, the data request is switched to be sent to the standby cluster for processing first, and the data request is continued to be sent to the active cluster for processing in parallel through the first connection session.

6. The method according to claim 5, after switching the data request based on the second connection session to be sent to the standby cluster for processing first, the method further comprises: If it is determined according to the response result that the primary cluster has recovered to normal, after the configuration information is updated so that the client preferentially accesses the primary cluster, the data request is switched back to be preferentially sent to the primary cluster for processing based on the first connection session.

7. The method according to claim 1, wherein the cluster comprises an HBase cluster.

8. A data request processing device, the device being applied to a client, the device comprising: Multi-cluster access module and automatic perception module; among them, The multi-cluster access module is used to: create a first connection session for maintaining connection with the main cluster and a second connection session for maintaining connection with the standby cluster, so that the client is in a connected state with the main cluster and the standby cluster respectively; the main cluster and the standby cluster are both distributed database clusters; obtain configuration information; if the configuration information indicates that the client gives priority to accessing the main cluster, based on the first connection session, the data request is preferentially sent to the main cluster for processing; if it is determined that the main cluster has a fault according to the response result of the main cluster to the data request, the configuration information is updated to allow the client to preferentially access the standby cluster, so that the client switches the data request to preferentially send it to the standby cluster for processing based on the second connection session according to the updated configuration information, and sends a cluster switching message to the standby cluster through the second connection session, so that other clients that are connected to the standby cluster update the configuration information to allow the client to preferentially access the standby cluster after listening to the cluster switching message issued by the standby cluster; The automatic sensing module is used to: collect the response results of the main cluster and / or the standby cluster to the data request, and determine whether the main cluster and / or the standby cluster fail to return a normal processing result; Among them, the multi-cluster access module is also used to: listen to the cluster switching messages carrying timestamps issued by the main cluster and / or the backup cluster, the cluster switching messages are used to indicate the cluster that the client accesses first; if the timestamp of the cluster switching message is greater than the update time of the configuration information, use the cluster switching message to update the configuration information; if the timestamp of the cluster switching message is less than the update time of the configuration information, discard the cluster switching message; and send a request for holding the automatic switching lock to the backup cluster, and after holding the automatic switching lock returned by the backup cluster based on the holding request, send the cluster switching message to the backup cluster.

9. A data request processing system, the system comprising a primary cluster and a backup cluster, the primary cluster and the backup cluster being distributed database clusters; the system further comprising at least one client; the client being configured to: Creating a first connection session for maintaining connection with the primary cluster and creating a second connection session for maintaining connection with the standby cluster, so that the client is in a connected state with the primary cluster and the standby cluster respectively; Get configuration information; If the configuration information indicates that the client preferentially accesses the primary cluster, the data request is preferentially sent to the primary cluster for processing based on the first connection session; If it is determined that the primary cluster fails according to the response result of the primary cluster to the data request, the configuration information is updated so that the client preferentially accesses the standby cluster, so that the client switches the data request to be preferentially sent to the standby cluster for processing based on the second connection session according to the updated configuration information, and sends a cluster switching message to the standby cluster through the second connection session, so that other clients that are connected to the standby cluster update the configuration information so that the client preferentially accesses the standby cluster after listening to the cluster switching message issued by the standby cluster; wherein, obtaining the configuration information includes: listening to the cluster switching message carrying a timestamp issued by the primary cluster and / or the standby cluster, the cluster switching message is used to indicate the cluster that the client preferentially accesses; if the timestamp of the cluster switching message is greater than the update time of the configuration information, using the cluster switching message to update the configuration information; if the timestamp of the cluster switching message is less than the update time of the configuration information, discarding the cluster switching message; The sending of the cluster switching message to the standby cluster includes: sending a holding request for an automatic switching lock to the standby cluster, and after holding the automatic switching lock returned by the standby cluster based on the holding request, sending the cluster switching message to the standby cluster.

10. A computer device comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 7 by running the executable instructions.

11. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Global session backup switching method and device in distributed instant communication software

    CN102426540A

  • Method and device for switching main / standby cluster

    CN107769943A

  • Data request processing method, device, computer equipment and storage medium

    CN108011929A

  • Communication system distributed method based on Redis

    CN111565229A

  • Kafka cluster switching method, device and system, electronic equipment and readable storage medium

    CN111917846A