Domain name resolution method and device, computer device and storage medium
By constructing an array of load types and node identifiers, calculating weights based on the load information of service nodes, and selecting target node identifiers to generate response messages, the problem of unbalanced load on service nodes in multi-node cluster environments is solved, achieving more efficient load balancing and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-27
- Publication Date
- 2026-04-07
AI Technical Summary
Traditional domain name resolution technology cannot effectively solve the problem of uneven load on service nodes in a multi-node cluster environment, resulting in different load conditions on each service node.
By determining the load type of the target domain name, a node identifier array is constructed, where the number of node identifiers is positively correlated with the weight of the service node. The weight is calculated based on the load information, and the target node identifier is selected from the node identifier array to generate a response message, ensuring that the IP selection matches the load of the service node.
This achieves relative load balancing across service nodes during domain name resolution, avoiding load imbalance issues and improving the accuracy and load balancing of domain name resolution.
Smart Images

Figure CN116095086B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of network services, and in particular to a domain name resolution method and device, a computer device, a storage medium, and a computer program product. BACKGROUND
[0002] With the development of Domain Name System (DNS) services, domain name system resolution technology has emerged. Generally, one domain name corresponds to multiple Internet Protocol (IP) addresses. Traditional domain name resolution technology cannot obtain service node load pressure and can only sequentially return all IP addresses corresponding to the domain name after simple sorting by a round-robin strategy.
[0003] The current domain name system weighted load balancing technology can set a weight value for each node according to the performance differences of each service node in the service cluster. Generally, a larger weight value can be set for a service node with good performance, and a smaller weight value can be set for a service node with poor performance. This can make the service node with a larger weight be more easily selected, thereby achieving relatively balanced load according to the performance differences of the service nodes.
[0004] However, in a multi-node cluster environment, due to the differences in business, the load conditions such as bandwidth, Input / Output Operations Per Second (IOPS), and Central Processing Unit (CPU) usage of each node at the same time can be different. Therefore, through the traditional weighted load balancing technology, the problem of unbalanced load of each service node still exists. SUMMARY
[0005] Therefore, it is necessary to provide a domain name resolution method, device, computer device, computer readable storage medium, and computer program product that can achieve relatively balanced load of service nodes according to load conditions.
[0006] In a first aspect, the present application provides a domain name resolution method. The method comprises:
[0007] In response to a domain name resolution request for a target domain name, determining a corresponding target load type of the target domain name;
[0008] In the node identifier array corresponding to each load type, a target node identifier array corresponding to the target load type is determined; wherein the number of node identifiers corresponding to each service node in the target node identifier array is positively correlated with the weight of each service node for the target load type; and the weight of each service node for the target load type is obtained based on load information of the target load type of the service node.
[0009] According to a pre-stored node identifier determination strategy, a target node identifier is determined in the target node identifier array, and a response message corresponding to the domain name resolution request is generated based on an Internet Protocol address corresponding to the target node identifier.
[0010] By using the method, when a domain name resolution request is received, a node identifier can be determined based on a node identifier array matched with a target domain name, and a response message can be generated according to an IP address corresponding to the node identifier. Since the number of node identifiers corresponding to each service node in the target node identifier array is positively correlated with the weight of each service node for the target load type, and the weight of each service node for the target load type is obtained based on load information of the target load type of the service node, the IP selection manner based on the target node identifier array can be matched with the load condition of each service node, thereby avoiding the problem of unbalanced load of each service node.
[0011] In one of the embodiments, the method further comprises:
[0012] Obtaining a current load information set of each service node in a service cluster, wherein the load information set comprises load information of multiple load types;
[0013] For each load type, calculating the weight of each service node for the load type according to a preset weight calculation strategy and load information of the load type corresponding to each service node;
[0014] Based on the node identifier corresponding to each service node and the weight of each service node for the load type, a node identifier array corresponding to the load type is constructed, wherein the number of node identifiers corresponding to each service node in the node identifier array is positively correlated with the weight corresponding to the service node.
[0015] In the embodiment, by obtaining the current collected load information set and the preset weight calculation strategy, the weight of the corresponding service node matched with each load type is calculated, and the node identifier array corresponding to the current load information is constructed according to the node identifier corresponding to each service node and the weight of each service node for the load type, so that the node identifier array related to the load information type and the weight can be obtained, and the accuracy and load balancing degree when the domain name resolution is performed through the node identifier array subsequently can be improved.
[0016] In one of the embodiments, the calculating, for each of the load types, the weight of each of the service nodes for the load type according to a preset weight calculation strategy and the load information of the load type corresponding to each of the service nodes comprises:
[0017] For each of the load types, the temporary weight of each of the service nodes is calculated according to a preset load error corresponding to the load type and the load information of the load type corresponding to each of the service nodes, and the sum of the temporary weights is determined to obtain a temporary total weight;
[0018] The standard total weight of each of the service nodes is calculated according to a preset service node standard weight, a preset service node reserved weight and the total number of the service nodes;
[0019] Based on the temporary total weight and the standard total weight, a target scaling multiple is determined, and the weight of the service node for the load type is obtained according to the temporary weight of the service node, the target scaling multiple and the preset service node reserved weight.
[0020] In the embodiment, since different load types correspond to different preset load errors, the weight of the service node for the load type can be obtained according to the preset load error, the preset service node standard weight, the preset service node reserved weight and the total number of the service nodes.
[0021] In one of the embodiments, the constructing, based on the node identifier corresponding to each of the service nodes and the weight of each of the service nodes for the load type, the node identifier array corresponding to the load type comprises:
[0022] For each of the load types, the sum of the weights is calculated based on the weight of each of the service nodes for the load type to obtain a total weight;
[0023] The array size corresponding to the load type is determined according to the total weight, and the number of the node identifiers corresponding to each of the service nodes is determined according to the array size and the weight ratio;
[0024] The node identifier array corresponding to the load type is constructed based on the number of the node identifiers corresponding to each of the service nodes.
[0025] In the embodiment, the array size corresponding to the load type is determined according to the total weight, and the number of the node identifiers corresponding to each of the service nodes is determined according to the array size and the weight ratio, so that the weight of each of the service nodes can be determined according to the load condition, the load condition can be reflected according to the number of the node identifiers, and each of the node identifiers can be filled into the node identifier array.
[0026] In one of the embodiments, the node identifier array corresponding to the load type is constructed based on the number of node identifiers corresponding to each of the service nodes, including:
[0027] An initial array is generated according to the number of node identifiers corresponding to each of the service nodes and the array size;
[0028] Each of the node identifiers contained in the initial array is randomly sorted to obtain the node identifier array corresponding to the load type.
[0029] In the embodiment, the node identifiers are filled into the array according to the number of node identifiers corresponding to each of the service nodes and the length of the empty array, and the node identifiers are randomly sorted, which can achieve the effect that the node identifiers corresponding to each of the service nodes are distributed relatively uniformly, facilitate the probability of obtaining each service node identifier to be substantially consistent in subsequent obtaining of the target node identifier, and realize the effect that the loads of each of the service nodes are relatively balanced.
[0030] In one of the embodiments, the target node identifier is determined in the target node identifier array according to the pre-stored node identifier determination strategy, and a response message corresponding to the domain name resolution request is generated based on the internet protocol address corresponding to the target node identifier, including:
[0031] The target node identifier is determined in the target node identifier array according to the arrangement order of the pre-stored node identifier in the target node identifier array;
[0032] A target internet protocol address is randomly determined in the multiple internet protocol addresses corresponding to the target service node, and a response message corresponding to the domain name resolution request is generated based on the target internet protocol address.
[0033] In the embodiment, one node identifier is obtained as the target node identifier according to the arrangement order in the target node identifier array, and then a target internet protocol address is randomly determined in the multiple internet protocol addresses corresponding to the target service node, and a response message corresponding to the domain name resolution request is generated based on the target internet protocol address, which can achieve the effect that the internet protocol address is randomly obtained in the target service node, so that the probability of obtaining each internet protocol address is substantially consistent, and the effect of load balancing is further realized.
[0034] In a second aspect, the application further provides a domain name resolution device. The device includes:
[0035] A first determination module configured to determine a target load type corresponding to a target domain name in response to a domain name resolution request for the target domain name;
[0036] The second determining module is configured to determine a target node identifier array corresponding to the target load type in the node identifier array corresponding to each load type, wherein the number of node identifiers corresponding to each service node in the target node identifier array is positively correlated with the weight of each service node for the target load type, and the weight of each service node for the target load type is obtained based on load information of the target load type of the service node.
[0037] The generating module is configured to determine a target node identifier in the target node identifier array according to a pre-stored node identifier determination strategy, and generate a response message corresponding to the domain name resolution request based on an Internet Protocol (IP) address corresponding to the target node identifier.
[0038] By using the device, a node identifier can be determined based on a node identifier array matched with a target domain name when a domain name resolution request is received, and a response message can be generated according to an IP address corresponding to the node identifier. Since the number of node identifiers corresponding to each service node in the target node identifier array is positively correlated with the weight of each service node for the target load type, and the weight of each service node for the target load type is obtained based on load information of the target load type of the service node, the IP selection manner based on the target node identifier array can be matched with the load condition of each service node, thereby avoiding the problem of unbalanced loads of each service node.
[0039] In one of the embodiments, the device further includes:
[0040] The obtaining module is configured to obtain a current load information set of each service node in a service cluster, and the load information set includes load information of multiple load types.
[0041] The calculating module is configured to calculate, for each load type, a weight of each service node for the load type according to a preset weight calculation strategy and load information of the load type corresponding to each service node.
[0042] The constructing module is configured to construct a node identifier array corresponding to each load type based on a node identifier corresponding to each service node and a weight of each service node for the load type, and the number of node identifiers corresponding to each service node in the node identifier array is positively correlated with the weight corresponding to the service node.
[0043] In one of the embodiments, the calculating module is specifically configured to:
[0044] For each of the load types, a temporary weight of each of the service nodes is calculated according to a preset load error corresponding to the load type and load information of the load type corresponding to each of the service nodes, and a sum value of each of the temporary weights is determined to obtain a temporary total weight;
[0045] A standard total weight of each of the service nodes is calculated according to a preset service node standard weight and a preset service node reserved weight and a total number of the service nodes;
[0046] A target scaling multiple is determined based on the temporary total weight and the standard total weight, and a weight of the service node for the load type is obtained according to the temporary weight of the service node, the target scaling multiple and the preset service node reserved weight.
[0047] In one of the embodiments, the constructing module is specifically configured to:
[0048] For each of the load types, a total weight is calculated based on the weight of each of the service nodes for the load type;
[0049] An array size corresponding to the load type is determined according to the total weight, and a number of node identifiers corresponding to each of the service nodes is determined according to the array size and the weight ratio;
[0050] A node identifier array corresponding to the load type is constructed based on the number of node identifiers corresponding to each of the service nodes.
[0051] In one of the embodiments, the constructing module is specifically configured to:
[0052] An initial array is generated according to the number of node identifiers corresponding to each of the service nodes and the array size;
[0053] Each of the node identifiers contained in the initial array is randomly sorted to obtain the node identifier array corresponding to the load type.
[0054] In one of the embodiments, the generating module is specifically configured to:
[0055] A target node identifier is determined in the target node identifier array according to a pre-stored arrangement order of the node identifier in the target node identifier array;
[0056] A target internet protocol address is randomly determined from a plurality of internet protocol addresses corresponding to the target service node, and a response message corresponding to the domain name resolution request is generated based on the target internet protocol address.
[0057] In a third aspect, the present application provides a computer device. The computer device comprises a memory and a processor. The memory stores a computer program. The processor implements the following steps when executing the computer program:
[0058] In response to a domain name resolution request for a target domain name, determining a target load type corresponding to the target domain name;
[0059] In a node identifier array corresponding to each load type, determining a target node identifier array corresponding to the target load type; wherein in the target node identifier array, the number of node identifiers corresponding to each service node is positively correlated with the weight of each service node for the target load type; the weight of each service node for the target load type is obtained based on load information of the target load type of the service node;
[0060] According to a pre-stored node identifier determination strategy, determining a target node identifier in the target node identifier array, and generating a response message corresponding to the domain name resolution request based on an Internet protocol address corresponding to the target node identifier.
[0061] In a fourth aspect, the present application provides a computer readable storage medium. The computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the following steps:
[0062] In response to a domain name resolution request for a target domain name, determining a target load type corresponding to the target domain name;
[0063] In a node identifier array corresponding to each load type, determining a target node identifier array corresponding to the target load type; wherein in the target node identifier array, the number of node identifiers corresponding to each service node is positively correlated with the weight of each service node for the target load type; the weight of each service node for the target load type is obtained based on load information of the target load type of the service node;
[0064] According to a pre-stored node identifier determination strategy, determining a target node identifier in the target node identifier array, and generating a response message corresponding to the domain name resolution request based on an Internet protocol address corresponding to the target node identifier.
[0065] In a fifth aspect, the present application provides a computer program product. The computer program product comprises a computer program. The computer program is executed by a processor to implement the following steps:
[0066] In response to a domain name resolution request for a target domain name, determining a target load type corresponding to the target domain name;
[0067] In the node identifier array corresponding to each load type, a target node identifier array corresponding to the target load type is determined; in the target node identifier array, the number of node identifiers corresponding to each service node is positively correlated with the weight of each service node for the target load type; the weight of each service node for the target load type is obtained based on load information of the target load type of the service node;
[0068] According to a pre-stored node identifier determination strategy, a target node identifier is determined in the target node identifier array, and a response message corresponding to the domain name resolution request is generated based on an Internet protocol address corresponding to the target node identifier.
[0069] The domain name resolution method, device, computer device, storage medium and computer program product can determine a node identifier based on a node identifier array matched with a target domain name when receiving a domain name resolution request, and then generate a response message according to an IP address corresponding to the node identifier. Since the number of node identifiers corresponding to each service node in the target node identifier array is positively correlated with the weight of each service node for the target load type, and the weight of each service node for the target load type is obtained based on load information of the target load type of the service node, the IP selection method based on the target node identifier array can be matched with the load condition of each service node, thereby avoiding the problem of uneven load of each service node. BRIEF DESCRIPTION OF DRAWINGS
[0070] Figure 1 An application environment diagram of the domain name resolution method in one embodiment;
[0071] Figure 2 A flowchart of the domain name resolution method in one embodiment;
[0072] Figure 3 A flowchart of constructing a node identifier array in one embodiment;
[0073] Figure 4 A flowchart of obtaining an actual weight in one embodiment;
[0074] Figure 5 A flowchart of constructing a node identifier array in another embodiment;
[0075] Figure 6 A flowchart of obtaining a node identifier array in one embodiment;
[0076] Figure 7 A flowchart of generating a response message corresponding to a domain name resolution request in one embodiment;
[0077] Figure 8Fig. 1 is a structural block diagram of a domain name resolution device in an embodiment;
[0078] Figure 9 Fig. 2 is an internal structure diagram of a computer device in an embodiment. DETAILED DESCRIPTION
[0079] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0080] The domain name resolution method provided by the embodiments of the present application can be applied in an application environment as shown in Figure 1 . The terminal 102 communicates with the server 104 through a network. The data storage system can store data required to be processed by the server 104. The data storage system can be integrated on the server 104, or placed on a cloud or other network server. The terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things device can be a smart speaker, a smart television, a smart air conditioner, a smart vehicle device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The server 104 can be a DNS server. The DNS server is any service node in a service cluster. The service nodes can communicate with each other through a network. Each service node includes a pre-configured management service.
[0081] In an embodiment, as shown in Figure 2 , a domain name resolution method is provided. The method is described by taking the DNS server in Figure 1 as an example, which includes the following steps:
[0082] Step 202, in response to a domain name resolution request for a target domain name, determining a corresponding target load type of the target domain name.
[0083] The load type can include, but is not limited to, at least one of a CPU utilization type, an IOPS type and a bandwidth type.
[0084] In the embodiment of the present application, the terminal initiates a domain name resolution request to the DNS server, the DNS server responds to the domain name resolution request sent by the terminal for the target domain name, resolves the domain name resolution request, and obtains the target domain name. The DNS server can pre-store a domain name and load balancing policy correspondence relationship, so that the DNS server can find the target load balancing policy corresponding to the target domain name in the correspondence relationship, determine the target load type corresponding to the target domain name according to the target load balancing policy, wherein the target load type can be one of CPU utilization, IOPS type and bandwidth type. Optionally, the load type can also be other load types determined according to the pre-configured load balancing policy, which is not limited in the present application. Optionally, in the case where it is detected that the current DNS server fails, any other service node can be selected as the DNS server, and the Internet protocol address corresponding to the failed DNS server can also be floated to any other service node.
[0085] Step 204, in the node identifier array corresponding to each load type, determine the target node identifier array corresponding to the target load type.
[0086] In the target node identifier array, the number of node identifiers corresponding to each service node is positively correlated with the weight of each service node for the target load type; the weight of the service node for the target load type is obtained based on the load information of the target load type of the service node; the node identifier is used to uniquely identify each service node. Optionally, the node identifier can be a digital identifier obtained according to the preset number of each service node, and the service node is any node in the service cluster.
[0087] In the embodiment of the present application, the DNS server can pre-store a node identifier array corresponding to each load type, and then the DNS server determines the target node identifier array corresponding to the target load type in the plurality of node identifier arrays according to the target load type.
[0088] Step 206, determine the target node identifier in the target node identifier array according to the pre-stored node identifier determination strategy, and generate a response message corresponding to the domain name resolution request based on the Internet protocol address corresponding to the target node identifier.
[0089] In the embodiment of the present application, the DNS server can pre-store a node identifier array corresponding to each load type, and then the DNS server determines the target node identifier array corresponding to the target load type in the plurality of node identifier arrays according to the target load type.
[0090] In the embodiment, when the DNS server receives a DNS resolution request, the DNS server can determine a policy according to a pre-stored node identifier, select a service node corresponding to a node identifier in the target node identifier array as a target service node at random, and then, when the DNS server receives a next DNS resolution request, select a node identifier in the target node identifier array excluding the last target service node at random, and select a service node corresponding to the node identifier as a target service node. Then, the DNS server selects an Internet protocol address as a target Internet protocol address from a plurality of Internet protocol addresses corresponding to the target service node. The DNS server generates a response message according to the target Internet protocol address, and then returns the response message to the terminal.
[0091] In the domain name resolution method, when a domain name resolution request is received, a node identifier is determined based on a target domain name matching node identifier array, and a response message is generated according to an IP address corresponding to the node identifier. Since the number of node identifiers corresponding to each service node in the target node identifier array is positively correlated with the weight of each service node for the target load type, and the weight of each service node for the target load type is obtained based on the load information of the target load type of the service node, the IP selection method based on the target node identifier array can match the load condition of each service node, thereby avoiding the problem of uneven load of each service node.
[0092] In one embodiment, as shown in FIG. 3, the method further includes: Figure 3
[0093] In step 302, the current load information set of each service node in the service cluster is obtained.
[0094] The load information set includes load information of a plurality of load types, and includes CPU utilization type, IOPS type and bandwidth type load information.
[0095] In the embodiment, the DNS server calls a management service pre-configured on the DNS server, and according to a preset acquisition frequency, sends the number of Internet protocol addresses corresponding to each service node in the current service cluster to the DNS server in a time period corresponding to the preset acquisition frequency. Then, the DNS server calls the management service, and sends the load information set corresponding to each service node in the current service cluster to the DNS server.
[0096] In step 304, for each load type, the weight of each service node for the load type is calculated according to a preset weight calculation policy and the load information of each service node for the load type.
[0097] In the embodiment of the present application, the DNS server calculates the weight of each load type of each service node according to the load information of the preset time period of the load type corresponding to each service node, which can be a time period corresponding to the current time, for example, the DNS server can collect the load information of the CPU utilization type, the IOPS type, the bandwidth type and the like within a preset time length starting from the current time, and then calculate the weight of each load type of each service node according to the collected load information and the pre-stored preset weight calculation strategy. In an implementation manner, the preset time period can be 10 seconds.
[0098] In step 306, the node identifier array corresponding to each load type is constructed based on the node identifier corresponding to each service node and the weight of each load type of each service node.
[0099] In the node identifier array, the number of node identifiers corresponding to each service node is positively correlated with the weight of the service node.
[0100] In the embodiment of the present application, the DNS server obtains the digital identifier obtained according to the preset number of the service node as the node identifier corresponding to the service node, and then constructs the node identifier array corresponding to each load type according to each node identifier and the weight of each load type of each service node, for example, the DNS server constructs the node identifier array corresponding to the CPU utilization type according to each node identifier and the weight of the CPU utilization type of each service node.
[0101] In the embodiment, by obtaining the current collected load information set and the preset weight calculation strategy, the DNS server can calculate the weight of the corresponding service node matched with each load type at present, and construct the node identifier array corresponding to the current load information according to the node identifier corresponding to each service node and the weight of each load type of each service node at present, so that the node identifier array related to the load information type and the weight can be obtained, and the accuracy and the load balancing degree in subsequent domain name resolution through the node identifier array can be improved.
[0102] In one embodiment, as shown in Figure 4 step 304 includes:
[0103] In step 402, for each load type, the temporary weight of each service node is calculated according to the preset load error corresponding to the load type and the load information of the load type corresponding to each service node, and the sum of each temporary weight is determined to obtain the temporary total weight.
[0104] In the embodiment of the present application, the DNS server calculates the temporary weight of each service node according to the preset temporary weight calculation formula, for each load type, according to the preset load error corresponding to the load type and the load information of the load type corresponding to each service node, and then the DNS server performs summation calculation on each temporary weight to obtain a temporary total weight.
[0105] Specifically, the preset temporary weight calculation formula is as follows:
[0106]
[0107] wherein n is the total number of service nodes in the service cluster, Yi is the temporary weight of the i th service node, Xi is the load information of the load type corresponding to the i th service node, k is the preset load error, X1 is the load information of the first service node, X2 is the load information of the second service node, and so on, and Xn is the load information of the n th service node. Specifically, the preset load error can be different preset values for each type of load information, for example, the preset load error value corresponding to the CPU utilization type can be two percent, the preset load error value corresponding to the IOPS type can be 10 or 20, and the preset load error value corresponding to the bandwidth type can be 1 megabyte (1 Mbps).
[0108] In step 404, the standard total weight of each service node is calculated according to the preset service node standard weight and the preset service node reserved weight, and the total number of service nodes.
[0109] In the embodiment of the present application, each service node can send a network communication message to the DNS server, and the DNS server obtains the total number of service nodes through the network communication message according to the pre-configured management service, then the DNS server calculates the sum of the preset service node standard weight and the preset service node reserved weight, and further performs multiplication calculation on the sum and the total number of service nodes to obtain the standard total weight of each service node. The formula for calculating the standard total weight is as follows:
[0110] W = (f + r) * n
[0111] wherein W is the standard total weight of each service node, f is the preset service node standard weight, r is the preset service node reserved weight, and n is the total number of service nodes in the service cluster. Specifically, the preset service node standard weight and the preset service node reserved weight can be set according to actual conditions, for example, the preset service node standard weight can be 20 and the preset service node reserved weight can be 10.
[0112] At step 406, a target scaling multiple is determined based on the temporary total weight and the standard total weight, and a weight of the service node for the load type is obtained according to the temporary weight of the service node, the target scaling multiple, and a preset service node reserved weight.
[0113] In the embodiment of the present application, the DNS server performs a division operation on the temporary total weight and the actual total weight, takes a quotient value after the division operation as the target scaling multiple, and then calculates the actual weight of the service node according to a preset actual weight calculation formula, the temporary weight, the target scaling multiple, and the preset service node reserved weight, and takes the actual weight of the service node as the weight of the service node for the load type. The specific preset actual weight calculation formula is as follows:
[0114] Hi=Yi / m+r
[0115] wherein Hi is the actual weight corresponding to the i th service node, Yi is the temporary weight of the i th service node, m is the target scaling multiple, and r is the preset service node reserved weight. The actual weight corresponding to each stage is processed by taking an integer, and the actual weight of the data type is obtained as an integer type.
[0116] In the embodiment, since different load types correspond to different preset load errors, the weight of the service node for the load type can be obtained according to the preset load error, the preset service node standard weight, the preset service node reserved weight, and the total number of the service nodes.
[0117] In one embodiment, as shown in FIG. 3, step 306 includes: Figure 5
[0118] At step 502, for each load type, a sum value of the weights is calculated based on the weight of each service node for the load type, and a total weight is obtained.
[0119] In the embodiment of the present application, for each load type, the DNS server can calculate the weight of each service node for the load type, and then calculate the sum of the weight of each service node for the load type, and obtain the sum value of the weights of the service nodes. The DNS server takes the sum value as the total weight of the service nodes, and then processes the value of the total weight by taking an integer, and obtains the total weight of the data type as an integer type.
[0120] At step 504, an array size corresponding to the load type is determined according to the total weight, and the number of node identifiers corresponding to each service node is determined according to the array size and the weight ratio.
[0121] In the embodiment of the present application, the DNS server pre-generates an empty array, determines the size of the empty array according to the total weight of each service node corresponding to the load type, and specifically, the length of the generated empty array is the same as the value of the total weight corresponding to the load type. Alternatively, the length of the empty array can also be a multiple of the total weight corresponding to the load type. Then, the DNS server calculates the number of node identifiers corresponding to each service node according to the weight proportion of each service node and the size of the empty array. Specifically, the DNS server can multiply the weight proportion of each service node and the size of the empty array to obtain the number of node identifiers corresponding to each service node. For example, the length of the empty array is 3, and the weight proportion of each service node is 1:1:1. The calculation method of the number of node identifiers corresponding to each service node is 1 / 3*3, and the number of node identifiers corresponding to each service node can be obtained as 1.
[0122] In step 506, a node identifier array corresponding to the load type is constructed based on the number of node identifiers corresponding to each service node.
[0123] In the embodiment of the present application, the DNS server constructs the node identifier array corresponding to the load type according to the number of node identifiers corresponding to each service node and the empty array with the length consistent with the total weight corresponding to the load type. Specifically, multiple node identifier arrays can be constructed simultaneously according to the number of load types.
[0124] In the embodiment, the DNS server determines the array size corresponding to the load type through the total weight, and determines the number of node identifiers corresponding to each service node according to the array size and the weight proportion. The weight of each service node can be determined according to the load condition, and the number of node identifiers can reflect the load condition, which is convenient for filling each node identifier into the node identifier array subsequently.
[0125] In one embodiment, as shown in FIG. 6, step 506 includes: Figure 6
[0126] In step 602, an initial array is generated according to the number of node identifiers corresponding to each service node and the array size.
[0127] In the embodiment of the present application, the DNS server adds the node identifiers into the empty array in the order from small to large according to the number of node identifiers corresponding to each service node and the length of the empty array, to obtain the initial array, wherein the total number of node identifiers corresponding to each service node can be less than or equal to the length of the empty array.
[0128] In step 604, each node identifier contained in the initial array is randomly sorted to obtain the node identifier array corresponding to the load type.
[0129] In this embodiment of the application, the DNS server randomly sorts the node identifiers contained in each initial array corresponding to each load type, resulting in a node identifier array in which the node identifiers are arranged in a random order.
[0130] In this embodiment, the DNS server fills the node identifiers into the array according to the number of node identifiers corresponding to each service node and the length of the empty array, and randomly sorts the node identifiers. This achieves a relatively uniform distribution of node identifiers corresponding to each service node, making it easier to obtain the identifier of each service node with a basically consistent probability when obtaining the identifier of the target node in the future, and achieving a relatively balanced load on each service node.
[0131] In one embodiment, such as Figure 7 As shown, step 206 includes:
[0132] Step 702: Determine the target node identifier in the target node identifier array according to the pre-stored node identifier arrangement order in the target node identifier array.
[0133] The node identifiers are arranged in the target node identifier array in a random order.
[0134] In this embodiment, the DNS server obtains a node identifier as the target node identifier based on the pre-stored order of node identifiers in the target node identifier array, according to the ascending order of the index values in the target node identifier array. Specifically, when the DNS server receives multiple domain name resolution requests simultaneously, upon receiving the first domain name resolution request, it obtains the node identifier corresponding to the first index value in the target node identifier array as the target node identifier; upon receiving the second domain name resolution request, it obtains the node identifier corresponding to the second index value in the target node identifier array as the target node identifier; and so on, sequentially obtaining the node identifier corresponding to each index value in the target node identifier array until an index value in the target node identifier array does not correspond to any node identifier (i.e., the member corresponding to the index value in the target node identifier array is empty), and repeats the step of using the node identifier corresponding to the first index value in the target node identifier array as the target node identifier.
[0135] Step 704: Randomly determine the target Internet Protocol address from among the multiple Internet Protocol addresses corresponding to the target service node, and generate a response message corresponding to the domain name resolution request based on the target Internet Protocol address.
[0136] In this embodiment, a service node may correspond to at least one Internet Protocol (IP) address, and the DNS server may pre-store the mapping relationship between service nodes and IP addresses. After obtaining the target service node based on the target service node identifier, the DNS server can search for multiple IP addresses corresponding to the target service node in the mapping relationship, and then randomly select one IP address from the found multiple IP addresses as the target IP address. Based on the target IP address, the DNS server generates a response message corresponding to the domain name resolution request, and then returns the response message to the terminal.
[0137] In this embodiment, a node identifier is obtained by the DNS server according to the order of the target node identifier array, and used as the target node identifier. Then, the DNS server randomly determines the target Internet Protocol address from among the multiple Internet Protocol addresses corresponding to the target service node, and generates a response message corresponding to the domain name resolution request based on the target Internet Protocol address. This achieves the effect of randomly obtaining Internet Protocol addresses from the target service node, so that the probability of obtaining each Internet Protocol address is basically the same, and further realizes the effect of load balancing.
[0138] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0139] Based on the same inventive concept, this application also provides a domain name resolution apparatus for implementing the domain name resolution method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more domain name resolution apparatus embodiments provided below can be found in the limitations of the domain name resolution method described above, and will not be repeated here.
[0140] In one embodiment, such as Figure 8 As shown, a domain name resolution device is provided, including: a first determining module 802, a second determining module 804, and a generating module 806, wherein:
[0141] The first determining module 802 is used to determine the target load type corresponding to the target domain name in response to a domain name resolution request for the target domain name.
[0142] The second determining module 804 is used to determine the target node identifier array corresponding to the target load type in the node identifier array corresponding to each load type; wherein, in the target node identifier array, the number of node identifiers corresponding to each service node is positively correlated with the weight of each service node for the target load type; the weight of the service node for the target load type is obtained based on the load information of the target load type of the service node.
[0143] The generation module 806 is used to determine the target node identifier in the target node identifier array according to the pre-stored node identifier determination strategy, and generate a response message corresponding to the domain name resolution request based on the Internet Protocol address corresponding to the target node identifier.
[0144] In one embodiment, the apparatus further includes:
[0145] The acquisition module is used to acquire the current load information set of each service node in the service cluster, and the load information set includes load information of multiple load types;
[0146] The calculation module is used to calculate the weight of each service node for each load type according to a preset weight calculation strategy and the load information of each load type corresponding to each service node;
[0147] The construction module is used to construct a node identifier array corresponding to the load type based on the node identifier corresponding to each service node and the weight of each service node for the load type. The number of node identifiers corresponding to each service node in the node identifier array is positively correlated with the weight of the service node.
[0148] In one embodiment, the computing module is specifically used for:
[0149] For each load type, based on the preset load error corresponding to the load type and the load information of the load type corresponding to each service node, the temporary weight of each service node is calculated, and the sum of the temporary weights is determined to obtain the total temporary weight.
[0150] The standard total weight of each service node is calculated based on the preset standard weight of the service node, the preset retention weight of the service node, and the total number of each service node.
[0151] Based on the temporary total weight and the standard total weight, the target scaling factor is determined. Based on the temporary weight of the service node, the target scaling factor, and the preset service node retention weight, the weight of the service node for the load type is obtained.
[0152] In one embodiment, the building module is specifically used for:
[0153] For each load type, based on the weight of each service node for that load type, the sum of the weights is calculated to obtain the total weight;
[0154] The array size corresponding to the load type is determined based on the total weight, and the number of node identifiers corresponding to each service node is determined based on the array size and the weight ratio.
[0155] Based on the number of node identifiers corresponding to each of the service nodes, construct an array of node identifiers corresponding to the load type.
[0156] In one embodiment, the building module is specifically used for:
[0157] An initial array is generated based on the number of node identifiers corresponding to each service node and the array size;
[0158] The node identifiers contained in the initial array are randomly sorted to obtain the node identifier array corresponding to the load type.
[0159] In one embodiment, the generation module 806 is specifically used for:
[0160] The target node identifier is determined in the target node identifier array according to the pre-stored node identifier arrangement order in the target node identifier array;
[0161] Among the multiple Internet Protocol addresses corresponding to the target service node, a target Internet Protocol address is randomly determined, and a response message corresponding to the domain name resolution request is generated based on the target Internet Protocol address.
[0162] Each module in the aforementioned domain name resolution device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0163] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 9As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores load information corresponding to storage nodes. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a domain name resolution method.
[0164] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0165] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0166] In response to a domain name resolution request for a target domain name, determine the target load type corresponding to the target domain name;
[0167] In the node identifier array corresponding to each load type, a target node identifier array corresponding to the target load type is determined; wherein, in the target node identifier array, the number of node identifiers corresponding to each service node is positively correlated with the weight of each service node for the target load type; the weight of the service node for the target load type is obtained based on the load information of the service node for the target load type.
[0168] According to the pre-stored node identifier determination strategy, the target node identifier is determined in the target node identifier array, and a response message corresponding to the domain name resolution request is generated based on the Internet Protocol address corresponding to the target node identifier.
[0169] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0170] Obtain the current load information set of each service node in the service cluster, the load information set including load information of multiple load types;
[0171] For each load type, the weight of each service node for the load type is calculated according to a preset weight calculation strategy and the load information of the load type corresponding to each service node;
[0172] Based on the node identifiers corresponding to each service node and the weights of each service node for the load type, a node identifier array corresponding to the load type is constructed. The number of node identifiers corresponding to each service node in the node identifier array is positively correlated with the weights of the service nodes.
[0173] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0174] For each load type, based on the preset load error corresponding to the load type and the load information of the load type corresponding to each service node, the temporary weight of each service node is calculated, and the sum of the temporary weights is determined to obtain the total temporary weight.
[0175] The standard total weight of each service node is calculated based on the preset standard weight of the service node, the preset retention weight of the service node, and the total number of each service node.
[0176] Based on the temporary total weight and the standard total weight, the target scaling factor is determined. Based on the temporary weight of the service node, the target scaling factor, and the preset service node retention weight, the weight of the service node for the load type is obtained.
[0177] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0178] For each load type, based on the weight of each service node for that load type, the sum of the weights is calculated to obtain the total weight;
[0179] The array size corresponding to the load type is determined based on the total weight, and the number of node identifiers corresponding to each service node is determined based on the array size and the weight ratio.
[0180] Based on the number of node identifiers corresponding to each of the service nodes, construct an array of node identifiers corresponding to the load type.
[0181] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0182] An initial array is generated based on the number of node identifiers corresponding to each service node and the array size;
[0183] The node identifiers contained in the initial array are randomly sorted to obtain the node identifier array corresponding to the load type.
[0184] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0185] The target node identifier is determined in the target node identifier array according to the pre-stored node identifier arrangement order in the target node identifier array;
[0186] Among the multiple Internet Protocol addresses corresponding to the target service node, a target Internet Protocol address is randomly determined, and a response message corresponding to the domain name resolution request is generated based on the target Internet Protocol address.
[0187] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0188] In response to a domain name resolution request for a target domain name, determine the target load type corresponding to the target domain name;
[0189] In the node identifier array corresponding to each load type, a target node identifier array corresponding to the target load type is determined; wherein, in the target node identifier array, the number of node identifiers corresponding to each service node is positively correlated with the weight of each service node for the target load type; the weight of the service node for the target load type is obtained based on the load information of the service node for the target load type.
[0190] According to the pre-stored node identifier determination strategy, the target node identifier is determined in the target node identifier array, and a response message corresponding to the domain name resolution request is generated based on the Internet Protocol address corresponding to the target node identifier.
[0191] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0192] Obtain the current load information set of each service node in the service cluster, the load information set including load information of multiple load types;
[0193] For each load type, the weight of each service node for the load type is calculated according to a preset weight calculation strategy and the load information of the load type corresponding to each service node;
[0194] Based on the node identifiers corresponding to each service node and the weights of each service node for the load type, a node identifier array corresponding to the load type is constructed. The number of node identifiers corresponding to each service node in the node identifier array is positively correlated with the weights of the service nodes.
[0195] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0196] For each load type, based on the preset load error corresponding to the load type and the load information of the load type corresponding to each service node, the temporary weight of each service node is calculated, and the sum of the temporary weights is determined to obtain the total temporary weight.
[0197] The standard total weight of each service node is calculated based on the preset standard weight of the service node, the preset retention weight of the service node, and the total number of each service node.
[0198] Based on the temporary total weight and the standard total weight, the target scaling factor is determined. Based on the temporary weight of the service node, the target scaling factor, and the preset service node retention weight, the weight of the service node for the load type is obtained.
[0199] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0200] For each load type, based on the weight of each service node for that load type, the sum of the weights is calculated to obtain the total weight;
[0201] The array size corresponding to the load type is determined based on the total weight, and the number of node identifiers corresponding to each service node is determined based on the array size and the weight ratio.
[0202] Based on the number of node identifiers corresponding to each of the service nodes, construct an array of node identifiers corresponding to the load type.
[0203] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0204] An initial array is generated based on the number of node identifiers corresponding to each service node and the array size;
[0205] The node identifiers contained in the initial array are randomly sorted to obtain the node identifier array corresponding to the load type.
[0206] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0207] The target node identifier is determined in the target node identifier array according to the pre-stored node identifier arrangement order in the target node identifier array;
[0208] Among the multiple Internet Protocol addresses corresponding to the target service node, a target Internet Protocol address is randomly determined, and a response message corresponding to the domain name resolution request is generated based on the target Internet Protocol address.
[0209] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the steps described in the above method embodiments.
[0210] 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, data stored, data displayed, 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 the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0211] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media 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), magnetic 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. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0212] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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.
[0213] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A domain name resolution method, characterized in that, The method includes: In response to a domain name resolution request for a target domain name, determine the target load type corresponding to the target domain name; In the node identifier array corresponding to each load type, a target node identifier array corresponding to the target load type is determined; wherein, in the target node identifier array, the number of node identifiers corresponding to each service node is positively correlated with the weight of each service node for the target load type; the weight of the service node for the target load type is obtained based on the load information of the service node for the target load type. According to the pre-stored node identifier determination strategy, the target node identifier is determined in the target node identifier array, and a response message corresponding to the domain name resolution request is generated based on the Internet Protocol address corresponding to the target node identifier. The method further includes: For each load type, the sum of the weights of each service node for the load type is calculated to obtain the total weight; the array size corresponding to the load type is determined according to the total weight, and the number of node identifiers corresponding to each service node is determined according to the array size and the weight ratio; based on the number of node identifiers corresponding to each service node, an array of node identifiers corresponding to the load type is constructed.
2. The method according to claim 1, characterized in that, The method further includes: Obtain the current load information set of each service node in the service cluster, the load information set including load information of multiple load types; For each load type, the weight of each service node for the load type is calculated according to a preset weight calculation strategy and the load information of the load type corresponding to each service node; The number of node identifiers corresponding to each service node in the node identifier array is positively correlated with the weight corresponding to the service node.
3. The method according to claim 2, characterized in that, For each load type, the weight of each service node for that load type is calculated based on a preset weight calculation strategy and the load information of each service node corresponding to that load type, including: For each load type, based on the preset load error corresponding to the load type and the load information of the load type corresponding to each service node, the temporary weight of each service node is calculated, and the sum of the temporary weights is determined to obtain the total temporary weight. The standard total weight of each service node is calculated based on the preset standard weight of the service node, the preset retention weight of the service node, and the total number of each service node. Based on the temporary total weight and the standard total weight, the target scaling factor is determined. Based on the temporary weight of the service node, the target scaling factor, and the preset service node retention weight, the weight of the service node for the load type is obtained.
4. The method according to claim 1, characterized in that, The step of constructing a node identifier array corresponding to the load type based on the number of node identifiers corresponding to each service node includes: An initial array is generated based on the number of node identifiers corresponding to each service node and the array size; The node identifiers contained in the initial array are randomly sorted to obtain the node identifier array corresponding to the load type.
5. The method according to claim 1, characterized in that, The step of determining the target node identifier from the target node identifier array according to a pre-stored node identifier determination strategy, and generating a response message corresponding to the domain name resolution request based on the Internet Protocol address corresponding to the target node identifier, includes: The target node identifier is determined in the target node identifier array according to the pre-stored node identifier arrangement order in the target node identifier array; Among the multiple Internet Protocol addresses corresponding to the target service node, a target Internet Protocol address is randomly determined, and a response message corresponding to the domain name resolution request is generated based on the target Internet Protocol address.
6. A domain name resolution device, characterized in that, The device includes: The first determining module is used to determine the target load type corresponding to the target domain name in response to a domain name resolution request for the target domain name; The second determining module is used to determine the target node identifier array corresponding to the target load type from the node identifier array corresponding to each load type; wherein, in the target node identifier array, the number of node identifiers corresponding to each service node is positively correlated with the weight of each service node for the target load type; the weight of the service node for the target load type is obtained based on the load information of the target load type of the service node; The generation module is used to determine the target node identifier in the target node identifier array according to the pre-stored node identifier determination strategy, and generate the response message corresponding to the domain name resolution request based on the Internet Protocol address corresponding to the target node identifier. The device further includes: A construction module is used to calculate the sum of the weights of each service node for each load type to obtain a total weight; determine the array size corresponding to the load type according to the total weight; determine the number of node identifiers corresponding to each service node according to the array size and the weight ratio; and construct a node identifier array corresponding to the load type based on the number of node identifiers corresponding to each service node.
7. The apparatus according to claim 6, characterized in that, The generation module is specifically used to determine the target node identifier in the target node identifier array according to the arrangement order of the pre-stored node identifiers in the target node identifier array; Among the multiple Internet Protocol addresses corresponding to the target service node, a target Internet Protocol address is randomly determined, and a response message corresponding to the domain name resolution request is generated based on the target Internet Protocol address.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Load balancing method, device and system, target load balancing equipment and medium
CN112491066A
Load balancing method, device and equipment for DNS (Domain Name Server) domain name resolution and medium
CN115225608A