Service registration center, service registration method and computer equipment
Through data sharding and mapping algorithms, service registration requests are distributed to virtual nodes of multiple storage servers, solving the problem of excessive and unavailable resource load in traditional service registration centers, and achieving higher scalability and reliability.
Patent Information
- Application Number
- CN202411019868.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-12-10
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional service registration centers adopt full backup method, resulting in excessive load on storage server resources. If the node storage resources are insufficient, the registration center will be unavailable and cannot cope with the dynamic changes in the number and distribution of service providers.
Using data sharding algorithm and mapping algorithm, the service registration request is mapped to virtual nodes in multiple storage servers. Through the preset hash ring and backup node mechanism, data sharding and asynchronous update are realized to avoid single point of failure and resource skew , improve system scalability.
Reduce the resource load of the storage server, avoid unavailability caused by insufficient node storage resources, improve the scalability and reliability of the service registry, and ensure the stable operation of the system under dynamic changing conditions.
Smart Images

Figure CN119109938A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology and can be used in the financial field or other fields, and in particular, to a service registration center, a service registration method and a computer device. Background Art
[0002] As the business in the banking information technology system (IT system) becomes more complex, it gradually transforms from the traditional monolithic application architecture to the microservice architecture. The service registration center is one of the core components in the microservice framework, which is used to manage dynamic service information.
[0003] The traditional service registration center adopts a distributed structure, which can improve the availability of the registration center. Each node fully backs up the service data so that other nodes can continue to provide service registration capabilities when some nodes fail. However, the full backup method increases the resource load of each node. If the node storage resources are insufficient, the registration center will be unavailable. Summary of the invention
[0004] Based on this, it is necessary to provide a service registration center, a service registration method and a computer device that can reduce the resource load of each storage server in response to the above technical problems.
[0005] In a first aspect, the present application provides a service registration center, the service registration center comprising a client, a node manager, and a plurality of storage servers, wherein:
[0006] The client is used to receive a service registration request initiated by a service provider and send the service registration request to the node manager;
[0007] The node manager is configured to determine the virtual node corresponding to the service registration request according to a data sharding algorithm, determine the storage server corresponding to the virtual node from the multiple storage servers according to a mapping algorithm, and send the service registration request to the storage server corresponding to the virtual node;
[0008] The storage server is used to store the service data of the service provider in response to the received service registration request.
[0009] In one embodiment, the node manager is further used to:
[0010] Calculate a hash value based on a data sharding algorithm and the service name carried in the service registration request;
[0011] Determine a starting position of the hash value on a preset hash ring, wherein the preset hash ring is provided with a plurality of virtual nodes;
[0012] The first virtual node queried in a clockwise direction on the preset hash ring starting from the starting position is used as the virtual node corresponding to the service registration request.
[0013] In one of the embodiments, the node manager is further used to determine one or more backup nodes corresponding to the service registration request according to a data backup algorithm, generate a backup request according to the one or more backup nodes, and send the backup request to the storage server;
[0014] The storage server is further configured to generate asynchronous update data according to the backup request, and send the asynchronous update data to the backup node corresponding to the backup request, so as to instruct each of the backup nodes to store the asynchronous update data.
[0015] In one embodiment, the node manager is further used to:
[0016] When it is detected that the target storage server fails, determining a plurality of target virtual nodes corresponding to the target storage server according to the mapping algorithm;
[0017] Determine the hash value ranges of the multiple target virtual nodes on the preset hash ring;
[0018] Determine the invalid data range according to the hash value range;
[0019] Determine a non-failed backup node corresponding to the target storage server according to the current node status;
[0020] Determine the destination storage server according to the current node state and the data sharding algorithm;
[0021] A data migration request is sent to the destination storage server according to the failed data range and the non-failed backup node, wherein the data migration request is used to instruct the destination storage server to request service data from the non-failed backup node according to the failed data range, and to store the service data fed back by the non-failed backup node.
[0022] In one embodiment, the node manager is further used to:
[0023] When a new storage server is detected, determine the scope of data to be migrated;
[0024] Determine the original storage server corresponding to the data range to be migrated;
[0025] The original storage server sends a data acquisition request to the newly added storage server according to the range of data to be migrated, wherein the data acquisition request is used to instruct the newly added storage server to request service data from the original storage server according to the range of data to be migrated, and to store the service data fed back by the original storage server;
[0026] A data deletion request is sent to the original storage server according to the range of data to be migrated, where the data deletion request is used to instruct the original storage server to delete the data matching the range of data to be migrated.
[0027] In one of the embodiments, the client is further used to receive a service call request initiated by a service consumer, and send the service call request to the node manager;
[0028] The node manager is further configured to query a service instance list according to the service call request and feed the service instance list back to the client;
[0029] The client is further configured to select a target service provider from the service instance list and initiate a service call request to the target service provider.
[0030] In one of the embodiments, the client is further configured to select a target service provider from the service instance list using a weighted round-robin algorithm.
[0031] In one of the embodiments, the client is further used to receive a service discovery request sent by a target service consumer and send the service discovery request to the node manager, wherein the service discovery request is generated when the target service consumer generates a query list based on one or more services called by a currently running program when the target service consumer is started;
[0032] The node manager is further configured to read a query list corresponding to the service discovery request, and redirect the service query request to a storage server to be queried that is related to each service in the query list;
[0033] The storage server to be queried is used to send the change information to the target service consumer in a long polling manner when the service instance information related to the service query request changes.
[0034] In a second aspect, the present application further provides a service registration method, which is applied to the service registration center as described above, the service registration center includes a client, a node manager and multiple storage servers, and the service registration method includes:
[0035] The client receives a service registration request initiated by a service provider, and sends the service registration request to the node manager;
[0036] The node manager determines the virtual node corresponding to the service registration request according to the data sharding algorithm, determines the storage server corresponding to the virtual node from the multiple storage servers according to the mapping algorithm, and sends the service registration request to the storage server corresponding to the virtual node;
[0037] The storage server stores the service data of the service provider in response to the received service registration request.
[0038] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0039] The client receives a service registration request initiated by a service provider, and sends the service registration request to the node manager;
[0040] The node manager determines the virtual node corresponding to the service registration request according to the data sharding algorithm, determines the storage server corresponding to the virtual node from the multiple storage servers according to the mapping algorithm, and sends the service registration request to the storage server corresponding to the virtual node;
[0041] The storage server stores the service data of the service provider in response to the received service registration request.
[0042] In the above-mentioned service registration center, service registration method and computer device, the client receives the service registration request initiated by the service provider and sends the service registration request to the node manager; the node manager determines the virtual node corresponding to the service registration request according to the data sharding algorithm, determines the storage server corresponding to the virtual node from multiple storage servers according to the mapping algorithm, and sends the service registration request to the storage server corresponding to the virtual node; the storage server responds to the received service registration request and stores the service data of the service provider. Compared with the method of full storage of each storage server, the present invention maps the service data of different services to different storage nodes according to the data sharding algorithm, which can reduce the resource load of each storage server, avoid the unavailability of the service registration center due to insufficient node storage resources, and improve the scalability of the entire system. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] FIG1 is a structural block diagram of a service registration center in one embodiment;
[0044] FIG2 is a diagram showing an example of the architecture of a service registration center in one embodiment;
[0045] FIG3 is a schematic diagram of a preset hash ring in one embodiment;
[0046] FIG4 is a schematic diagram of a preset hash ring in another embodiment;
[0047] FIG5 is a schematic diagram of a process flow of a service registration method in one embodiment;
[0048] FIG. 6 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0050] In one embodiment, as shown in FIG. 1 , a service registration center is provided, the service registration center comprising a client 102, a node manager 104, and a plurality of storage servers 106, wherein:
[0051] The client 102 is used to receive a service registration request initiated by a service provider, and send the service registration request to the node manager 104 .
[0052] The service registration center of this embodiment can be used in IT systems in the financial field, and can also be used in any field other than the financial field. The application field of the service registration center of this embodiment is not limited. The service registration center of this embodiment can be implemented by a server cluster composed of multiple servers.
[0053] Among them, the microservice architecture is the architectural style followed by current Internet companies when building large and complex software applications. This architecture develops a single application as a set of loosely coupled services. Microservices work as an application, consisting of small and separate services that run in the microservice process and communicate with lightweight mechanisms. The service registry is one of the core components in the microservice framework, which is used to manage services in the microservice framework. For any microservice, in principle, there should be or support multiple providers, which is determined by the distributed properties of microservices. Furthermore, in order to support elastic scaling features, the number and distribution of providers of a service are often dynamic and cannot be predetermined. Therefore, the static configuration mechanism commonly used in the monolithic application stage is no longer applicable, and an additional component needs to be introduced to manage the registration and discovery of microservices, and this component is the service registry.
[0054] The current mainstream service registration center solutions are: Zookeeper, Eureka, Consul, Nacos, etc. These solutions all use server-client architecture and full data backup. When a node is just started, it will actively pull full data from other nodes to quickly keep the data in the current node consistent with the data in the entire cluster. In addition, Zookeeper and Consul both use strict CP principles in terms of data consistency, that is, access requests to the registration center at any time can get consistent data results, and the system is fault-tolerant to network segmentation, but it cannot guarantee that every service request is reachable.
[0055] 2 , the service registration center includes a client 102 and a server, the server includes a node manager 104 and multiple storage servers 106, and the client 102 has the following functions: providing service registration, service discovery interface and service deregistration interface to microservices, and interacting with the server, which process is transparent to the microservices; caching the service provider data required by the service; and responding to the health check of the service registration center server.
[0056] The client 102 provides a service registration interface to the service provider, and the service provider initiates a service registration request to the client 102. The client 102 caches the service data of the service provider and interacts with the node manager 104 to notify the node manager 104 to allocate storage.
[0057] The node manager 104 is used to determine the virtual node corresponding to the service registration request according to the data sharding algorithm, determine the storage server corresponding to the virtual node from the multiple storage servers according to the mapping algorithm, and send the service registration request to the storage server 106 corresponding to the virtual node.
[0058] 2, the node manager can be implemented with a single computing node or a node cluster composed of multiple computing nodes. The node manager 104 has the following functions: storage server status management; running data sharding algorithm; forwarding the client's service registration request and service discovery request to the storage server determined by the data sharding algorithm as a server interface; data migration management.
[0059] The data distribution algorithm is used to determine the step-by-step rules for data distribution on multiple devices in a distributed system. The data distribution algorithm of this embodiment has the following characteristics: uniform distribution, that is, the data stored on each device is similar; load balancing, that is, the number of requests on each device is similar; support for dynamic expansion and contraction, that is, when the state of nodes in the distributed system changes (a node fails and cannot continue to work, or a new node joins to share the work), less data migration work is generated.
[0060] The node manager 104 runs a data sharding algorithm to determine which virtual node the currently registered service data should exist in, and maps the determined virtual node to its corresponding physical node, thereby determining the storage server 106 assigned to the currently registered service, and forwarding the service registration request to the storage server 106 determined by the data sharding algorithm.
[0061] The storage server 106 is used to store the service data of the service provider in response to the received service registration request.
[0062] Among them, the storage server 106 has the following functions: responding to service registration requests and storing part of the service data in the system; performing health checks on service providers; responding to service discovery requests; and synchronizing the data of the current node to the corresponding backup node according to data backup requirements.
[0063] The service registration process of this embodiment includes: the service provider application calls the client of the service registration center to initiate a registration service request. The client of the service registration center interacts with the server and forwards the registration service request. The node manager of the service registration center server runs the data sharding algorithm to determine which virtual node the current service should be stored in, and determines the physical node (storage server) mapped to the virtual node. The node manager sends a service registration request to the storage server determined by the data sharding algorithm, so that the storage server stores the metadata of the currently registered service. After receiving the call success result returned by the storage server, the node manager returns a registration success message to the service provider.
[0064] In the above-mentioned service registration center, the client receives the service registration request initiated by the service provider, and sends the service registration request to the node manager; the node manager determines the virtual node corresponding to the service registration request according to the data sharding algorithm, determines the storage server corresponding to the virtual node from multiple storage servers according to the mapping algorithm, and sends the service registration request to the storage server corresponding to the virtual node; the storage server responds to the received service registration request and stores the service data of the service provider. Compared with the method of full storage on each storage server, this embodiment maps the service data of different services to different storage nodes according to the data sharding algorithm, which can reduce the resource load of each storage server, avoid the unavailability of the service registration center due to insufficient node storage resources, and improve the scalability of the entire system.
[0065] In one embodiment, the node manager 104 is further configured to:
[0066] A hash value is calculated according to a data sharding algorithm and the service name carried in the service registration request; a starting position of the hash value on a preset hash ring is determined, wherein a plurality of virtual nodes are arranged on the preset hash ring; and the first virtual node queried in a clockwise direction with the starting position as the starting point on the preset hash ring is used as the virtual node corresponding to the service registration request.
[0067] Among them, consistent hashing is a pair of 32 Perform a modulo operation to form a virtual ring around the entire hash value space, which is the preset hash ring. As shown in Figures 3 and 4, the preset hash ring space is organized in a clockwise direction. The point directly above the ring represents 0, the first point to the right of 0 represents 1, and so on until 2. 32 -1, that is, the first point to the left of 0 represents 2 32 -1.
[0068] Referring to FIG3, when the number of nodes of the storage server is small, a large amount of data will be concentrated on one node, and very little data will be stored on another node, resulting in a data tilt problem. Based on this, referring to FIG4, a virtual node mechanism is introduced when constructing the preset hash ring of this embodiment, and multiple hashes are calculated for each physical node (storage server), and service nodes, i.e., virtual nodes, are placed on the preset hash ring according to each hash calculation result. Specifically, the number of virtual nodes associated with each physical node is determined according to actual demand or the storage space size of the storage server, and the number is increased according to the virtual node sequence number after the IP or unique host name of the storage server to obtain the keyword of each virtual node, and the keyword is hashed. For example, in FIG4, three virtual nodes are set for each storage server, and the hash values of "Node A001", "Node A002", "Node A003", "Node B001", "Node B002", and "Node B003" are calculated respectively. At this time, six virtual nodes are set on the preset hash ring.
[0069] Referring to Figure 4, for the four data objects object A, object B, object C, and object D, the corresponding key values are calculated through a specific hash function and mapped to the hash ring. From the location where the data is mapped, "walk" along the preset hash ring in a clockwise direction. The first server encountered is the storage node corresponding to the data. This process is shown by the arrow in Figure 4. Among them, the data located in the three virtual nodes "Node A001", "Node A002", and "Node A003" are all mapped to the physical node A, which solves the problem of data skew when there are few service nodes.
[0070] Exemplarily, vnode_tree is set to a red-black tree that stores all virtual nodes. The following code is used to find the smallest virtual node whose key value is greater than key in the red-black tree that stores virtual nodes, and obtain the physical node pointed to by the virtual node:
[0071] if serviceName=NULL || this->vNodes=0 then
[0072] return NULL;
[0073] key<-getHashVal(serviceName);
[0074] init pNode0, pNode1, pNode2;
[0075] rbNode<-util_rbtree_lookup(vnode_tree,key);
[0076] By entering the service name in the above manner, the output can determine the physical node corresponding to the service allocation.
[0077] In one embodiment, the node manager 104 is further configured to determine one or more backup nodes corresponding to the service registration request according to a data backup algorithm, generate a backup request according to the one or more backup nodes, and send the backup request to the storage server 106;
[0078] The storage server 106 is further configured to generate asynchronous update data according to the backup request, and send the asynchronous update data to the backup node corresponding to the backup request, so as to instruct each of the backup nodes to store the asynchronous update data.
[0079] There is also a hash ring including multiple physical nodes. In order to reduce the computational complexity and the amount of data migration, the selected storage server is used as the starting point through the data backup algorithm, and multiple adjacent storage servers queried in the clockwise direction on the hash ring are used as backup nodes. The number of backup nodes M can be set according to the actual situation, and the redundancy index N can also be set according to the actual situation, which is used to indicate that the Nth and adjacent M-1 storage servers are queried in the clockwise direction of the hash ring as backup nodes. For example, storage servers 1, 2, and 3 are mapped to clockwise adjacent positions on the hash ring, the number of backup nodes M=2, and the redundancy index N=1, then the data mapped to storage server 1 will be backed up to storage servers 2 and 3 at the same time. In this embodiment, data sharding, data backup synchronization process, etc. are transparent to the client 102, and the data backup nodes of each service of the client 102 are notified at the same time. The storage server records the relevant service data and returns the registration result, and asynchronously updates the data to the data backup node according to the backup node identifier carried in the backup request to complete the data backup.
[0080] In one embodiment, the node manager 104 is also used to: when a failure of a target storage server is detected, determine multiple target virtual nodes corresponding to the target storage server according to the mapping algorithm; determine the hash value range of the multiple target virtual nodes on the preset hash ring; determine the failed data range according to the hash value range; determine the non-failed backup node corresponding to the target storage server according to the current node status; determine the destination storage server according to the current node status and the data sharding algorithm; send a data migration request to the destination storage server according to the failed data range and the non-failed backup node, the data migration request is used to instruct the destination storage server to request service data from the non-failed backup node according to the failed data range, and store the service data fed back by the non-failed backup node.
[0081] Among them, when the number of storage servers changes, the node manager 104 will sense the change and determine the failed physical nodes. In the event of a physical node failure, the multiple virtual nodes mapped to the physical node are determined according to the mapping algorithm, and the affected data range stored by the multiple virtual nodes, that is, the failed data range, is determined according to the consistent hashing algorithm. New virtual nodes are reselected based on the current node status (removing failed physical nodes and virtual nodes) and the data sharding algorithm, and mapped to the corresponding physical nodes according to the mapping algorithm, so as to determine the destination storage server for migration, and the destination storage server actively obtains data from other backup nodes that have not failed. In this way, a data backup and data migration mechanism is provided so that all service information will not be lost due to partial node failures, thereby improving the reliability of the service registration center.
[0082] In one embodiment, the node manager 104 is also used to: determine the range of data to be migrated when a newly added storage server is detected; determine the original storage server corresponding to the range of data to be migrated; send a data acquisition request from the original storage server to the newly added storage server according to the range of data to be migrated, and the data acquisition request is used to instruct the newly added storage server to request service data from the original storage server according to the range of data to be migrated, and store the service data fed back by the original storage server; send a data deletion request to the original storage server according to the range of data to be migrated, and the data deletion request is used to instruct the original storage server to delete the data matching the range of data to be migrated.
[0083] Among them, in the case of newly added physical nodes, it is necessary to increase the number according to the virtual node sequence number after the IP or unique host name of the newly added storage server to obtain the keyword of each virtual node, perform hash calculation on the keyword to obtain multiple hash values, map the multiple hash values to the preset hash ring, determine the affected data range, that is, the data range to be migrated according to the consistent hashing algorithm, instruct the new node to obtain data from the old node that stores the data range to be migrated, and instruct the old node to delete the data in the data range to be migrated. Optionally, the node manager 104 is also used to instruct the backup node to delete the data that matches the data range to be migrated, and then re-determine the backup node according to the data backup algorithm, and instruct the newly added storage server to asynchronously update the data to the newly determined backup node. Optionally, when a read and write operation matching the data range to be migrated is received during the data migration process, data is queried from the newly added storage server first, and when no data is found, data is queried from the original storage server.
[0084] Through the above method, the addition and deletion of physical nodes are analyzed, which avoids large-scale data migration, reduces the data reading and writing pressure of the storage server, provides data backup and data migration mechanisms so that all service information will not be lost due to partial node failure, and improves the reliability of the service registration center.
[0085] In one embodiment, the client 102 is further used to receive a service call request initiated by a service consumer, and send the service call request to the node manager 104;
[0086] The node manager 104 is further configured to query a service instance list according to the service call request and feed the service instance list back to the client 102;
[0087] The client 102 is further configured to select a target service provider from the service instance list and initiate a service call request to the target service provider.
[0088] Among them, when the service consumer queries the service, the node manager 104 forwards the request to the storage server 106 storing the corresponding service, and the storage server 106 queries and obtains the corresponding service instance list, and replies to the service consumer via the node manager 104 and the client 102. Similarly, when the service consumer calls the service, the node manager 104 forwards the request to the storage server 106 storing the corresponding service, and the storage server 106 queries and obtains the corresponding service instance list, and feeds back to the client 102 via the node manager 104, and the client selects the service provider to call according to the load balancing algorithm.
[0089] In one embodiment, the client 102 is further configured to select a target service provider from the service instance list using a weighted round-robin algorithm.
[0090] Among them, the load balancing algorithm adopted by the client 102 in this embodiment is a weighted polling algorithm. Specifically, a higher weight is assigned to a service provider with high configuration and strong processing capability so that it can process more requests; a lower weight is assigned to a service provider with low configuration and weak processing capability to reduce its load. In this way, each service provider can share the call request, and the load size of different service providers is determined by configuring different weights, thereby achieving load balancing of service calls.
[0091] Among them, the client 102 receives a list of available service instances, stores the weight of each service, and maintains a calling sequence number. In the initial stage, the service list is initialized according to the service weight, and then the corresponding service instance is selected in turn according to the calling sequence number. In this way, each service will be called in turn and the load quantity will be consistent with its weight.
[0092] Optionally, the client of the service registration center selects a service provider to initiate a service call based on the load balancing algorithm. If the service call is successful, the service agent of the service consumer will receive the result, decompress the data, serialize the result data, and pass the return value to the service consumer. If the call fails, a new service provider will be selected to continue the remote call process as shown in Figure 2.
[0093] In one embodiment, the client 102 is further used to receive a service discovery request sent by a target service consumer, and send the service discovery request to the node manager 104, wherein the service discovery request is generated by the target service consumer at startup based on a query list generated according to one or more services called by a currently running program, and is generated based on the query list;
[0094] The node manager 104 is further configured to read a query list corresponding to the service discovery request, and redirect the service query request to a storage server to be queried that is related to each service in the query list;
[0095] The storage server to be queried is used to send the change information to the target service consumer in a long polling manner when the service instance information related to the service query request changes.
[0096] Among them, a cache mechanism is added to the client of the service consumer to store the service cache actively pushed by the server. When each service consumer starts, it notifies the client 102 which services the current program needs to call. The client 102 of the service registration center sends the service discovery request to the server of the service registration center. After receiving the service discovery request, the server of the service registration center reads the query list and redirects the query request to each specific storage server. Each storage server records the service consumers who subscribe to the corresponding service. When the storage server detects that the information of a subscribed service instance has changed, it will push the latest information to the client of the service consumer who has subscribed to the service through the long polling response.
[0097] Each module in the above service registration center can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0098] Based on the same inventive concept, the embodiment of the present application also provides a service registration method for implementing the service registration center involved above. The implementation solution provided by the service registration method to solve the problem is similar to the implementation solution recorded in the above service registration center, so the specific limitations in one or more service registration method embodiments provided below can refer to the limitations on the service registration center above, and will not be repeated here.
[0099] In one embodiment, as shown in FIG. 5 , a service registration method is provided, the service registration method is applied to the service registration center as described in any of the above embodiments, the service registration center includes a client, a node manager and a plurality of storage servers, and the service registration method includes:
[0100] Step 502: The client receives a service registration request initiated by a service provider, and sends the service registration request to the node manager.
[0101] Step 504: The node manager determines the virtual node corresponding to the service registration request according to the data sharding algorithm, determines the storage server corresponding to the virtual node from the multiple storage servers according to the mapping algorithm, and sends the service registration request to the storage server corresponding to the virtual node.
[0102] Step 506: The storage server stores the service data of the service provider in response to the received service registration request.
[0103] In the above service registration method, the client receives the service registration request initiated by the service provider and sends the service registration request to the node manager; the node manager determines the virtual node corresponding to the service registration request according to the data sharding algorithm, determines the storage server corresponding to the virtual node from multiple storage servers according to the mapping algorithm, and sends the service registration request to the storage server corresponding to the virtual node; the storage server responds to the received service registration request and stores the service data of the service provider. Compared with the method of full storage on each storage server, this method maps the service data of different services to different storage nodes according to the data sharding algorithm, which can reduce the resource load of each storage server, avoid the unavailability of the service registration center due to insufficient node storage resources, and improve the scalability of the entire system.
[0104] In one embodiment, step 504 includes:
[0105] The node manager calculates a hash value according to a data sharding algorithm and a service name carried in the service registration request;
[0106] Determine a starting position of the hash value on a preset hash ring, wherein the preset hash ring is provided with a plurality of virtual nodes;
[0107] The first virtual node queried in a clockwise direction on the preset hash ring starting from the starting position is used as the virtual node corresponding to the service registration request.
[0108] In one embodiment, the method further comprises:
[0109] The node manager determines one or more backup nodes corresponding to the service registration request according to a data backup algorithm, generates a backup request according to the one or more backup nodes, and sends the backup request to the storage server;
[0110] The storage server generates asynchronous update data according to the backup request, and sends the asynchronous update data to the backup node corresponding to the backup request, so as to instruct each of the backup nodes to store the asynchronous update data.
[0111] In one embodiment, the method further comprises:
[0112] When the node manager detects that the target storage server fails, the node manager determines a plurality of target virtual nodes corresponding to the target storage server according to the mapping algorithm;
[0113] Determine the hash value ranges of the multiple target virtual nodes on the preset hash ring;
[0114] Determine the invalid data range according to the hash value range;
[0115] Determine a non-failed backup node corresponding to the target storage server according to the current node status;
[0116] Determine the destination storage server according to the current node state and the data sharding algorithm;
[0117] A data migration request is sent to the destination storage server according to the failed data range and the non-failed backup node, wherein the data migration request is used to instruct the destination storage server to request service data from the non-failed backup node according to the failed data range, and to store the service data fed back by the non-failed backup node.
[0118] In one embodiment, the method further comprises:
[0119] The node manager determines the range of data to be migrated when detecting a newly added storage server;
[0120] Determine the original storage server corresponding to the data range to be migrated;
[0121] The original storage server sends a data acquisition request to the newly added storage server according to the range of data to be migrated, wherein the data acquisition request is used to instruct the newly added storage server to request service data from the original storage server according to the range of data to be migrated, and to store the service data fed back by the original storage server;
[0122] A data deletion request is sent to the original storage server according to the range of data to be migrated, where the data deletion request is used to instruct the original storage server to delete the data matching the range of data to be migrated.
[0123] In one embodiment, the method further comprises:
[0124] The client receives a service call request initiated by a service consumer, and sends the service call request to the node manager;
[0125] The node manager queries a service instance list according to the service call request, and feeds the service instance list back to the client;
[0126] The client selects a target service provider from the service instance list and initiates a service call request to the target service provider.
[0127] In one embodiment, in the method, the client selects a target service provider from the service instance list using a weighted round-robin algorithm.
[0128] In one embodiment, the method further comprises:
[0129] The client receives a service discovery request sent by a target service consumer, and sends the service discovery request to the node manager, wherein the service discovery request is generated by the target service consumer when it is started, based on a query list generated according to one or more services called by a currently running program, and is generated according to the query list;
[0130] The node manager reads a query list corresponding to the service discovery request, and redirects the service query request to a storage server to be queried related to each service in the query list;
[0131] When the service instance information related to the service query request changes, the storage server to be queried sends the change information to the target service consumer in a long polling manner.
[0132] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0133] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG6. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a service registration method is implemented.
[0134] Those skilled in the art will understand that the structure shown in FIG. 6 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0135] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0136] The client receives a service registration request initiated by a service provider, and sends the service registration request to the node manager;
[0137] The node manager determines the virtual node corresponding to the service registration request according to the data sharding algorithm, determines the storage server corresponding to the virtual node from the multiple storage servers according to the mapping algorithm, and sends the service registration request to the storage server corresponding to the virtual node;
[0138] The storage server stores the service data of the service provider in response to the received service registration request.
[0139] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0140] The node manager calculates a hash value according to a data sharding algorithm and a service name carried in the service registration request;
[0141] Determine a starting position of the hash value on a preset hash ring, wherein the preset hash ring is provided with a plurality of virtual nodes;
[0142] The first virtual node queried in a clockwise direction on the preset hash ring starting from the starting position is used as the virtual node corresponding to the service registration request.
[0143] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0144] The node manager determines one or more backup nodes corresponding to the service registration request according to a data backup algorithm, generates a backup request according to the one or more backup nodes, and sends the backup request to the storage server;
[0145] The storage server generates asynchronous update data according to the backup request, and sends the asynchronous update data to the backup node corresponding to the backup request, so as to instruct each of the backup nodes to store the asynchronous update data.
[0146] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0147] When the node manager detects that the target storage server fails, the node manager determines a plurality of target virtual nodes corresponding to the target storage server according to the mapping algorithm;
[0148] Determine the hash value ranges of the multiple target virtual nodes on the preset hash ring;
[0149] Determine the invalid data range according to the hash value range;
[0150] Determine a non-failed backup node corresponding to the target storage server according to the current node status;
[0151] Determine the destination storage server according to the current node state and the data sharding algorithm;
[0152] A data migration request is sent to the destination storage server according to the failed data range and the non-failed backup node, wherein the data migration request is used to instruct the destination storage server to request service data from the non-failed backup node according to the failed data range, and to store the service data fed back by the non-failed backup node.
[0153] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0154] The node manager determines the range of data to be migrated when detecting a newly added storage server;
[0155] Determine the original storage server corresponding to the data range to be migrated;
[0156] The original storage server sends a data acquisition request to the newly added storage server according to the range of data to be migrated, wherein the data acquisition request is used to instruct the newly added storage server to request service data from the original storage server according to the range of data to be migrated, and to store the service data fed back by the original storage server;
[0157] A data deletion request is sent to the original storage server according to the range of data to be migrated, where the data deletion request is used to instruct the original storage server to delete the data matching the range of data to be migrated.
[0158] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0159] The client receives a service call request initiated by a service consumer, and sends the service call request to the node manager;
[0160] The node manager queries a service instance list according to the service call request, and feeds the service instance list back to the client;
[0161] The client selects a target service provider from the service instance list and initiates a service call request to the target service provider.
[0162] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0163] The client selects a target service provider from the service instance list using a weighted round-robin algorithm.
[0164] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0165] The client receives a service discovery request sent by a target service consumer, and sends the service discovery request to the node manager, wherein the service discovery request is generated by the target service consumer when it is started, based on a query list generated according to one or more services called by a currently running program, and is generated according to the query list;
[0166] The node manager reads a query list corresponding to the service discovery request, and redirects the service query request to a storage server to be queried related to each service in the query list;
[0167] When the service instance information related to the service query request changes, the storage server to be queried sends the change information to the target service consumer in a long polling manner.
[0168] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0169] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0170] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0171] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A service registration center, It is characterized in that The service registration center includes a client, a node manager and multiple storage servers, wherein: The client is used to receive a service registration request initiated by a service provider and send the service registration request to the node manager; The node manager is configured to determine the virtual node corresponding to the service registration request according to a data sharding algorithm, determine the storage server corresponding to the virtual node from the multiple storage servers according to a mapping algorithm, and send the service registration request to the storage server corresponding to the virtual node; The storage server is used to store the service data of the service provider in response to the received service registration request.
2. The service registration center according to claim 1, It is characterized in that The node manager is also used to: Calculate a hash value based on a data sharding algorithm and the service name carried in the service registration request; Determine a starting position of the hash value on a preset hash ring, wherein the preset hash ring is provided with a plurality of virtual nodes; The first virtual node queried in a clockwise direction on the preset hash ring starting from the starting position is used as the virtual node corresponding to the service registration request.
3. The service registration center according to claim 1, It is characterized in that The node manager is further configured to determine one or more backup nodes corresponding to the service registration request according to a data backup algorithm, generate a backup request according to the one or more backup nodes, and send the backup request to the storage server; The storage server is further configured to generate asynchronous update data according to the backup request, and send the asynchronous update data to the backup node corresponding to the backup request, so as to instruct each of the backup nodes to store the asynchronous update data.
4. The service registration center according to claim 2, It is characterized in that The node manager is also used to: When it is detected that the target storage server fails, determining a plurality of target virtual nodes corresponding to the target storage server according to the mapping algorithm; Determine the hash value ranges of the multiple target virtual nodes on the preset hash ring; Determine the invalid data range according to the hash value range; Determine a non-failed backup node corresponding to the target storage server according to the current node status; Determine the destination storage server according to the current node state and the data sharding algorithm; A data migration request is sent to the destination storage server according to the failed data range and the non-failed backup node, wherein the data migration request is used to instruct the destination storage server to request service data from the non-failed backup node according to the failed data range, and to store the service data fed back by the non-failed backup node.
5. The service registration center according to claim 1, It is characterized in that The node manager is also used to: When a new storage server is detected, determine the scope of data to be migrated; Determine the original storage server corresponding to the data range to be migrated; The original storage server sends a data acquisition request to the newly added storage server according to the range of data to be migrated, wherein the data acquisition request is used to instruct the newly added storage server to request service data from the original storage server according to the range of data to be migrated, and to store the service data fed back by the original storage server; A data deletion request is sent to the original storage server according to the range of data to be migrated, where the data deletion request is used to instruct the original storage server to delete the data matching the range of data to be migrated.
6. The service registration center according to any one of claims 1 to 5, It is characterized in that The client is further configured to receive a service call request initiated by a service consumer and send the service call request to the node manager; The node manager is further configured to query a service instance list according to the service call request and feed the service instance list back to the client; The client is further configured to select a target service provider from the service instance list and initiate a service call request to the target service provider.
7. The service registration center according to claim 6, It is characterized in that The client is further configured to select a target service provider from the service instance list by using a weighted polling algorithm.
8. A service registration center according to any one of claims 1 to 5, It is characterized in that The client is further used to receive a service discovery request sent by a target service consumer and send the service discovery request to the node manager, wherein the service discovery request is generated by the target service consumer when starting up, based on a query list generated according to one or more services called by a currently running program, and is generated based on the query list; The node manager is further configured to read a query list corresponding to the service discovery request, and redirect the service query request to a storage server to be queried that is related to each service in the query list; The storage server to be queried is used to send the change information to the target service consumer in a long polling manner when the service instance information related to the service query request changes.
9. A service registration method, It is characterized in that The service registration method is applied to a service registration center as described in any one of claims 1 to 8, the service registration center includes a client, a node manager and a plurality of storage servers, and the service registration method includes: The client receives a service registration request initiated by a service provider, and sends the service registration request to the node manager; The node manager determines the virtual node corresponding to the service registration request according to the data sharding algorithm, determines the storage server corresponding to the virtual node from the multiple storage servers according to the mapping algorithm, and sends the service registration request to the storage server corresponding to the virtual node; The storage server stores the service data of the service provider in response to the received service registration request.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to claim 9 are implemented.
Citation Information
Patent Citations
Energy SCADA massive data distributed processing system and method thereof
CN105117171A
Service registration center
CN110049089A
Distributed registration center architecture
CN112272228A
Message pushing method and device, computer equipment and storage medium
CN117176796A
Resource data acquisition method and apparatus, computer device and storage medium
WO2021051880A1
Cited By
Nacos-based block chain network service management method and system
CN120455467A
