Data access method and device, medium, electronic equipment and program product
By receiving business requests, extract the target routing key and determine whether it is a hot -spiced routing key, so as to select the appropriate service node group processing request from the service node cluster, solving the unable to take into account the cache rate and request throughput in the existing technology. The problem realizes more efficient remote call interface performance.
Patent Information
- Application Number
- CN202411304376.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-09-18
AI Technical Summary
In the prior art, when processing access requests for hotspot tables, it is impossible to take into account the local cache hit rate and request throughput limit of the service node.
By receiving business requests, the target routing key is extracted to determine whether it is a hot routing key. If it, determine the corresponding service node group from the service node cluster, and select a target node from the group to process the request.
Diversify the business request of the hot spot button to the fixed service group, which can not only ensure the cache hits, but also improve the request throughput upper limit, thereby improving the performance of the remote call interface.
Smart Images

Figure CN119336839A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer network technology, and in particular, to a data access method, device, medium, electronic device and program product. Background Art
[0002] The table data is stored in the database, and the upstream business usually uses the Software Development Kit (SDK) deployed on it to schedule the corresponding service nodes in the service node cluster to access the table data. If the consistent hashing method is used to schedule the service node according to the table's routing key (RouteKey), the local cache of the service node can be effectively used to improve the performance of the remote call interface. However, when a hot table appears, the CPU of the corresponding service node will be fully occupied by an access request for a hot table. The request throughput of the hot table is limited by the CPU performance of the corresponding service node. If a random or polling scheduling method is used to scatter the table to multiple service nodes, the local cache cannot be effectively utilized, and the performance of the remote call interface will be affected. It can be seen that the single service node scheduling method commonly used in related technologies cannot take into account both the local cache hit rate of the service node and the upper limit of the request throughput supporting the hot routing key. Summary of the invention
[0003] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0004] In a first aspect, the present disclosure provides a data access method, applied to a first service node, comprising: In response to receiving a first service request, extracting a target routing key in the first service request; Determine whether the target routing key is a hotspot routing key; If the target routing key is a hotspot routing key, determining a service node group corresponding to the target routing key from a service node cluster; Determine a first target node for responding to the first service request from the service node group; The first service request is sent to the first target node.
[0005] In a second aspect, the present disclosure provides a data access device, applied to a first service node, comprising: An extraction module, configured to extract a target routing key in the first service request in response to receiving the first service request; A first determination module, used to determine whether the target routing key is a hotspot routing key; A second determination module, configured to determine a service node group corresponding to the target routing key from a service node cluster if the target routing key is a hotspot routing key; A third determination module, configured to determine a first target node for responding to the first service request from the service node group; A sending module is used to send the first service request to the first target node.
[0006] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the data access method provided in the first aspect of the present disclosure.
[0007] In a fourth aspect, the present disclosure provides an electronic device, including: a storage device having a computer program stored thereon; A processing device is used to execute the computer program in the storage device to implement the steps of the data access method provided in the first aspect of the present disclosure.
[0008] In a fifth aspect, the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the data access method provided in the first aspect of the present disclosure.
[0009] In the above technical solution, when the first business request is received, the target routing key in the first business request is first extracted; then, it is determined whether the target routing key is a hotspot routing key; if the target routing key is a hotspot routing key, the service node group corresponding to the target routing key is determined from the service node cluster; next, the first target node for responding to the first business request is determined from the service node group corresponding to the target routing key, and the first business request is sent to the first target node. In this way, the business requests of the hotspot routing key can be dispersed to the fixed service group corresponding to the target routing key, which can improve the request throughput upper limit of the hotspot routing key while ensuring the cache hit rate as much as possible, thereby improving the performance of the remote call interface.
[0010] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings: Figure 1 It is a schematic diagram showing the structure of a distributed system according to an exemplary embodiment.
[0012] Figure 2 The invention is a flowchart of a data access method according to an exemplary embodiment.
[0013] Figure 3 The present invention is a timing diagram showing a method of determining a second service node for responding to a first service request according to an exemplary embodiment.
[0014] Figure 4 The figure is a timing diagram of a consistent hashing construction according to an exemplary embodiment.
[0015] Figure 5 The diagram is a schematic diagram showing a method of determining a second service node for responding to a first service request according to an exemplary embodiment.
[0016] Figure 6 The invention is a flowchart showing a method of determining a first target node from a service node group according to an exemplary embodiment.
[0017] Figure 7 The diagram is a timing diagram of a service request execution according to an exemplary embodiment.
[0018] Figure 8 The invention is a block diagram of a data access device according to an exemplary embodiment.
[0019] Fig. 9 The diagram is a schematic structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0020] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0021] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0022] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0023] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0024] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0025] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0026] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0027] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0028] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0029] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0030] At the same time, it is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0031] Figure 1 FIG. 1 is a schematic diagram showing a structure of a distributed system according to an exemplary embodiment. Figure 1 As shown, the distributed system may include at least one client, a first service node, and a service node cluster.
[0032] The service node cluster includes multiple second service nodes, each client is connected to the first service node, and the first service node is connected to each second service node in the service node cluster. A user can initiate a service request through the client, and the client responds to receiving the service request and sends it to the first service node.
[0033] There are two different types of service nodes, the second service node and the first service node, each of which has different functions and roles. Among them, the first service node is a device used to determine the path of the service request from the source to the destination. It usually does not process business logic, but focuses on the routing decision of the business request. For example, the first service node is a routing server. The second service node is used to process the client's business request and execute the corresponding business logic, such as querying the database, generating reports, processing transactions, etc. For example, the second service node is a business server.
[0034] Figure 2 FIG. 1 is a flow chart of a data access method according to an exemplary embodiment. The method can be applied to a first service node in a distributed system. Figure 2 As shown, the data access method applied to the first service node may include the following S101-S105.
[0035] In S101, in response to receiving a first service request, a target routing key in the first service request is extracted.
[0036] In the present disclosure, a user may initiate a first service request through a client, and after receiving the first service request, the client sends it to a first service node, wherein the first service request includes a target routing key; after receiving the first service request, the first service node may extract the target routing key from the first service request by parsing the first service request.
[0037] In load balancing, a route key is an identifier or key value used to determine how to assign a request or message to the second service node of the backend. RouteKey is a distinguishing string used to uniquely identify something. For example, in a table data business, RouteKey can be a document identifier, and in an e-commerce business, RouteKey can be a product identifier.
[0038] In S102, it is determined whether the target routing key is a hotspot routing key.
[0039] Specifically, the hotspot routing key list may be obtained first; if the target routing key exists in the hotspot routing key list, the target routing key is determined to be the hotspot routing key; if the target routing key does not exist in the hotspot routing key list, the target routing key is determined to be a non-hotspot routing key.
[0040] In S103, if the target routing key is a hotspot routing key, a service node group corresponding to the target routing key is determined from the service node cluster.
[0041] In S104, a first target node for responding to the first service request is determined from the service node group.
[0042] In this disclosure, Figure 3 As shown, when the target routing key is a hotspot routing key, a hybrid routing strategy can be adopted to determine the first target node for responding to the first business request from the service node cluster, that is, to turn on Hybrid routing. Specifically, the service node group corresponding to the target routing key can be first determined from the service node cluster, and then the first target node for responding to the first business request can be determined from the service node group.
[0043] In S105, the first service request is sent to the first target node.
[0044] After determining the first target node for responding to the first service request, the first service node may send it to the first target node so that the first target node responds to the first service request. After receiving the first service request, the first target node may directly execute the first service request.
[0045] In the above technical solution, when the first business request is received, the target routing key in the first business request is first extracted; then, it is determined whether the target routing key is a hotspot routing key; if the target routing key is a hotspot routing key, the service node group corresponding to the target routing key is determined from the service node cluster; next, the first target node for responding to the first business request is determined from the service node group corresponding to the target routing key, and the first business request is sent to the first target node. In this way, the business requests of the hotspot routing key can be dispersed to the fixed service group corresponding to the target routing key, which can improve the request throughput upper limit of the hotspot routing key while ensuring the cache hit rate as much as possible, thereby improving the performance of the remote call interface.
[0046] In a possible implementation manner, the data access method applied to the first service node may be executed by the SDK on the first service node; in this case, Figure 4 As shown, before the above S101, the above data access method applied to the first service node may further include the following four steps: When the first service node is started, the SDK is initialized; Obtain connection information of each second service node in the service node cluster; Based on the virtual nodes corresponding to each second service node in the service node cluster, a hash ring is constructed using a consistent hashing algorithm; Based on the connection information, a persistent connection between the software development kit and each second service node in the service node cluster is established and maintained in the connection pool.
[0047] In the present disclosure, in order to use the SDK, after being started, the first service node first pulls the SDK code, and then actively calls the Init method provided by the SDK to complete the SDK initialization.
[0048] After the SDK is initialized, you can use the SDK to perform service discovery, that is, obtain the connection information of each second service node in the service node cluster from the service registration center, where the connection information includes the IP address information, computer room information, and cluster information of each second service node in the service node cluster. The service registration center is a common component of the distributed system. Each second service node in the service node cluster will report its own connection information to the service registration center. The SDK can query the service registration center to obtain which second service nodes are included in the service node cluster, and then perform subsequent hash ring construction and connection pool maintenance.
[0049] After obtaining the connection information of each second service node in the service node cluster, the SDK can map each second service node in the service node cluster to 64 times the number of virtual nodes. After that, a hash ring is constructed using a consistent hashing algorithm through the virtual nodes corresponding to each second service node to alleviate the problem of uneven distribution on the hash ring and make the load more balanced.
[0050] For example, the service node cluster includes two second service nodes (real physical service nodes) node1 and node2. When the consistent hashing algorithm is used to construct the hash ring, node1 and node2 are first mapped to 64 times the number of virtual nodes respectively, and a total of 128 virtual nodes are obtained, namely {node1_1, node1_2, ...., node1_64, node2_1, node2_2, ..., node2_64}. These 128 virtual nodes are then used to construct the hash ring.
[0051] After obtaining the connection information of each second service node in the service node cluster, the SDK can establish a long connection between the SDK and the second service node in the connection pool for each second service node in the service node cluster according to the IP address information of the second service node, and regularly check whether the long connection is disconnected. If disconnected, the SDK will re-establish the connection, that is, keep the connection alive, to maintain the long connection in the connection pool.
[0052] At this time, the above S105 may include: sending the first service request to the first target node through the long connection between the software development kit and the first target node. In this way, the first service request can be directly sent to the first target node using the corresponding long connection that has been established in the connection pool, without having to perform a connection establishment operation after determining the first target node, thereby improving the response efficiency of the service request.
[0053] like Figure 5 As shown, the above-mentioned Hybrid routing strategy can adopt two-layer routing. The first-layer routing maps the target routing key to a service node group through a consistent hashing algorithm, wherein the size of the service node group supports runtime adjustment; the second-layer routing can combine a random algorithm and the load information of each second service node in the service node group to select a first target node for responding to the first business request from the service nodes corresponding to the target routing key.
[0054] For example, the service node group selected using the consistent hashing algorithm is service node group F2. At this time, the first target node for responding to the first business request can be determined from second service node 4, second service node 5 and second service node 6 in combination with the random algorithm and the load information of each second service node in service node group F2.
[0055] As another example, the service node group selected by the consistent hashing algorithm is service node group F1. At this time, the first target node for responding to the first business request can be determined from second service node 1, second service node 2 and second service node 3 in combination with the random algorithm and the load information of each second service node in service node group F1.
[0056] Specifically, determining the service node group corresponding to the target routing key from the service node cluster in S103 may include the following steps (a1) to (a3): Step (a1): Based on the consistent hashing algorithm, determine the virtual node that matches the target routing key from the pre-built hash ring.
[0057] Specifically, the hash value of the target routing key can be calculated first; then, the hash value is used to calculate the target routing key. 32 Then, according to the position of the modulo value on the pre-built hash ring, search clockwise along the hash ring, and the first virtual node encountered is the virtual node that matches the target routing key. The above hash ring is based on the virtual nodes corresponding to each second service node in the service node cluster and is constructed using a consistent hashing algorithm.
[0058] Step (a2): Determine a second target node corresponding to the matching virtual node from the service node cluster.
[0059] In the present disclosure, there is a corresponding relationship between the second service node and the 64 times of virtual nodes it is mapped to, that is, one second service node corresponds to 64 virtual nodes based on the mapping of the second service node, based on which the second target node corresponding to the matching virtual node can be determined.
[0060] Step (a3): In the service node cluster, starting from the second target node, traverse a preset number of second service nodes in a preset direction to obtain a service node group corresponding to the target routing key.
[0061] In the present disclosure, each second service node in the service node cluster can be stored in the form of a list. In the second service node list, the second target node can be used as the starting position to traverse a preset number (N) of second service nodes forward or backward, and the traversed N second service nodes are determined as the service node group corresponding to the target routing key. N can be a default value or a value set by the R&D personnel.
[0062] For example, N is 4, and the service node cluster includes node1, node2, node3, node4, node5, node6, node7, and node8, among which the second target node is node3. At this time, starting from node3, traverse the four second service nodes backward to obtain the service node group corresponding to the target routing key, including node3, node4, node5, and node6.
[0063] Particularly, when traversing in a preset direction, if the last second service node in the service node cluster is traversed, the traversal continues from the first second service node in the service node cluster.
[0064] For example, N is 4, and the service node cluster includes node1, node2, node3, node4, node5, node6, node7, and node8, among which the second target node is node7. At this time, taking node7 as the starting position, after traversing backward through two second service nodes, traverse backward through two second service nodes starting from node1, and obtain the service node group corresponding to the target routing key including node7, node8, node1, and node2.
[0065] The following is a detailed description of the specific implementation of determining the first target node for responding to the first service request from the service node group in S104. Specifically, it can be implemented through multiple implementations. In one implementation, a second service node is randomly selected from the service node group as the first target node.
[0066] In another implementation, a polling strategy may be used to select a second service node from the service node group as the first target node.
[0067] In yet another implementation, the first target node may be determined from the service node group according to the first load information of each second service node in the service node group.
[0068] like Figure 3 As shown, the first service node can periodically obtain the first load information of each second service node in the service node cluster, and update the first load information of each second service node stored locally. The first load information may include CPU usage, memory usage, etc.
[0069] In this embodiment, when determining the first target node for responding to the first business request from the service node cluster, the first load information of each second service node in the service node group is taken into consideration. In this way, the problem of delayed response to the first business request due to high load of the selected second service node can be avoided, thereby improving the response efficiency of the business request.
[0070] The following is a detailed description of the specific implementation method of determining the first target node from the service node group based on the first load information of each second service node in the service node group. Specifically, it can be implemented through multiple implementation methods. In one implementation method, the second service node with the lowest CPU usage or memory usage in the service group can be determined as the first target node.
[0071] In another embodiment, a second service node in a low-load state is determined from the service node group; then, a second service node is randomly selected from the second service nodes in a low-load state as the first target node.
[0072] In the present disclosure, if the CPU usage of the second service node is greater than the second preset usage threshold or the memory usage is greater than the third preset usage threshold, it is determined that the second service node is in a high load state; if the CPU usage of the second service node is less than or equal to the second preset usage threshold, and the memory usage is less than or equal to the third preset usage threshold, it is determined that the second service node is in a low load state.
[0073] In another embodiment, the first load information of each second service node in the service node group may be used to Figure 6 S201-S205 shown in the figure determine the first target node from the service node group: In S201, a second service node is randomly selected from the service node group as a candidate service node.
[0074] In S202, it is determined whether the candidate service node is in a high load state according to first load information of the candidate service node.
[0075] In the present disclosure, if the candidate service node is not in a high load state, that is, the candidate service node is in a low load state, it indicates that the candidate service node has idle resources to process the first business request. At this time, the candidate service node can be determined as the first target node for responding to the first business request, that is, execute the following S205; if the candidate service node is in a high load state, it indicates that the candidate service node has no idle resources to process the first business request. At this time, the second service node can be reselected from the service group, that is, execute the following S203.
[0076] In S203, it is determined whether the number of cycles reaches a preset number.
[0077] In the present disclosure, if the number of cycles does not reach the preset number, the process returns to the above S201; if the number of cycles reaches the preset number, the following S204 is executed.
[0078] The preset number of times may be a default value or a value set by a developer. Preferably, the preset number of times is equal to the preset number N, so that each second service node in the service node group can be randomly selected as much as possible.
[0079] In S204, the most recently selected candidate service node is determined as the first target node.
[0080] In S205, the candidate service node is determined as the first target node.
[0081] In this implementation, a second service node is first randomly selected from the service node group, and then it is determined whether the selected second service node meets the low load requirement. In this way, the candidate service node randomly selected for the first time may meet the low load requirement, thereby quickly determining the first target node.
[0082] In a possible implementation manner, the data access method applied to the first service node may include the following steps: If the target routing key is a non-hotspot routing key, determine a third target node corresponding to the target routing key from the service node cluster; The first service request is sent to the third target node.
[0083] When the target routing key is a non-hotspot routing key, a third target node corresponding to the target routing key is determined from the service node cluster, and the third target node is determined as the second service node for responding to the first service request. In this way, for a non-hotspot routing key, it is routed to the same second service node corresponding to the non-hotspot routing key, thereby effectively utilizing the local cache of the service node to improve the performance of the remote call interface.
[0084] The specific implementation method of determining the third target node corresponding to the target routing key from the service node cluster is described in detail below. Specifically, it can be implemented through the following steps (b1) and (b2).
[0085] Step (b1): Based on the consistent hashing algorithm, determine the virtual node that matches the target routing key from the pre-built hash ring.
[0086] Step (b2): determining the second service node corresponding to the matching virtual node in the service node cluster as the third target node.
[0087] In a possible implementation manner, the data access method applied to the first service node may further include the following steps: In response to receiving the retry instruction sent by the fourth target node, the hotspot routing key list is updated according to the target routing key, and then the step of determining the service node group corresponding to the target routing key from the service node cluster is returned, that is, returning to the above S103.
[0088] In the present disclosure, the fourth target node is the second service node in the service node cluster that receives the first service request, which can be the first target node or the third target node. The retry instruction is used to instruct the first service node to reallocate the second service node for the first service request, the retry instruction includes a target routing key, and the retry instruction is sent by the fourth target node when the target routing key is determined to be a hotspot routing key according to its own second load information.
[0089] Specifically, if Figure 7 As shown, after receiving the first service request, the fourth target node first extracts the target routing key in the first service request; then, according to the second load information of the fourth target node, it determines whether the target routing key is a hotspot routing key, that is, it determines whether the target routing key is a hotspot routing key relative to the fourth target node; if the target routing key is a non-hotspot routing key, it indicates that the fourth target node has idle resources to process the first service request. At this time, the fourth service service can directly execute the first service request, thereby ensuring the local cache hit rate of the service node; if the target routing key is a hotspot routing key, it indicates that the fourth target node has no idle resources to process the first service request. At this time, a retry instruction containing the target routing key can be sent to the first service node. After receiving the retry instruction, the first service node parses the retry instruction and extracts the target routing key from the retry instruction. Then, according to the target routing key, the hotspot routing key list is updated, and the second service node for responding to the first service request is re-determined through a hybrid routing strategy, that is, the service node group corresponding to the target routing key is determined from the service node cluster, and the first target node for responding to the first service request is determined from the service node group, and the first service request is sent to the first target node.
[0090] In the above implementation, when the target routing key is a hot routing key relative to the fourth target node, the second service node is reselected from the service group to distribute the first business request to other second service nodes for execution, which can make the load more balanced and avoid overload of the fourth target node.
[0091] In addition, the second load information may include the CPU usage rate and the number of second business requests being executed by the fourth target node, wherein the second business request is a business request carrying a target routing key. At this time, the fourth target node may determine that the target routing key is a hotspot when the number of second business requests being executed reaches a preset number threshold and the CPU usage rate of the fourth target node is greater than the first preset usage rate threshold; the fourth target node determines that the target routing key is a non-hotspot routing key when the number of second business requests being executed does not reach the preset number threshold or the CPU usage rate of the fourth target node is less than or equal to the first preset usage rate threshold.
[0092] In this way, when the number of second business requests being executed reaches the preset threshold, but the CPU usage of the fourth target node is not high, it indicates that the fourth target node can still withstand the current task request without dispersing the request to other second service nodes, thereby ensuring the local cache hit rate of the fourth target node.
[0093] Among them, R&D personnel can configure the above preset quantity threshold and the first preset usage rate threshold through the dynamic configuration center (a common component of the distributed system), and can modify them at any time. In order to ensure the accuracy of the hotspot routing key configuration (including the above preset quantity threshold and the first preset usage rate threshold), such as Figure 7 As shown, the fourth target node can periodically obtain the hotspot routing key configuration from the dynamic configuration center to refresh the local hotspot routing key configuration.
[0094] The specific implementation method of updating the hotspot routing key list according to the target routing key is described in detail below.
[0095] Specifically, if the target routing key exists in the hotspot routing key list, the time to live (TTL) of the target routing key in the hotspot routing key list is updated to 0, that is, the time to live of the target routing key is recalculated; if the target routing key does not exist in the hotspot routing key list, the target routing key is added to the hotspot routing key list.
[0096] The survival time is the duration of the target routing key in the hotspot routing key list.
[0097] Since hotspot routing keys are usually time-sensitive, each hotspot routing key in the hotspot routing key list has a lifespan. If the lifespan reaches a preset time, it will no longer be used as a hotspot routing key. Specifically, it can be implemented in a variety of ways. In one embodiment, the data access method applied to the first service node may include the following steps: Delete the hotspot routing key whose survival time reaches the preset time from the hotspot routing key list.
[0098] In another implementation, the data access method applied to the first service node may include the following steps: Set the hotspot routing key in the hotspot routing key list whose survival time reaches the preset time to an invalid routing key.
[0099] At this time, if the target routing key exists in the hotspot routing key list, determining the target routing key as the hotspot routing key may include: if the target routing key exists in other routing keys except the invalid routing key in the hotspot routing key list, determining the target routing key as the hotspot routing key.
[0100] In addition, in addition to being updated according to the retry instruction sent by the fourth target node, the above hotspot routing key can also include some manually set hotspot routing keys, thereby increasing the diversity of the hotspot routing key list and making the data access method more flexible and user-friendly. Specifically, the data access method applied to the first service node can also include the following steps: Regularly obtain manually configured hotspot routing keys from the dynamic configuration center (such as Figure 3 ), and add the manually configured hotspot routing key obtained to the hotspot routing key list.
[0101] Figure 8 3 is a block diagram of a data access device according to an exemplary embodiment. The data access device 300 can be applied to a first service node. Figure 8 As shown, the data access device 300 may include: The extraction module 301 is used for extracting a target routing key in the first service request in response to receiving the first service request; A first determination module 302 is used to determine whether the target routing key is a hotspot routing key; The second determination module 303 is used to determine the service node group corresponding to the target routing key from the service node cluster if the target routing key is a hotspot routing key; A third determination module 304 is used to determine a first target node for responding to the first service request from the service node group; The sending module 305 is configured to send the first service request to the first target node.
[0102] In the above technical solution, when the first business request is received, the target routing key in the first business request is first extracted; then, it is determined whether the target routing key is a hotspot routing key; if the target routing key is a hotspot routing key, the service node group corresponding to the target routing key is determined from the service node cluster; next, the first target node for responding to the first business request is determined from the service node group corresponding to the target routing key, and the first business request is sent to the first target node. In this way, the business requests of the hotspot routing key can be dispersed to the fixed service group corresponding to the target routing key, which can improve the request throughput upper limit of the hotspot routing key while ensuring the cache hit rate as much as possible, thereby improving the performance of the remote call interface.
[0103] Optionally, the third determination module 304 is used to determine the first target node from the service node group according to the first load information of each second service node in the service node group.
[0104] Optionally, the third determining module 304 includes: A random selection submodule, used to randomly select a second service node from the service node group as a candidate service node; A first determining submodule, configured to determine whether the candidate service node is in a high load state according to first load information of the candidate service node; a triggering submodule, configured to trigger the random selection submodule to randomly select a second service node from the service node group as a candidate service node if the candidate service node is in the high load state, until the number of cycles reaches a preset number; The second determining submodule is configured to determine the candidate service node selected most recently as the first target node if the number of cycles reaches the preset number of times.
[0105] Optionally, the third determining module 304 further includes: The third determining submodule is configured to determine the candidate service node as the first target node if the candidate service node is not in the high load state.
[0106] Optionally, the second determining module 303 includes: A fourth determination submodule, configured to determine a virtual node matching the target routing key from a pre-constructed hash ring based on a consistent hashing algorithm, wherein the hash ring is constructed based on virtual nodes corresponding to each second service node in the service node cluster using a consistent hashing algorithm; A fifth determination submodule, configured to determine a second target node corresponding to the matching virtual node from the service node cluster; The traversal submodule is used to traverse a preset number of second service nodes in the service node cluster in a preset direction with the second target node as the starting position, to obtain a service node group corresponding to the target routing key.
[0107] Optionally, the data access device 300 further includes: a fourth determination module, configured to determine a third target node corresponding to the target routing key from the service node cluster if the target routing key is a non-hotspot routing key; The sending module 305 is further configured to send the first service request to the third target node.
[0108] Optionally, the fourth determining module includes: a sixth determination submodule, configured to determine a virtual node matching the target routing key from a pre-constructed hash ring based on a consistent hashing algorithm, wherein the hash ring is constructed based on virtual nodes corresponding to each second service node in the service node cluster and using a consistent hashing algorithm; The seventh determination submodule is used to determine the second service node corresponding to the matching virtual node in the service node cluster as the third target node.
[0109] Optionally, the first determining module 302 includes: Get submodule, used to get hotspot routing key list; The eighth determination submodule is used to determine that the target routing key is a hotspot routing key if the target routing key exists in the hotspot routing key list.
[0110] Optionally, the data access device 300 further includes: An update module, configured to update the hotspot routing key list according to the target routing key in response to receiving a retry instruction sent by a fourth target node, wherein the retry instruction is used to instruct the first service node to reallocate a second service node for the first service request, the retry instruction includes the target routing key, and the retry instruction is sent by the fourth target node when determining that the target routing key is a hotspot routing key according to its own second load information, and the fourth target node is the second service node in the service node cluster that receives the first service request; The trigger module is used to trigger the second determination module 303 to determine the service node group corresponding to the target routing key from the service node cluster.
[0111] Optionally, the second load information includes a CPU usage rate and a number of second service requests being executed by the fourth target node, wherein the second service request is a service request carrying the target routing key; The fourth target node determines that the target routing key is a hotspot when the number reaches a preset number threshold and the CPU usage of the fourth target node is greater than a first preset usage threshold.
[0112] Optionally, the update module includes: A first updating submodule, for updating the life time of the target routing key in the hotspot routing key list to 0 if the target routing key exists in the hotspot routing key list, wherein the life time is the duration of existence of the target routing key in the hotspot routing key list; The second updating submodule is used to add the target routing key to the hotspot routing key list if the target routing key does not exist in the hotspot routing key list.
[0113] Optionally, the data access device 300 further includes: The deleting module is used to delete the hotspot routing key whose survival time reaches a preset time length from the hotspot routing key list.
[0114] Optionally, the data access device 300 further includes: An invalidation module is used to set the hotspot routing key in the hotspot routing key list whose survival time reaches a preset time as an invalid routing key; The eighth determination submodule is used to determine that the target routing key is a hotspot routing key if the target routing key exists in other routing keys except the invalid routing key in the hotspot routing key list.
[0115] Optionally, the data access device 300 further includes: The first acquisition module is used to periodically acquire manually configured hotspot routing keys from the dynamic configuration center, and add the acquired manually configured hotspot routing keys to the hotspot routing key list.
[0116] Optionally, the data access device 300 is executed by a software development kit on the first service node; The data access device 300 further includes: an initialization module, used to initialize the software development kit when the first service node is started; A second acquisition module, used to acquire connection information of each second service node in the service node cluster; A hash ring construction module, used to construct a hash ring using a consistent hashing algorithm based on the virtual nodes corresponding to each second service node in the service node cluster; A connection pool maintenance module, used to establish and maintain a long connection between the software development kit and each second service node in the service node cluster in the connection pool based on the connection information; The sending module 305 is used to send the first service request to the first target node through the long connection between the software development kit and the first target node.
[0117] The present disclosure also provides a computer-readable medium having a computer program stored thereon, and when the computer program is executed by a processing device, the steps of the above-mentioned data access method provided by the present disclosure are implemented.
[0118] The present disclosure also provides a computer program product, including a computer program, which implements the steps of the above data access method provided by the present disclosure when executed by a processor.
[0119] Reference below Fig. 9 , which shows an electronic device (eg, Figure 1 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig. 9 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0120] like Fig. 9 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0121] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Fig. 9The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0122] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0123] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0124] In some embodiments, the first service node may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0125] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0126] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: in response to receiving a first service request, extract the target routing key in the first service request; determine whether the target routing key is a hotspot routing key; if the target routing key is a hotspot routing key, determine the service node group corresponding to the target routing key from the service node cluster; determine the first target node for responding to the first service request from the service node group; send the first service request to the first target node. The computer program code for performing the operation of the present disclosure can be written in one or more programming languages or a combination thereof, and the programming languages include but are not limited to object-oriented programming languages such as Java, Smalltalk, C++, and also conventional procedural programming languages such as "C" language or similar programming languages. The program code can be executed completely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or completely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (eg, through the Internet using an Internet service provider).
[0127] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0128] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of the module does not limit the module itself in some cases. For example, the sending module may also be described as "a module for sending the first service request to the first target node".
[0129] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0130] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0131] According to one or more embodiments of the present disclosure, Example 1 provides a data access method, applied to a first service node, including: in response to receiving a first business request, extracting a target routing key in the first business request; determining whether the target routing key is a hotspot routing key; if the target routing key is a hotspot routing key, determining a service node group corresponding to the target routing key from a service node cluster; determining a first target node for responding to the first business request from the service node group; and sending the first business request to the first target node.
[0132] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, wherein determining the first target node for responding to the first business request from the service node group includes: determining the first target node from the service node group based on the first load information of each second service node in the service node group.
[0133] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, which determines the first target node from the service node group based on the first load information of each second service node in the service node group, including: randomly selecting a second service node from the service node group as a candidate service node; determining whether the candidate service node is in a high load state based on the first load information of the candidate service node; if the candidate service node is in the high load state, returning to the step of randomly selecting a second service node from the service node group as a candidate service node until the number of cycles reaches a preset number; if the number of cycles reaches the preset number, determining the candidate service node selected most recently as the first target node.
[0134] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 3, which determines the first target node from the service node group based on the first load information of each second service node in the service node group, and also includes: if the candidate service node is not in the high load state, determining the candidate service node as the first target node.
[0135] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 1, wherein determining the service node group corresponding to the target routing key from the service node cluster includes: based on a consistent hashing algorithm, determining a virtual node matching the target routing key from a pre-constructed hash ring, wherein the hash ring is based on the virtual nodes corresponding to each second service node in the service node cluster and is constructed using a consistent hashing algorithm; determining a second target node corresponding to the matching virtual node from the service node cluster; in the service node cluster, taking the second target node as the starting position, traversing a preset number of second service nodes in a preset direction to obtain a service node group corresponding to the target routing key.
[0136] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 1, which further includes: if the target routing key is a non-hotspot routing key, determining a third target node corresponding to the target routing key from the service node cluster; and sending the first business request to the third target node.
[0137] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 6, wherein determining a third target node corresponding to the target routing key from the service node cluster includes: based on a consistent hashing algorithm, determining a virtual node matching the target routing key from a pre-built hash ring, wherein the hash ring is based on the virtual nodes corresponding to each second service node in the service node cluster and is constructed using a consistent hashing algorithm; and determining the second service node corresponding to the matching virtual node in the service node cluster as the third target node.
[0138] According to one or more embodiments of the present disclosure, Example 8 provides a method of any one of Examples 1-7, wherein determining whether the target routing key is a hotspot routing key comprises: obtaining a hotspot routing key list; if the target routing key exists in the hotspot routing key list, determining that the target routing key is a hotspot routing key.
[0139] According to one or more embodiments of the present disclosure, Example 9 provides the method of Example 8, which further includes: in response to receiving a retry instruction sent by a fourth target node, updating the hotspot routing key list according to the target routing key, wherein the retry instruction is used to instruct the first service node to reallocate the second service node for the first business request, and the retry instruction includes the target routing key. The retry instruction is sent by the fourth target node when it determines that the target routing key is a hotspot routing key based on its own second load information, and the fourth target node is the second service node in the service node cluster that receives the first business request; returning to the step of determining the service node group corresponding to the target routing key from the service node cluster.
[0140] According to one or more embodiments of the present disclosure, Example 10 provides the method of Example 9, wherein the second load information includes CPU usage and the number of second business requests being executed by the fourth target node, wherein the second business request is a business request carrying the target routing key; the fourth target node determines that the target routing key is a hotspot when the number reaches a preset number threshold and the CPU usage of the fourth target node is greater than a first preset usage threshold.
[0141] According to one or more embodiments of the present disclosure, Example 11 provides the method of Example 9, which updates the hotspot routing key list according to the target routing key, including: if the target routing key exists in the hotspot routing key list, updating the lifetime of the target routing key in the hotspot routing key list to 0, and the lifetime is the duration of the target routing key in the hotspot routing key list; if the target routing key does not exist in the hotspot routing key list, adding the target routing key to the hotspot routing key list.
[0142] According to one or more embodiments of the present disclosure, Example 12 provides the method of Example 11, which further includes: deleting the hotspot routing key whose survival time reaches a preset time length from the hotspot routing key list.
[0143] According to one or more embodiments of the present disclosure, Example 13 provides the method of Example 11, which further includes: setting the hotspot routing key in the hotspot routing key list whose survival time reaches a preset time length to an invalid routing key; if the target routing key exists in the hotspot routing key list, determining that the target routing key is a hotspot routing key, including: if the target routing key exists in other routing keys in the hotspot routing key list except the invalid routing key, determining that the target routing key is a hotspot routing key.
[0144] According to one or more embodiments of the present disclosure, Example 14 provides the method of Example 8, which further includes: periodically obtaining manually configured hotspot routing keys from a dynamic configuration center, and adding the obtained manually configured hotspot routing keys to the hotspot routing key list.
[0145] According to one or more embodiments of the present disclosure, Example 15 provides a method of any one of Examples 1-7, and the method is executed through a software development kit on the first service node; the method also includes: initializing the software development kit when the first service node is started; obtaining connection information of each second service node in the service node cluster; constructing a hash ring based on the virtual nodes corresponding to each second service node in the service node cluster using a consistent hashing algorithm; based on the connection information, establishing and maintaining a long connection between the software development kit and each second service node in the service node cluster in a connection pool; sending the first business request to the first target node includes: sending the first business request to the first target node through the long connection between the software development kit and the first target node.
[0146] According to one or more embodiments of the present disclosure, Example 16 provides a data access device, applied to a first service node, including: an extraction module, used to extract a target routing key in a first business request in response to receiving the first business request; a first determination module, used to determine whether the target routing key is a hotspot routing key; a second determination module, used to determine a service node group corresponding to the target routing key from a service node cluster if the target routing key is a hotspot routing key; a third determination module, used to determine a first target node for responding to the first business request from the service node group; and a sending module, used to send the first business request to the first target node.
[0147] According to one or more embodiments of the present disclosure, Example 17 provides a computer-readable medium having a computer program stored thereon, which implements the steps of any of the methods described in Examples 1-15 when executed by a processing device.
[0148] According to one or more embodiments of the present disclosure, Example 18 provides an electronic device, comprising: a storage device on which a computer program is stored; and a processing device for executing the computer program in the storage device to implement the steps of any one of the methods described in Examples 1-15.
[0149] According to one or more embodiments of the present disclosure, Example 19 provides a computer program product, including a computer program, which implements the steps of any one of the methods of Examples 1-15 when executed by a processor.
[0150] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0151] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0152] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Claims
1. A data access method, characterized in that: Applied to the first service node, comprising: In response to receiving a first service request, extracting a target routing key in the first service request; Determine whether the target routing key is a hotspot routing key; If the target routing key is a hotspot routing key, determining a service node group corresponding to the target routing key from a service node cluster, wherein the service node cluster includes a plurality of second service nodes; Determine a first target node for responding to the first service request from the service node group; The first service request is sent to the first target node.
2. The method according to claim 1, characterized in that The determining, from the service node group, a first target node for responding to the first service request includes: The first target node is determined from the service node group according to the first load information of each second service node in the service node group.
3. The method according to claim 2, characterized in that The determining the first target node from the service node group according to the first load information of each second service node in the service node group includes: Randomly selecting a second service node from the service node group as a candidate service node; Determining, according to the first load information of the candidate service node, whether the candidate service node is in a high load state; If the candidate service node is in the high load state, returning to the step of randomly selecting a second service node from the service node group as a candidate service node until the number of cycles reaches a preset number; If the number of cycles reaches the preset number of times, the candidate service node selected most recently is determined as the first target node.
4. The method according to claim 3, characterized in that The determining the first target node from the service node group according to the first load information of each second service node in the service node group further includes: If the candidate service node is not in the high load state, the candidate service node is determined as the first target node.
5. The method according to claim 1, characterized in that The determining, from the service node cluster, a service node group corresponding to the target routing key comprises: Based on a consistent hashing algorithm, determining a virtual node matching the target routing key from a pre-constructed hash ring, wherein the hash ring is based on virtual nodes corresponding to each second service node in the service node cluster and is constructed using a consistent hashing algorithm; Determine a second target node corresponding to the matching virtual node from the service node cluster; In the service node cluster, taking the second target node as a starting position, traversing a preset number of second service nodes in a preset direction, to obtain a service node group corresponding to the target routing key.
6. The method according to claim 1, characterized in that The method further comprises: If the target routing key is a non-hotspot routing key, determining a third target node corresponding to the target routing key from the service node cluster; The first service request is sent to the third target node.
7. The method according to claim 6, characterized in that The determining, from the service node cluster, a third target node corresponding to the target routing key comprises: Based on a consistent hashing algorithm, determining a virtual node matching the target routing key from a pre-constructed hash ring, wherein the hash ring is based on virtual nodes corresponding to each second service node in the service node cluster and is constructed using a consistent hashing algorithm; A second service node in the service node cluster corresponding to the matching virtual node is determined as the third target node.
8. The method according to any one of claims 1 to 7, characterized in that The determining whether the target routing key is a hotspot routing key includes: Get the hotspot routing key list; If the target routing key exists in the hotspot routing key list, the target routing key is determined to be a hotspot routing key.
9. The method according to claim 8, characterized in that The method further comprises: In response to receiving a retry instruction sent by a fourth target node, updating the hotspot routing key list according to the target routing key, wherein the retry instruction is used to instruct the first service node to reallocate a second service node for the first service request, the retry instruction includes the target routing key, and the retry instruction is sent by the fourth target node when determining that the target routing key is a hotspot routing key according to its own second load information, and the fourth target node is the second service node in the service node cluster that receives the first service request; Return to the step of determining the service node group corresponding to the target routing key from the service node cluster.
10. The method according to claim 9, characterized in that The second load information includes a CPU usage rate and a number of second service requests being executed by the fourth target node, wherein the second service request is a service request carrying the target routing key; The fourth target node determines that the target routing key is a hotspot when the number reaches a preset number threshold and the CPU usage of the fourth target node is greater than a first preset usage threshold.
11. The method according to claim 9, characterized in that The updating of the hotspot routing key list according to the target routing key includes: If the target routing key exists in the hotspot routing key list, the lifetime of the target routing key in the hotspot routing key list is updated to 0, where the lifetime is the duration of the target routing key in the hotspot routing key list; If the target routing key does not exist in the hotspot routing key list, the target routing key is added to the hotspot routing key list.
12. The method according to claim 11, characterized in that The method further comprises: The hotspot routing key whose survival time reaches the preset time length is deleted from the hotspot routing key list.
13. The method according to claim 11, characterized in that The method further comprises: Setting the hotspot routing key whose survival time in the hotspot routing key list reaches a preset time length as an invalid routing key; If the target routing key exists in the hotspot routing key list, determining that the target routing key is a hotspot routing key includes: If the target routing key exists in other routing keys except the invalid routing key in the hotspot routing key list, the target routing key is determined to be the hotspot routing key.
14. The method according to claim 8, characterized in that The method further comprises: The manually configured hotspot routing keys are periodically obtained from the dynamic configuration center, and the obtained manually configured hotspot routing keys are added to the hotspot routing key list.
15. The method according to any one of claims 1 to 7, characterized in that The method is performed by a software development kit on the first service node; The method further comprises: Initializing the software development kit when the first service node is started; Obtaining connection information of each second service node in the service node cluster; Based on the virtual nodes corresponding to the second service nodes in the service node cluster, a consistent hashing algorithm is used to construct a hash ring; Based on the connection information, establishing and maintaining in a connection pool a persistent connection between the software development kit and each second service node in the service node cluster; The sending the first service request to the first target node includes: The first service request is sent to the first target node through the long connection between the software development kit and the first target node.
16. A data access device, characterized in that: Applied to the first service node, comprising: An extraction module, configured to extract a target routing key in the first service request in response to receiving the first service request; A first determination module, used to determine whether the target routing key is a hotspot routing key; A second determination module, configured to determine a service node group corresponding to the target routing key from a service node cluster if the target routing key is a hotspot routing key; A third determination module, configured to determine a first target node for responding to the first service request from the service node group; A sending module is used to send the first service request to the first target node.
17. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing device, the steps of the method according to any one of claims 1 to 15 are implemented.
18. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 15.
19. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 15 are implemented.
Citation Information
Patent Citations
Data migration method and device
CN112583864A
Load balancing method and device based on cloud cluster
CN113596094A
Edge cloud collaboration method and device
CN113630383A
Constant time data structure for single and distributed networks
US11960483B1
Methods and systems for providing dynamic routing key registration
US20010055380A1