Data processing method and apparatus
By automatically selecting the data center with the lowest network latency as the target access node, the user experience problem when the application is migrated to a data center where no data replica is deployed is solved, achieving efficient data access and reducing manual configuration costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG E COMMERCE BANK CO LTD
- Filing Date
- 2022-11-29
- Publication Date
- 2026-05-05
AI Technical Summary
When an application is migrated to a data center where no distributed database data replicas are deployed, it cannot access the data normally, resulting in a degraded user experience. Existing solutions rely on manual configuration of virtual mappings, which is costly, or random access leads to network jitter and inefficiency.
By determining the type of data access request and network latency, the system automatically selects the data center with the lowest network latency as the target access node, enabling applications to access data copies from the nearest location and avoiding issues of manual configuration and random access.
It reduces the cost of manual configuration, avoids network jitter and high latency, and improves user experience and data access efficiency.
Smart Images

Figure CN115729982B_ABST
Abstract
Description
Technical Field
[0001] The embodiments in this specification relate to the field of computer technology, and in particular to data processing methods. Background Technology
[0002] Currently, applications are typically deployed in multiple data centers, and users access the applications by calling data copies of distributed databases in the data centers.
[0003] However, as the services and functions offered by the application become more comprehensive and the data grows, the application may be migrated to another data center when the capacity of the data center cannot meet the demand. Since the distributed database data replicas are not deployed in the other data center, the application migrated to that data center cannot access the data from that data center, affecting the user experience. Summary of the Invention
[0004] In view of the above, embodiments of this specification provide a data processing method. One or more embodiments of this specification also relate to a data processing apparatus, a distributed database, a computing device, a computer-readable storage medium, and a computer program, to address the technical deficiencies existing in the prior art.
[0005] According to a first aspect of the embodiments of this specification, a data processing method is provided, applied to a database client, comprising:
[0006] Determine the data access request sent by the application, wherein the data access request carries node information of the initial access node corresponding to the application and data information of the target data;
[0007] Based on the data information, at least two nodes storing the target data are determined to be accessed, and based on the node information, the initial access node is determined.
[0008] If it is determined that the type of the data access request is the target type, and the initial access node and the at least two nodes to be accessed do not belong to the same access node, the target access node is determined from the at least two nodes to be accessed;
[0009] The data access request is processed according to the target access node.
[0010] According to a second aspect of the embodiments of this specification, a data processing apparatus is provided, applied to a client of a distributed database, comprising:
[0011] The first determining module is configured to determine the data access request sent by the application, wherein the data access request carries node information of the initial access node corresponding to the application and data information of the target data.
[0012] The second determining module is configured to determine at least two nodes to be accessed that store the target data based on the data information, and to determine the initial access node based on the node information.
[0013] The third determining module is configured to determine the target access node from the at least two nodes to be accessed when it is determined that the type of the data access request is the target type and the initial access node does not belong to the same access node as the at least two nodes to be accessed.
[0014] The processing module is configured to process the data access request based on the target access node.
[0015] According to a third aspect of the embodiments of this specification, a distributed database is provided, including a client and nodes to be accessed, wherein...
[0016] The client is configured to: determine a data access request sent by an application; determine at least two nodes to be accessed storing the target data based on the data information, and determine the initial access node based on the node information; and determine the target access node from the at least two nodes to be accessed when the type of the data access request is a target type and the initial access node does not belong to the same access node as the at least two nodes to be accessed. The data access request carries node information of the initial access node corresponding to the application and data information of the target data.
[0017] The node to be accessed is configured to process the data access request based on the target access node.
[0018] According to a fourth aspect of the embodiments of this specification, a computing device is provided, comprising:
[0019] Memory and processor;
[0020] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the above-described data processing method.
[0021] According to a fifth aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores computer-executable instructions, which, when executed by a processor, implement the steps of the data processing method described above.
[0022] According to a sixth aspect of the embodiments of this specification, a computer program is provided, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the above-described data processing method.
[0023] This specification provides a data processing method in one embodiment, applied to a database client, which determines a data access request sent by an application, wherein the data access request carries node information of an initial access node corresponding to the application and data information of target data; determines at least two nodes to be accessed storing the target data based on the data information, and determines the initial access node based on the node information; if it is determined that the type of the data access request is a target type, and the initial access node and the at least two nodes to be accessed do not belong to the same access node, determines a target access node from the at least two nodes to be accessed; and processes the data access request based on the target access node.
[0024] The above method identifies at least two nodes storing the target data and determines the initial access node to which the application migrates. If the data access request type is determined to be the target type, and the initial access node and the at least two nodes not belong to the same access node, it indicates that the target data is not stored in the initial access node to which the application migrates, i.e., no data copy of the distributed database is deployed. In this case, the target access node can be determined from the at least two nodes storing the target data, and the application can call the target data stored in the target access node to enable user access to the application and ensure user experience. Attached Figure Description
[0025] Figure 1 This is a diagram illustrating access routing for a distributed database application.
[0026] Figure 2 This is a diagram illustrating another type of access route for distributed database applications;
[0027] Figure 3 This is a schematic diagram illustrating an application scenario of a data processing method provided in one embodiment of this specification;
[0028] Figure 4 This is a flowchart illustrating a data processing method provided in one embodiment of this specification;
[0029] Figure 5 This is a flowchart illustrating the processing procedure of a data processing method provided in one embodiment of this specification.
[0030] Figure 6 This is a schematic diagram of the structure of a data processing apparatus provided in one embodiment of this specification;
[0031] Figure 7 This is a schematic diagram of the structure of a distributed database provided in one embodiment of this specification;
[0032] Figure 8This is a structural block diagram of a computing device provided in one embodiment of this specification. Detailed Implementation
[0033] Many specific details are set forth in the following description to provide a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0034] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0035] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0036] First, the terms and concepts used in one or more embodiments of this specification will be explained.
[0037] Data center: This can be understood as an Internet Data Center (IDC), referring to a facility with complete equipment (including high-speed internet access bandwidth, high-performance local area networks, and a secure and reliable data center environment), professional management, and a comprehensive application service platform. Based on this platform, IDC service providers offer customers basic internet platform services (server hosting, virtual hosting, email caching, virtual mail, etc.) as well as various value-added services (site rental services, domain name system services, load balancing systems, database systems, data backup services, etc.).
[0038] Distributed database: refers to a database built from multiple ordinary computing hardware devices that can be partitioned, deployed across data centers, has one master and multiple backups, and can automatically perform master-slave disaster recovery. It can be deployed and provide services in multiple data centers within the same city and multiple data centers across cities. The client contains high availability logic such as master-slave routing and retry.
[0039] Routing logic: This can be understood as the logic for determining which database copy to access, where the database copy is deployed in the data center.
[0040] Strong consistency: Businesses need to ensure that data can be read immediately after it is updated or written, so they can only read and write to the primary replica.
[0041] Weak consistency: Businesses can tolerate reading old data with a certain delay. For example, they want to read multiple replicas of a distributed database at the same time to improve the system's concurrency capabilities.
[0042] SQL: Structured Query Language, is a special-purpose programming language, a database query and programming language used to access, query, update and manage relational database systems.
[0043] Network latency refers to the round-trip time it takes for a data packet to travel from a user's computer to a web server and then immediately back to the user's computer. Simply put, it's the time it takes for data to travel from one computer to the other.
[0044] In practical applications, as businesses demand higher disaster recovery and high availability, more and more businesses are using distributed databases and deploying them in multiple data centers, achieving availability across multiple data centers within the same city or even across multiple data centers in different cities. While distributed databases support high availability and easy cloud migration, they have also encountered cross-city access problems caused by improper operation and maintenance configurations and incomplete middleware routing logic.
[0045] For example, the original distributed database was deployed in a two-site, three-center configuration. Region 1 had two data centers (data center A and data center B as an example), and Region 2 had one data center D. Each data center deployed a data replica of the distributed database. Data center A deployed the primary data replica of the distributed database, while data centers B and D each deployed their own data replicas of the distributed database. Figure 1 As shown, Figure 1 A schematic diagram of access routing for a distributed database application is shown, such as... Figure 1 As shown, when the data access request sent by the application is a strongly consistent data access request, the application deployed in data center A, the application deployed in data center B, and the application deployed in data center D all access the primary data replica deployed in data center A. When the data access request sent by the application is a weakly consistent data access request, the application deployed in data center A calls the primary data replica deployed in data center A, the application deployed in data center B calls the data replica deployed in data center B, and the application deployed in data center D calls the data replica deployed in data center D.
[0046] When business needs in Region 1 require the application to migrate from data center B to data center C, the distributed database's data replica remains deployed in data center B, while no distributed database data replica is deployed in data center C. When the application in data center C accesses the distributed database, strongly consistent data access requests can still access the primary data replica in data center A; however, weakly consistent data access requests cannot access the data replica in data center C because data center C does not have a distributed database data replica deployed there. In this situation, business personnel can manually configure a virtual mapping for data center C, enabling database clients to call this virtual mapping to access the data replica in either data center A or data center B.
[0047] However, this method of configuring virtual mappings requires business personnel to pay attention not only to the data center where the distributed database is deployed, but also to the data center where the application is deployed, resulting in a large workload and high labor costs. Secondly, when the data replicas of the distributed database are migrated from data center B to data center C, the virtual mappings configured for data center C also need to be deleted. This method is highly dependent on business personnel, places high demands on them, leads to high labor costs, is prone to errors, and lacks flexibility.
[0048] There is another method, see [link] Figure 2 , Figure 2 This diagram illustrates another distributed database application access routing scenario. When an application migrates from data center B to data center C, but the distributed database's data replicas remain deployed in data center B, and the data access request is a weakly consistent data access request, the application deployed in data center C can randomly access any data center, such as data center A, B, or D. However, random access can cause network jitter, thus affecting data access. Furthermore, if a random access occurs to a data center deployed in a different city, it results in cross-city access, leading to poor network communication efficiency and a degraded user experience.
[0049] Therefore, an effective technical solution is urgently needed to solve the above problems.
[0050] This specification provides a data processing method, and also relates to a data processing apparatus, a distributed database, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.
[0051] See Figure 3 , Figure 3 A schematic diagram illustrating an application scenario of a data processing method provided according to an embodiment of this specification is shown.
[0052] Figure 3In this architecture, the distributed database 306 includes data replicas 3062, 3064, and 3068, deployed in data centers A, B, and D, respectively. The distributed application includes clients 3022 in data center A, 3024 in data center B, and 3028 in data center D. When a user accesses the application, the application deployed in data center A can access the data stored in data replica 3062 deployed in data center A through client 3022, thus enabling user access to the application.
[0053] However, when the capacity of data center B is insufficient to meet the application's capacity requirements, the application can be migrated to data center C. In this case, since no distributed database replica is deployed in data center C, the application migrated to data center C cannot retrieve data from data center C through client 3026, and instead randomly accesses data replica 3062 in data center A, data replica 3064 in data center B, or data replica 3068 in data center D. One embodiment of this specification provides a data processing method that, even when the application is migrated to a data center without a deployed data replica, can still access data from the nearest distributed database 306.
[0054] In specific implementation, client 3026 receives a data access request triggered by an application in response to a user's access request. This data access request carries data center information for data center C corresponding to the application. Based on this data center information, client 3026 can determine that the application is deployed in data center C. If the data access request is determined to be of a weak consistency type, and data center C does not have a data replica of distributed database 306 deployed, then from the three data centers A, B, and D that have deployed data replicas 3062, 3064, and 3068, data center D with the lowest network latency can be selected as the target data center. That is, the application can access data replica 3068 deployed in the target data center D through client 1026 and process the data access request based on the target data center D, thereby enabling the application to access the database replica nearest to it.
[0055] like Figure 3As shown, when a user wants to access a music application, the music application by default calls the audio data copy deployed in its corresponding data center. The music application can send an audio data request to client 3026. Client 3026 determines that the music application is deployed in data center C based on the data center information of data center C corresponding to the music application carried in the audio data request. If the audio data request is determined to be a weak consistency request, and data center C does not deploy a data copy of distributed database 306, then data center D with the lowest network latency can be selected from the three data centers A, B, and D that have deployed data copies as the target data center. That is, the application can access the data copy 3068 deployed in the target data center D through client 3026 and process the data access request according to the target data center D, thereby enabling the user to access the application and reducing the high latency problem caused by random access.
[0056] See Figure 4 , Figure 4 A flowchart of a data processing method according to an embodiment of this specification is shown, which specifically includes the following steps.
[0057] Step 402: Determine the data access request sent by the application, wherein the data access request carries node information of the initial access node corresponding to the application and data information of the target data.
[0058] In this context, a data access request can be understood as an application sending a data access request to the database client in response to a user's access request. An application can be understood as an application that provides services to users, such as an application providing resource access services or a music application. The application's backend can access data through the database client. The application's backend can be understood as the backend that processes user access requests when a user accesses the application. The initial access node can be understood as the data center where the application is deployed. The node information of the initial access node can be understood as the information of the data center where the application is deployed; this information can identify the data center. Data center information could be, for example, the data center's identifier or location information. The target data information can be understood as the information of the data that the data access request wants to access. For example, when an application sends a data access request to retrieve music X, the audio data corresponding to music X can be understood as the target data, and X can be understood as the data information of that audio data; based on this data information, the target data can be determined.
[0059] In practical applications, data centers typically deploy applications and data replicas. A data replica can be understood as a copy of a distributed database, storing data that is the same data found in the distributed database. For example, given application A and data replica A deployed in data center A, application A can access data through database client A in data center A. The data replica can correspond to an application; for instance, if the application provides resource access services, the data replica might include resource-related data, such as remaining resource data. Or, if the application is a music application, the data replica could include music-related audio data.
[0060] Based on this, it can be determined that the data access request sent by the application carries information about the data center where the application is deployed, as well as the data information of the target data that the data access request wants to access.
[0061] For example, it can receive a remaining resource query request sent by an application that provides resource access services. The remaining resource query request carries the data center information where the application that provides resource access services is deployed, as well as the remaining resource data that the remaining resource query request wants to query.
[0062] In practical applications, data access requests sent by the application to the database client are usually generated based on user access requests to the application. The specific implementation method is as follows:
[0063] Receive data access requests sent by the application in response to a user's access request.
[0064] In this context, a user access request can be understood as a user's access request to an application. For example, it could be a user's request to query the remaining resources of an application that provides resource access services, or a user's request to play music in a music application.
[0065] Based on this, when an application responds to a user's access request to the application, a data access request can be generated and sent to the database client.
[0066] In summary, the application responds to user access requests by generating and sending data access requests to the database client, providing a basis for the database client to determine the target access node and further enabling user access to the application.
[0067] In practical applications, the data access request is an SQL request, which can specifically be an SQL statement.
[0068] In practical implementation, after determining the data access request sent by the application, the type of data access request can be determined. It's understood that different data access request types will call different nodes to be accessed. In practical applications, distributed databases are backed up into multiple data replicas, one of which serves as the primary data replica. After data in the distributed database is modified or written, the primary data replica synchronizes the data modification and write operations in real time. That is, the data in the primary data replica is backed up in real time, while the data in other data replicas is backed up within a preset time after the primary data replica's synchronization, such as within 2 milliseconds after the primary data replica's synchronization. In other words, the real-time performance of the primary data replica is better than that of other data replicas. When the data access request type is strongly consistent, it is necessary to ensure that data updates or writes can be read immediately. Therefore, for strongly consistent data access requests, the primary data replica will be read. However, when the data access request type is weakly consistent, it indicates that the real-time requirement for the data access request is lower, and it can read older data with a certain delay. In this case, other data replicas can be read instead of the primary data replica. The specific implementation method for determining the type of data access request is as follows:
[0069] The type of the data access request is determined based on the request type identifier carried in the data access request.
[0070] The request type identifier can be understood as an identifier that indicates the type of data access request. For example, for a weakly consistent data access request, if the data access request is an SQL statement, then the request type identifier is hint. When the client receives a data access request carrying this request type identifier, it can determine that the data access request is of a weakly consistent type.
[0071] Based on this, the type of data access request can be determined by the identifier carried in the data access request that indicates the type of data access request.
[0072] In summary, by determining the type of data access request, we can provide a basis for subsequently identifying the target access node that needs to be accessed, thereby determining the target access node with the least network latency and the highest communication efficiency.
[0073] Step 404: Determine at least two nodes to be accessed that store the target data based on the data information, and determine the initial access node based on the node information.
[0074] Specifically, after determining the data access request sent by the application, at least two nodes storing the target data can be identified based on the data information carried in the data access request, and the initial access node can be determined based on the node information.
[0075] The at least two nodes storing the target data can be understood as data centers storing data replicas of the distributed database. Specifically, there are at least two such data centers. The target data can be understood as the data that the data access request wants to access and that belongs to a data replica of the distributed database.
[0076] It is understandable that the application is deployed in the data center and calls the data copy deployed in the same data center. In other words, the target data that the application wants to access exists in the data copy.
[0077] Based on this, at least two data centers storing the target data can be identified according to the data information carried in the data access request. These data centers contain data copies of a distributed database, and the data center where the application is deployed can be determined based on the data center information.
[0078] In practice, the target data can be determined based on the data information, and then at least two nodes to be accessed can be determined based on the target data. The specific implementation method is as follows:
[0079] Based on the data information, determine the target data corresponding to the data access request;
[0080] Based on the target data, at least two nodes storing the target data are identified as to be accessed.
[0081] Specifically, based on the data information carried in the data access request, the target data that the data access request wants to access can be determined, and then based on the target data, at least two nodes storing the target data can be determined to be accessed.
[0082] Using the previous example, we can determine the remaining resource data that the remaining resource query request wants to query based on the data information carried in the remaining resource query request, and then determine the nodes A, B, and C to be accessed that store the remaining resource data based on the remaining resource data.
[0083] In summary, by identifying at least two nodes that store the target data, it becomes easier to determine the target access node from these two nodes. This allows the application to call the data in the target access node, enabling the application to be invoked and, in turn, allowing the user to invoke the application.
[0084] Specifically, the node information includes the node identifier. Accordingly, when determining the initial access node based on the node information, the specific implementation method is as follows:
[0085] The initial access node is determined based on the node identifier.
[0086] Step 406: If it is determined that the type of the data access request is the target type and the initial access node does not belong to the same access node as the at least two nodes to be accessed, determine the target access node from the at least two nodes to be accessed.
[0087] Specifically, after determining the initial access node for application deployment and at least two nodes to be accessed that store the target data, the target access node can be determined from the at least two nodes to be accessed if the type of the data access request is the target type and the initial access node and the at least two nodes to be accessed are different.
[0088] The target type can be understood as a weakly consistent type, where data access requests can read data copies stored in any of the nodes to be accessed. The initial access node and at least two other nodes to be accessed are not the same; this can be understood as the initial access node being distinct from each of the at least two other nodes to be accessed. The target access node can be understood as the node to be accessed that stores the target data.
[0089] Based on this, if the data access request is determined to be of a weak consistency type and the initial access node is different from each of the at least two nodes to be accessed, the target access node can be determined from the at least two nodes to be accessed.
[0090] In specific implementation, determining the target access node from at least two nodes to be accessed includes:
[0091] From the at least two nodes to be accessed, the node that meets the preset conditions is determined as the target access node.
[0092] Among them, the preset conditions can be understood as the conditions for determining the target access node that are set in advance according to actual needs.
[0093] Specifically, from the at least two nodes to be accessed, the node that meets the preset conditions is determined as the target access node, including:
[0094] Determine the target node to be visited from the at least two nodes to be visited;
[0095] If the network latency with the target node to be accessed meets the preset latency condition, the target node to be accessed is determined as the target access node.
[0096] Here, the target node to be visited can be understood as each of the at least two nodes to be visited. The preset delay condition can be understood as sorting the network delays with each node to be visited from largest to smallest, and determining the condition with the smallest network delay based on the sorting result.
[0097] Based on this, for each of at least two nodes to be accessed, the network latency between the database client and each node to be accessed can be determined, and the network latency between the database client and each node to be accessed can be sorted from largest to smallest. Based on the sorting result, the node to be accessed with the smallest network latency can be determined as the target access node.
[0098] Using the previous example, consider nodes A, B, and C that store the remaining resource data. Determine the network latency between the database client and node A as 'a', between the database client and node B as 'b', and between the database client and node C as 'c', where a > b > c. Sort the network latency between the database client and these three nodes in descending order. Based on the sorting result, determine node C, which has the smallest network latency, as the target access node.
[0099] In summary, by identifying the node with the lowest network latency as the target access node, and enabling the application to access the data copy in that target access node, the costly manual configuration of virtual mapping relationships can be eliminated, and problems such as network jitter and high network latency caused by randomly selecting the node to be accessed can be avoided.
[0100] In practical applications, data centers are typically deployed in different regions to meet actual business needs. It's understandable that after an application migrates from data center A in region A to data center B in region B (the initial access node), it cannot access the required data in data center B because there is no data copy of the distributed database there. If it were to cross regions to data center A to access the data copy deployed there, the cross-regional issue would cause high network latency and poor communication efficiency, and would also require manual configuration of virtual mapping relationships. Therefore, data center C (the target access node) located in the same region B as data center B, and which deploys a data copy of the distributed database, can be identified to allow the application to access the data copy in data center C. Specifically, the node information includes a region identifier. Correspondingly, determining the target access node from the at least two access nodes includes:
[0101] Based on the region identifier, determine the target node to be visited corresponding to the region identifier from the at least two nodes to be visited.
[0102] The region identifier can be understood as the identifier of the region where the initial access node is located. Corresponding to the region identifier, it can be understood as being in the same region as the initial access node.
[0103] Based on this, the region where the initial access node is located can be determined according to the region identifier, and then the target access node in the same region as the initial access node can be determined from at least two access nodes.
[0104] Understandably, the database client can obtain the region identifier of each of at least two nodes to be accessed.
[0105] Continuing with the previous example, consider nodes A (region A), B (region B), and C (region B) storing remaining resource data. Based on the region identifier B carried in the data access request, the region where the initial access node is located is determined to be region B. From this region B, nodes B and C, which are in the same region as the initial access node (i.e., located in region B), can be selected as target access nodes. Therefore, in the subsequent process of determining network latency, it is only necessary to determine the network latency between the database client and node B, and the network latency between the database client and node C.
[0106] In summary, by identifying the target node to be accessed that is located in the same region as the initial access node, high-latency cross-city access can be reduced without affecting other types of data access requests, such as the routing logic of strongly consistent data access requests. It does not disrupt the existing database's addressing logic, requires no maintenance, and can be used as a fallback route.
[0107] In addition, after determining the initial access node based on the node information, the process also includes:
[0108] If the data access request is determined to be of the target type and the initial access node and the at least two nodes to be accessed belong to the same access node, the initial access node is determined to be the target access node.
[0109] In this context, the initial access node and at least two nodes to be accessed belong to the same access node, which can be understood as the initial access node being the same as any one of the at least two nodes to be accessed.
[0110] At this point, it can be concluded that the application has not been migrated. That is to say, the initial access node has deployed copies of the application and the distributed database. The application can directly access the data copies in the initial access node without having to select other access nodes.
[0111] In summary, by determining that the initial access node and at least two nodes to be accessed belong to the same access node, data can be retrieved from the data copy in the initial access node deployed by the application according to the original routing addressing logic, without having to select other nodes to be accessed, thus achieving compatibility with the existing addressing logic.
[0112] In addition, after determining the initial access node based on the node information, the process also includes:
[0113] If the data access request is determined to be of a preset access type, a primary node to be accessed is determined from the at least two nodes to be accessed, and the primary node to be accessed is determined as the target access node.
[0114] The default access type can be understood as a strongly consistent type. When the data access request type is strongly consistent, the application needs to call the primary data replica of the distributed database. The primary node to be accessed can be understood as the node to be accessed that has the primary data replica deployed, i.e., the data center where the primary data replica is deployed.
[0115] Based on this, if it is determined that the data access request is a data access request of the strongly consistent type, the node to be accessed that has deployed a primary data replica is determined from at least two nodes to be accessed, and the node to be accessed that has deployed a primary data replica is taken as the target access node.
[0116] In summary, by distinguishing the types of data access requests, the system can determine the node with the least network latency in the case of weakly consistent data access requests, while accessing the node with a primary data replica in the case of strongly consistent data access requests, without affecting the routing logic of strongly consistent reads.
[0117] Step 408: Process the data access request according to the target access node.
[0118] Specifically, after identifying the target access node, the data access request can be processed based on the target access node.
[0119] In this context, processing data access requests based on the target access node can be understood as enabling the application to call the data copy deployed in the target access node through the database client corresponding to the target access node, thereby processing the data access request.
[0120] In summary, the above method identifies at least two nodes storing the target data and determines the initial access node to which the application migrates. If the data access request type is determined to be the target type, and the initial access node and the at least two nodes not belong to the same access node, it indicates that the initial access node to which the application migrates does not store the target data, meaning no distributed database data copy is deployed. In this case, the target access node can be determined from the at least two nodes storing the target data, allowing the application to access the target data stored in that target access node, thus enabling user access to the application and ensuring a positive user experience.
[0121] The following is in conjunction with the appendix Figure 5Taking the application of the data processing method provided in this specification in a music application as an example, the data processing method will be further explained. Figure 5 A flowchart illustrating the processing steps of a data processing method according to an embodiment of this specification is shown, specifically including the following steps.
[0122] Step 502: Receive the data access request sent by the application in response to the user's access request.
[0123] Specifically, it can receive audio data access requests sent by music applications in response to user music playback requests.
[0124] Step 504: Determine the data center where the application is deployed based on the data access request's data center information.
[0125] Step 506: Based on the data information carried in the data access request, determine at least two data centers corresponding to the target data stored in the data information.
[0126] Specifically, each of the at least two data centers deploys a data copy of the distributed database, with one data center deploying a master data copy of the distributed database.
[0127] The target data is the audio data corresponding to the audio data information carried in the audio data access request. For example, it could be the audio data corresponding to the music that the user wants to play. It can be understood that the data center storing the audio data is the data center that has deployed a distributed database replica.
[0128] Step 508: If the data access request is determined to be of weak consistency type and the data center where the application is deployed is different from at least two data centers, determine the data center with the minimum network latency from at least two data centers as the target data center.
[0129] Specifically, when the data access request is a weakly consistent read and the data center where the application is deployed is different from each of the at least two data centers, it means that there is no data copy of the distributed database in the data center where the application is deployed, and therefore no audio data. In this case, the data center with the smallest network latency among the at least two data centers where data copies exist is determined as the target data center.
[0130] Step 510: If it is determined that the data access request is of weak consistency type and the data center where the application is deployed is the same as one of at least two data centers, then the data center where the application is deployed is selected as the target data center.
[0131] Specifically, if the data access request is a weakly consistent read and the data center where the application is deployed is the same as any one of at least two data centers, it means that the data center where the application is deployed has a data copy of the distributed database. In this case, it means that there is audio data in the data center, and the data center where the application is deployed can be directly used as the target data center.
[0132] Step 512: If the data access request is determined to be of a strong consistency type, select the data center with the master data replica of the distributed database deployed from at least two data centers as the target data center.
[0133] Specifically, if the data access request is determined to be a strongly consistent read, the data center where the primary data copy of the distributed database is deployed can be directly identified from at least two data centers where data copies of the distributed database are deployed, and that data center can be used as the target data center.
[0134] Step 514: Call the data copy in the target data center to process the data access request.
[0135] In summary, the above method identifies at least two nodes storing the target data and determines the initial access node to which the application migrates. If the data access request type is determined to be the target type, and the initial access node and the at least two nodes not belong to the same access node, it indicates that the initial access node to which the application migrates does not store the target data, meaning no distributed database data copy is deployed. In this case, the target access node can be determined from the at least two nodes storing the target data, allowing the application to access the target data stored in that target access node, thus enabling user access to the application and ensuring a positive user experience.
[0136] Corresponding to the above method embodiments, this specification also provides data processing apparatus embodiments. Figure 6 A schematic diagram of the structure of a data processing apparatus according to one embodiment of this specification is shown. Figure 6 As shown, the device includes:
[0137] The first determining module 602 is configured to determine a data access request sent by an application, wherein the data access request carries node information of the initial access node corresponding to the application and data information of the target data.
[0138] The second determining module 604 is configured to determine at least two nodes to be accessed that store the target data based on the data information, and to determine the initial access node based on the node information.
[0139] The third determining module 606 is configured to determine the target access node from the at least two nodes to be accessed when it is determined that the type of the data access request is the target type and the initial access node does not belong to the same access node as the at least two nodes to be accessed.
[0140] The processing module 608 is configured to process the data access request based on the target access node.
[0141] In an optional embodiment, the third determining module 606 is further configured to:
[0142] From the at least two nodes to be accessed, the node that meets the preset conditions is determined as the target access node.
[0143] In an optional embodiment, the third determining module 606 is further configured to:
[0144] Determine the target node to be visited from the at least two nodes to be visited;
[0145] If the network latency with the target node to be accessed meets the preset latency condition, the target node to be accessed is determined as the target access node.
[0146] In an optional embodiment, the node information includes a region identifier, and the third determining module 606 is further configured to:
[0147] Based on the region identifier, determine the target node to be visited corresponding to the region identifier from the at least two nodes to be visited.
[0148] In an optional embodiment, the node information includes a node identifier, and the second determining module 604 is further configured to:
[0149] The initial access node is determined based on the node identifier.
[0150] In an optional embodiment, the second determining module 604 is further configured to:
[0151] The type of the data access request is determined based on the request type identifier carried in the data access request.
[0152] In an optional embodiment, the third determining module 606 is further configured to:
[0153] If the data access request is determined to be of the target type and the initial access node and the at least two nodes to be accessed belong to the same access node, the initial access node is determined to be the target access node.
[0154] In an optional embodiment, the third determining module 606 is further configured to:
[0155] If the data access request is determined to be of a preset access type, a primary node to be accessed is determined from the at least two nodes to be accessed, and the primary node to be accessed is determined as the target access node.
[0156] In an optional embodiment, the first determining module 602 is further configured to:
[0157] Receive data access requests sent by the application in response to a user's access request.
[0158] In an optional embodiment, the second determining module 604 is further configured to:
[0159] Based on the data information, determine the target data corresponding to the data access request;
[0160] Based on the target data, at least two nodes storing the target data are identified as to be accessed.
[0161] In an optional embodiment, the data access request is an SQL request.
[0162] In summary, the aforementioned device, by identifying at least two nodes storing the target data and determining the initial access node to which the application has migrated, determines that if the data access request type is the target type and the initial access node does not belong to the same access node as the at least two nodes to be accessed, it indicates that the initial access node to which the application has migrated does not store the target data, i.e., no data copy of the distributed database is deployed. In this case, the target access node can be determined from the at least two nodes storing the target data, enabling the application to call the target data stored in the target access node, thereby enabling the user to access the application and ensuring the user experience.
[0163] The above is an illustrative scheme of a data processing apparatus according to this embodiment. It should be noted that the technical solution of this data processing apparatus and the technical solution of the data processing method described above belong to the same concept. For details not described in detail in the technical solution of the data processing apparatus, please refer to the description of the technical solution of the data processing method described above.
[0164] Corresponding to the above method embodiments, this specification also provides distributed database embodiments. Figure 7 A schematic diagram of the structure of a distributed database 700 provided in one embodiment of this specification is shown. Figure 7 As shown, the distributed database 700 includes:
[0165] Client 702 and node to be accessed 704, where,
[0166] The client 702 is configured to: determine a data access request sent by an application; determine at least two nodes to be accessed storing the target data based on the data information, and determine the initial access node based on the node information; and determine the target access node from the at least two nodes to be accessed when the type of the data access request is a target type and the initial access node does not belong to the same access node as the at least two nodes to be accessed. The data access request carries node information of the initial access node corresponding to the application and data information of the target data.
[0167] The node to be accessed 704 is configured to process the data access request according to the target access node.
[0168] In summary, the aforementioned distributed database identifies at least two nodes storing the target data and determines the initial access node to which the application migrates. If the data access request type is the target type, and the initial access node and the at least two nodes not belong to the same access node, it indicates that the initial access node to which the application migrates does not store the target data, meaning no data copy of the distributed database is deployed. In this case, the target access node can be determined from the at least two nodes storing the target data, allowing the application to access the target data stored in that target access node, thus enabling user access to the application and ensuring a positive user experience.
[0169] The above is an illustrative scheme of a distributed database according to this embodiment. It should be noted that the technical solution of this distributed database and the technical solution of the data processing method described above belong to the same concept. For details not described in detail in the technical solution of the distributed database, please refer to the description of the technical solution of the data processing method described above.
[0170] Figure 8 A structural block diagram of a computing device 800 according to one embodiment of this specification is shown. The components of the computing device 800 include, but are not limited to, a memory 810 and a processor 820. The processor 820 is connected to the memory 810 via a bus 830, and a database 850 is used to store data.
[0171] The computing device 800 also includes an access device 840, which enables the computing device 800 to communicate via one or more networks 860. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 840 may include one or more of any type of wired or wireless network interface (e.g., a network interface card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0172] In one embodiment of this application, the aforementioned components of the computing device 800 and Figure 8 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 8 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this application. Those skilled in the art can add or replace other components as needed.
[0173] The computing device 800 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 800 can also be a mobile or stationary server.
[0174] The processor 820 is configured to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the above-described data processing method.
[0175] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the data processing method described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the data processing method described above.
[0176] An embodiment of this specification also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the above-described data processing method.
[0177] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the data processing method described above belong to the same concept. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the data processing method described above.
[0178] An embodiment of this specification also provides a computer program, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the above-described data processing method.
[0179] The above is an illustrative example of a computer program according to this embodiment. It should be noted that the technical solution of this computer program and the technical solution of the data processing method described above belong to the same concept. Details not described in detail in the technical solution of the computer program can be found in the description of the technical solution of the data processing method described above.
[0180] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0181] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0182] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments in this specification are not limited to the described order of actions, because according to the embodiments in this specification, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments in this specification.
[0183] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0184] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the embodiments described herein. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the embodiments, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A data processing method applied to a database client, comprising: Determine the data access request sent by the application, wherein the data access request carries node information of the initial access node corresponding to the application and data information of the target data; Based on the data information, at least two nodes to be accessed that store the target data are determined, and the initial access node is determined based on the node information of the initial access node; If the type of the data access request is determined to be a target type, and the initial access node and the at least two nodes to be accessed do not belong to the same access node, a target access node is determined from the at least two nodes to be accessed, wherein the target type is a weakly consistent type; The data access request is processed according to the target access node.
2. The method according to claim 1, wherein determining the target access node from the at least two nodes to be accessed comprises: From the at least two nodes to be accessed, the node that meets the preset conditions is determined as the target access node.
3. The method according to claim 2, wherein determining the node to be accessed that meets the preset conditions from the at least two nodes to be accessed as the target access node includes: Determine the target node to be visited from the at least two nodes to be visited; If the network latency with the target node to be accessed meets the preset latency condition, the target node to be accessed is determined as the target access node.
4. The method according to claim 3, wherein the node information includes a node identifier and a region identifier; Accordingly, determining the initial access node based on the node information includes: The initial access node is determined based on the node identifier; Accordingly, determining the target node to be visited from the at least two nodes to be visited includes: Based on the region identifier, determine the target node to be visited corresponding to the region identifier from the at least two nodes to be visited.
5. The method according to claim 1, further comprising, after determining the data access request sent by the application: The type of the data access request is determined based on the request type identifier carried in the data access request.
6. The method according to claim 1, further comprising, after determining the initial access node based on the node information: If the data access request is determined to be of the target type and the initial access node and the at least two nodes to be accessed belong to the same access node, the initial access node is determined to be the target access node.
7. The method according to claim 1, further comprising, after determining the initial access node based on the node information: If the data access request is determined to be of a preset access type, a primary node to be accessed is determined from the at least two nodes to be accessed, and the primary node to be accessed is determined as the target access node, wherein the preset access type is a strong consistency type.
8. The method according to claim 1, wherein determining the data access request sent by the application includes: Receive data access requests sent by the application in response to a user's access request.
9. The method according to claim 1, wherein determining at least two nodes to be accessed storing the target data based on the data information comprises: Based on the data information, determine the target data corresponding to the data access request; Based on the target data, at least two nodes storing the target data are identified as to be accessed.
10. The method according to claim 1, wherein the data access request is an SQL request.
11. A distributed database, comprising clients and nodes to be accessed, wherein, The client is configured to: determine a data access request sent by an application; determine at least two nodes to be accessed storing target data based on data information, and determine the initial access node based on the node information of the initial access node; and determine the target access node from the at least two nodes to be accessed when the type of the data access request is a target type and the initial access node does not belong to the same access node as the at least two nodes to be accessed. The data access request carries the node information of the initial access node corresponding to the application and the data information of the target data, and the target type is a weakly consistent type. The node to be accessed is configured to process the data access request based on the target access node.
12. A data processing apparatus, applied to a client of a distributed database, comprising: The first determining module is configured to determine the data access request sent by the application, wherein the data access request carries node information of the initial access node corresponding to the application and data information of the target data. The second determining module is configured to determine at least two nodes to be accessed that store the target data based on the data information, and to determine the initial access node based on the node information of the initial access node. The third determining module is configured to determine a target access node from the at least two nodes to be accessed when it is determined that the type of the data access request is a target type and the initial access node and the at least two nodes to be accessed do not belong to the same access node, wherein the target type is a weakly consistent type; The processing module is configured to process the data access request based on the target access node.
13. A computing device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the method according to any one of claims 1 to 10.
14. A computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Network access control method and server server
CN106572069A
Multi-copy weak consistency maintenance method for distributed storage system
CN107609090A