Methods, apparatus, devices, and storage media for balanced distribution of network requested resources
By receiving information about resource requests from terminals, counting the number of hash values and adjusting the hash values, the problem of unbalanced load in large-scale service systems is solved, achieving uniform distribution of requested resources and load balancing, thus improving the system's responsiveness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILEHANGZHOUINFORMATION TECH CO LTD
- Filing Date
- 2022-12-12
- Publication Date
- 2026-05-05
AI Technical Summary
In large-scale information systems, the high concentration of user requests within a short period leads to an uneven load distribution. Existing predictive and post-analysis solutions lack sufficient accuracy and cannot effectively address this issue.
By receiving information about resource requests from terminals, the hash value and its generation time are determined, the number of times the same hash value is obtained within a preset time is counted, a disturbance factor is determined based on the number of times and a threshold, the hash value is adjusted, and the requested resources are redistributed to edge servers to achieve load balancing.
It achieves a uniform distribution of highly concentrated request content within a short period of time, improving the balance and real-time performance of load distribution, and avoiding the shortcomings of inaccurate prediction and post-event adjustment in existing technologies.
Smart Images

Figure CN116915778B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for the balanced distribution of network request resources. Background Technology
[0002] In large-scale information systems, service clusters with multiple service units are often required to handle massive user requests. In certain business scenarios, there is a need to use content-based consistent hashing to distribute service units within the cluster according to content independence and exclusivity. This can lead to uneven load distribution due to short-term high concentrations of user requests. Currently, there is no effective solution to this problem. Summary of the Invention
[0003] To address the related technical issues, embodiments of the present invention provide a method, apparatus, device, and storage medium for the balanced distribution of network request resources.
[0004] To achieve the above objectives, the technical solution of this invention is implemented as follows:
[0005] In a first aspect, embodiments of the present invention provide a method for the balanced distribution of network request resources, the method comprising:
[0006] The system receives first information requesting resources from at least one terminal, and determines first data corresponding to the resource request for each of the at least one terminal based on the first information; the first data includes at least a hash value corresponding to the resource request for each terminal and the time when the hash value was generated.
[0007] Based on the first data, determine the number of times the same first hash value exists within a preset time period;
[0008] If the number of occurrences is greater than or equal to a preset threshold, the perturbation factor corresponding to the first hash value is determined based on the number of occurrences and the preset threshold.
[0009] The multiple first hash values are adjusted according to the perturbation factor to obtain the second hash value corresponding to each first hash value at a different position in the preset hash ring;
[0010] The information of the requested resource corresponding to the second hash value is distributed to the edge servers corresponding to the different locations.
[0011] In the above scheme, determining the first data corresponding to the resource request of each terminal 5 in the at least one terminal based on the first information includes:
[0012] The first information is pre-mapped using a preset hash function to obtain the hash value corresponding to each terminal's requested resource and the time when the hash value was generated.
[0013] The hash value corresponding to each terminal requesting resources and the time when the hash value was generated are used as the first data.
[0014] 0. In the above scheme, the method further includes:
[0015] Obtain a first identifier corresponding to each edge server in at least one edge server, and generate a third hash value based on the first identifier;
[0016] Determine the first position of the third hash value in the preset hash ring and the second position of the fourth hash value corresponding to the preset requested resource in the preset hash ring;
[0017] 5. Associate the first position and the second position to obtain a first relationship between the third hash value and the fourth hash value; the first relationship is used to determine the edge server corresponding to the hash value of each terminal requesting resources.
[0018] In the above scheme, the method further includes:
[0019] The hash value corresponding to each terminal requesting resources is matched with the fourth hash value to obtain the fourth hash value that matches 0 with the hash value corresponding to each terminal requesting resources;
[0020] Based on the first relationship and the matched fourth hash value, the edge server corresponding to the hash value of each terminal requesting resources is determined.
[0021] In the above scheme, the method further includes:
[0022] 5. Determine a fifth hash value outside the preset time based on the time the hash value was generated; 6. Delete the fifth hash value in the middle of the first data.
[0023] In the above scheme, determining the perturbation factor corresponding to the first hash value based on the number of occurrences and the preset threshold includes:
[0024] Determine a second relationship between the number of times and the preset threshold;
[0025] The perturbation factor corresponding to the first hash value is determined based on the second relationship.
[0026] In the above scheme, the perturbation factor includes at least a perturbation parameter; the step of adjusting multiple first hash values according to the perturbation factor to obtain a second hash value corresponding to each first hash value at a different position in a preset hash ring includes:
[0027] Determine the random parameters corresponding to the disturbance parameters;
[0028] Based on the random parameters, multiple first hash values are adjusted to obtain second hash values corresponding to different positions of each first hash value in a preset hash ring.
[0029] Secondly, embodiments of the present invention also provide a device for the balanced distribution of network request resources, the device comprising: a receiving unit, a determining unit, an adjusting unit, and a distributing unit, wherein,
[0030] The receiving unit is configured to receive first information of at least one terminal requesting resources, and determine first data corresponding to the resource request of each of the at least one terminal based on the first information; the first data includes at least the hash value corresponding to the resource request of each terminal and the time when the hash value was generated.
[0031] The determining unit is configured to determine, based on the first data, the number of times the same first hash value exists within a preset time period; and, if the number of times is greater than or equal to a preset threshold, to determine the perturbation factor corresponding to the first hash value based on the number of times and the preset threshold.
[0032] The adjustment unit is used to adjust multiple first hash values according to the disturbance factor to obtain a second hash value corresponding to each first hash value at a different position in a preset hash ring;
[0033] The distribution unit is used to distribute the information of the requested resource corresponding to the second hash value to the edge servers corresponding to the different locations.
[0034] Thirdly, embodiments of the present invention also provide an electronic device, comprising:
[0035] Memory, used to store executable instructions;
[0036] A processor, when executing executable instructions stored in the memory, implements any step of the method described above.
[0037] Fourthly, embodiments of the present invention also provide a storage medium storing executable instructions for implementing any step of the method described above when executed by a processor.
[0038] The present invention provides a method, apparatus, device, and storage medium for balanced distribution of network request resources. The method includes: receiving first information about at least one terminal requesting resources; determining first data corresponding to the resource request of each of the at least one terminal based on the first information; the first data including at least a hash value corresponding to the resource request of each terminal and the time the hash value was generated; determining the number of times the same first hash value exists within a preset time period based on the first data; if the number of times is greater than or equal to a preset threshold, determining a perturbation factor corresponding to the first hash value based on the number of times and the preset threshold; adjusting multiple first hash values according to the perturbation factor to obtain a second hash value corresponding to each first hash value at a different position in a preset hash ring; and distributing the resource request information corresponding to the second hash value to edge servers corresponding to the different positions. The technical solution of this invention involves determining a perturbation factor corresponding to the first hash value based on the number of occurrences and the preset threshold when the number of occurrences is greater than or equal to a preset threshold; adjusting multiple first hash values based on the perturbation factor to obtain a second hash value corresponding to each first hash value at a different position in a preset hash ring; and distributing the information of the requested resources corresponding to the second hash value to the edge servers corresponding to the different positions. This enables the even distribution of highly concentrated request content that occurs in a short period of time to different edge servers, thereby achieving load balancing. Attached Figure Description
[0039] Figure 1 A flowchart illustrating a method for balanced distribution of network request resources provided in an embodiment of the present invention;
[0040] Figure 2 A schematic diagram of a consistent hashing method provided in an embodiment of the present invention;
[0041] Figure 3 A schematic diagram of an adjusted load balancing dynamic hashing process provided in an embodiment of the present invention;
[0042] Figure 4 A schematic flowchart illustrating the conditional judgment of hash perturbation provided in an embodiment of the present invention;
[0043] Figure 5 A schematic diagram of a request resource distribution process including parameters is provided for an embodiment of the present invention;
[0044] Figure 6 A schematic diagram of the composition structure of a network request resource equalization distribution device provided in an embodiment of the present invention;
[0045] Figure 7 This is a schematic diagram of a hardware entity structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0046] To better understand the embodiments of the present invention, the following terms are now explained:
[0047] A hash is an algorithm that transforms an input of arbitrary length into an output of fixed length, which is called the hash value.
[0048] Hash premapping refers to the input content for hash calculation.
[0049] A hash value is the output result of a hash calculation.
[0050] A hash function is a mathematical method for performing hash calculations.
[0051] Hash scrambling adjusts the hash value, affecting its subsequent matching results.
[0052] The hash perturbation factor is the range of adjustment for a hash value, representing the maximum number of new hashes that can be derived from the same hash value.
[0053] The perturbation threshold is the limit value of hash keys that can appear per unit of time. Once the threshold is reached, further perturbation is performed.
[0054] Backtracking time is the time range within which the number of times a hash key appears is counted.
[0055] A service unit is a service that provides business services to a large number of people.
[0056] Hash mapping is the process of converting a pre-mapped hash into a hash value.
[0057] A hash space / ring is a collection of data consisting of consecutive hash keys.
[0058] Consistent hashing is an algorithm that groups hash values within a hash ring and forms a unique correspondence between the group and the hash key.
[0059] In related technologies, there may be a problem of uneven load distribution caused by a short-term high concentration of user requests. This is because the resources requested by users have the characteristic of concentrated distribution. Load balancing allocates service units according to the resources requested by users. As a result, the service units corresponding to the concentrated content will be unable to meet the capacity due to the large number of requests, leading to a decline in the overall service quality.
[0060] To address the issue of uneven load distribution, relevant technologies often involve predicting business needs in advance and analyzing data later to identify content with concentrated access. Load balancing strategies are then adjusted based on content paths or characteristics to optimize the load on individual content. These methods can be summarized into two implementations:
[0061] 1. Preliminary business forecasting: Based on the acceptance of content and the expected development of business models, we can predict that a certain piece of content or a batch of resources will experience concentrated access issues before the aforementioned problems occur. We can then adjust the load balancing strategy for such content in advance, and ensure that the content is evenly distributed by controlling weights, hash variables, etc.
[0062] 2. Post-processing data analysis: By analyzing user access records in the already-served system, identify content that is concentrated in a short period of time. Based on the concentration of content access, adjust the load balancing strategy and change the load balancing parameters of the concentrated content to ultimately achieve a balanced distribution of the same requests.
[0063] However, both solutions have certain shortcomings in practical use. The prediction-based approach, relying on existing data, is often inaccurate, leading to insufficient accuracy in load balancing adjustments. Unforeseen business or content may experience random, concentrated access; incorrect content may be predicted, resulting in uneven load distribution; or concentrated access may be predicted but not actually occur, wasting resources. The post-event analysis approach lacks timeliness for sudden, concentrated access events. Many concentrated access events are short-lived, and problems are often only discovered through data analysis after the access has ended, at which point it's too late to modify any strategies. Therefore, post-event analysis is suitable for prolonged periods of concentrated access, and even after the concentrated phenomenon disappears, it cannot be automatically restored; manual configuration restoration is required to maintain the exclusive characteristics of consistent hash content.
[0064] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the specific technical solutions of the invention will be further described in detail below with reference to the accompanying drawings of the embodiments of the present invention. The following embodiments are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0065] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0066] Figure 1 This is a flowchart illustrating a method for balanced distribution of network request resources provided in an embodiment of the present invention. Figure 1As shown, the method includes:
[0067] S101: Receive first information of at least one terminal requesting resources, and determine first data corresponding to the resource request of each of the at least one terminal based on the first information; the first data includes at least the hash value corresponding to the resource request of each terminal and the time when the hash value was generated.
[0068] In this embodiment, the terminal requesting resource can be determined according to the actual situation and is not limited here. As an example, the terminal requesting resource can be a resource requested by the user terminal, such as a Uniform Resource Locator (URL). The first information can be the request information of the terminal requesting the resource, and is not limited here. As an example, the first information can be address information. The at least one terminal requesting resource can be one terminal requesting resource or multiple terminal requesting resources, and is not limited here.
[0069] It should be noted that, based on the first information, the first data corresponding to the resource request of each terminal in the at least one terminal can be obtained by using the first information through a hash algorithm to obtain the first data corresponding to the resource request of each terminal in the at least one terminal; as an example, it can be that a preset hash function is used to pre-map the first information to obtain the hash value corresponding to the resource request of each terminal and the time when the hash value was generated.
[0070] The hash value corresponding to each terminal's resource request can be understood as a hash, which is to transform an input of arbitrary length in each terminal's resource request into an output of fixed length through a hash algorithm. This output value is the hash value.
[0071] It should be noted that the scheduler's user processing module receives user requests, calculates the hash value corresponding to the user request through the hash calculation module, and stores the hash value in the counting analysis module, which records the hash value and the time when the hash value was generated.
[0072] S102: Determine the number of times the same first hash value exists within a preset time period based on the first data.
[0073] In this embodiment, the preset time can be determined according to the actual situation and is not limited here. As an example, the preset time can be a backtracking time, set to 500 milliseconds. It should be noted that if there are identical hash values among the hash values, then it is the first hash value.
[0074] For ease of understanding, it should be noted that, based on the hash value of each terminal requesting resources in the first data and the time when the hash value was generated, the hash value within a preset time period is first determined, and then it is determined whether there are identical hash values, and the number of times identical hash values are obtained is counted.
[0075] It should be noted that the counting analysis module counts the number of times the same hash value is used.
[0076] S103: If the number of times is greater than or equal to a preset threshold, determine the perturbation factor corresponding to the first hash value based on the number of times and the preset threshold.
[0077] In this embodiment, the preset threshold can be a perturbation threshold; the value of the preset threshold can be determined according to the actual situation and is not limited here. As an example, the preset threshold can be 1000 times. The perturbation factor can be a hash perturbation factor.
[0078] The step of determining the perturbation factor corresponding to the first hash value based on the number of times and the preset threshold is to determine the perturbation factor corresponding to the first hash value based on the relationship between the number of times and the preset threshold. As an example, it can be based on a second relationship between the number of times and the preset threshold, and the perturbation factor corresponding to the first hash value is determined based on the second relationship.
[0079] It should be noted that if the number of times is less than a preset threshold, the first hash value will not be modified.
[0080] S104: Adjust the multiple first hash values according to the perturbation factor to obtain the second hash value corresponding to each first hash value at a different position in the preset hash ring.
[0081] In this embodiment, adjusting the multiple first hash values according to the perturbation factor can be performed by recalculating the multiple first hash values according to the perturbation factor to obtain the second hash value. As an example, it can be done by determining the random parameters corresponding to the perturbation parameters included in the perturbation factor, and adjusting the multiple first hash values based on the random parameters. The preset hash ring is a virtual ring that maps the entire hash value space, and the value range of the entire hash value space is 0 to 2. 32 -1, the entire space is organized clockwise. It should be noted that the second hash value is obtained by adjusting the first hash value, and there can be multiple values.
[0082] S105: Distribute the information of the requested resource corresponding to the second hash value to the edge servers corresponding to the different locations.
[0083] In this embodiment, for ease of understanding, an example is given here, in which the second hash value is located on a preset hash ring and then mapped one-to-one with the edge server.
[0084] The method for balanced distribution of network request resources provided in this embodiment of the invention determines a perturbation factor corresponding to the first hash value based on the number of requests and the preset threshold when the number of requests is greater than or equal to a preset threshold; adjusts multiple first hash values according to the perturbation factor to obtain a second hash value corresponding to each first hash value at a different position in a preset hash ring; and distributes the information of the request resources corresponding to the second hash value to the edge servers corresponding to the different positions, thereby evenly distributing highly concentrated request content that occurs in a short period of time to different edge servers and achieving load distribution balance.
[0085] In an optional embodiment of the present invention, determining the first data corresponding to the resource request of each terminal in the at least one terminal based on the first information includes: performing pre-mapping processing on the first information using a preset hash function to obtain the hash value corresponding to the resource request of each terminal and the time when the hash value was generated; and using the hash value corresponding to the resource request of each terminal and the time when the hash value was generated as the first data.
[0086] In this embodiment, the preset hash function can be selected according to the actual situation, and is not limited here. As an example, the preset hash function can be a message-digest algorithm (MD5) function.
[0087] For ease of understanding, an example is provided here: the hash pre-mapping is extracted from the user request and input into the hash calculation module. The hash calculation module calculates a unique hash value from the input value using a hash algorithm and stores the hash value in the counting analysis module. The counting analysis module records the hash value and the time when the hash value was generated.
[0088] In an optional embodiment of the present invention, the method further includes:
[0089] Obtain a first identifier corresponding to each edge server in at least one edge server, and generate a third hash value based on the first identifier;
[0090] Determine the first position of the third hash value in the preset hash ring and the second position of the fourth hash value corresponding to the preset requested resource in the preset hash ring;
[0091] Associating the first position and the second position yields a first relationship between the third hash value and the fourth hash value; the first relationship is used to determine the edge server corresponding to the hash value of each terminal requesting resources.
[0092] In this embodiment, the first identifier represents the identification information of each edge server, which is not limited here. As an example, the first identifier can be the hostname of the edge server. The third hash value is the hash value corresponding to each edge server. It should be noted that the hash value of each edge server and the hash value of each terminal requesting resources are calculated using the same hash function.
[0093] Associating the first position and the second position to obtain the first relationship between the third hash value and the fourth hash value can be achieved by locating the third hash value and the fourth hash value on the hash ring and then associating them one by one (consistent hashing).
[0094] To facilitate understanding, the process of association will be explained here. Figure 2 This is a schematic diagram of a consistent hashing method provided in an embodiment of the present invention. Consistent hashing technology is prevalent in the current information service field, especially in distributed systems including distributed computing, distributed storage, and blockchain. Figure 2 As shown, firstly, the requested resource flag is pre-mapped to a fixed-length hash value using a hash function, and then located on the hash ring. Secondly, the service unit flag is processed using the same hash function to obtain the hash value of the service unit (i.e., the unit to be allocated), which is also located on the hash ring (e.g., ...). Figure 2 The hash keys of nodes 1, 2, 3, 4, and 5 are used to uniquely associate the two resources by comparing their hash values with the hash values of the pre-calculated units to be allocated.
[0095] In an optional embodiment of the present invention, the method further includes:
[0096] The hash value corresponding to the resource requested by each terminal is matched with the fourth hash value to obtain the fourth hash value that matches the hash value corresponding to the resource requested by each terminal.
[0097] Based on the first relationship and the matched fourth hash value, the edge server corresponding to the hash value of each terminal requesting resources is determined.
[0098] In this embodiment, for ease of understanding, an example is given here: the hash value of each terminal requesting resources is matched with the fourth hash value to obtain the position on the hash ring, and then the edge server corresponding to each terminal requesting resources is obtained according to the first relationship.
[0099] It should be noted that after each terminal requests a resource and it corresponds to an edge server, the result needs to be returned to the terminal.
[0100] For ease of understanding, an example is provided here. The hash calculation module locates the calculated hash value and the pre-calculated service unit hash value on the hash ring and associates them one by one through consistent hashing. The hash calculation module outputs the service unit corresponding to the requested resource and passes it to the user processing module, which returns the service unit assigned by the user.
[0101] In an optional embodiment of the present invention, the method further includes:
[0102] A fifth hash value outside the preset time is determined based on the time when the hash value was generated;
[0103] The fifth hash value is deleted from the middle of the first data.
[0104] In this embodiment, the fifth hash value is the hash value outside the preset time. For ease of understanding, this example illustrates that data outside the preset time (e.g., 500 milliseconds) is deleted.
[0105] The technical solution of this invention avoids the data analysis process of other solutions by dynamically analyzing the hash results within a short period, typically 100ms-500ms. Therefore, it is more sensitive and real-time than other solutions, and can generally react within 200ms-1000ms.
[0106] In an optional embodiment of the present invention, determining the perturbation factor corresponding to the first hash value based on the number of occurrences and the preset threshold includes:
[0107] Determine a second relationship between the number of times and the preset threshold;
[0108] The perturbation factor corresponding to the first hash value is determined based on the second relationship.
[0109] In this embodiment, the second relationship can be any relationship between the number of times and the preset threshold, and is not limited here. As an example, the second relationship can be a multiple relationship. Determining the perturbation factor corresponding to the first hash value based on the number of times and the preset threshold can be done by determining the perturbation factor corresponding to the first hash value based on the multiple relationship between the number of times and the preset threshold.
[0110] For ease of understanding, here is an example: if the preset threshold is 1000 times and the number of repetitions of the same hash value is 10000 times, then the value of the perturbation factor is 10.
[0111] It should be noted that the process of whether to enable hash perturbation in this embodiment of the invention is dynamically determined. Once a resource cluster occurs and hash perturbation begins, the problem of the resource cluster disappears, and hash perturbation can be immediately turned off based on the new resource access status.
[0112] In an optional embodiment of the present invention, the perturbation factor includes at least a perturbation parameter; the step of adjusting the plurality of first hash values according to the perturbation factor to obtain a second hash value corresponding to each first hash value at a different position in a preset hash ring includes:
[0113] Determine the random parameters corresponding to the disturbance parameters;
[0114] Based on the random parameters, multiple first hash values are adjusted to obtain second hash values corresponding to different positions of each first hash value in a preset hash ring.
[0115] In this embodiment, the perturbation parameter can be a perturbation value; the random parameter can be a random number. Adjusting multiple first hash values based on the random parameter can be performed by conducting a secondary hash operation on the first hash values based on the random parameter. The secondary hash operation is performed using the hash value plus a random number.
[0116] To make it easier to understand, here is an explanation: the range of random numbers is equal to the hash perturbation factor. For example, if the hash perturbation factor is 10, then the random number will take a value between 1 and 10. In this case, performing a second hash operation on the hash value and the random number will result in 10 new hash values. That is, the number of new hash values output through the operation is equal to the hash perturbation factor.
[0117] For ease of understanding, Figure 3 This is a schematic diagram of an adjusted load balancing dynamic hashing process provided by an embodiment of the present invention. Through the hash calculation process, the hash value of the requested resource is generated, the hash value is counted, and the number of times the same hash value appears within a unit of time is counted. When the hash value reaches a predetermined threshold within a unit of time, the calculated hash value is distributed according to a predetermined fixed result to ensure that the high-request content appearing within a unit of time can be distributed in multiple locations in the hash space. Then, after the consistent hashing algorithm mapping, it is ensured that the content will be evenly distributed to different service units.
[0118] To better understand the process of hash perturbation Figure 4This is a flowchart illustrating the conditional judgment of hash perturbation according to an embodiment of the present invention. In the hash statistics stage, the hash value of the hash operation result needs to be saved each time a hash operation is performed. During algorithm operation, the number of occurrences of the same result within a certain time range needs to be periodically counted in the hash values. If the number of occurrences of a certain hash value or a batch of hash values exceeds a preset threshold, a subsequent hash perturbation operation is triggered. The MD5 value output after triggering is the hash value obtained through the MD5 function.
[0119] In this embodiment of the invention, the calculation process of dynamic hashing requires multiple external parameters to control its overall action details, including the main switch, backtracking time, and threshold. At the same time, multiple intermediate parameters affect the output result in the complete process. Figure 5 This is a schematic diagram of a request resource distribution process including parameters, provided as an embodiment of the present invention. Figure 5 As shown, after the requested data is input, the main switch is first run to determine whether the statistical analysis process of the raw hash result is enabled. If it is not enabled (i.e., the main switch is off), the raw hash result is directly output; if it is enabled (i.e., the main switch is on), the raw hash result is statistically analyzed, and the hash value, generation time, and occurrence frequency are stored (i.e., ...). Figure 5 The hash key is stored in the memory. During the backtracking time (i.e., the backtracking period), the hash value is perturbed. That is, it is judged based on whether the number of times the same hash value appears during the backtracking time exceeds the perturbation threshold. If it does not exceed the threshold, the original hash result is directly output; if it exceeds the threshold, the hash scrambling process is performed, and finally the scrambled hash result is output.
[0120] It should be noted that the embodiments of the present invention perform actions after sensing the state, which belongs to a feedback system. Furthermore, the conditions for function activation can be controlled by thresholds, making it more accurate than predictive solutions.
[0121] To better understand this invention, a method for balanced distribution of network request resources is illustrated here. Specifically, it is a consistent hashing method that dynamically balances resource request characteristics. The specific implementation process is as follows:
[0122] Step 1: The scheduler's user processing module receives the user request, extracts the hash pre-mapping from the user request, and inputs it into the hash calculation module;
[0123] Step 2: The hash calculation module calculates a unique hash value from the input value using a hash algorithm and stores the hash value in the counting analysis module. The counting analysis module records at least three types of data: hash value, statistical time, and occurrence count.
[0124] Step 3: The hash calculation module locates the calculated hash value and the pre-calculated service unit hash value on the hash ring, and associates them one by one through consistent hashing;
[0125] Step 4: The hash calculation module outputs the service unit corresponding to the requested resource and passes it to the user processing module, which then returns the service unit assigned by the user.
[0126] Step 5: Eliminate and summarize the data in the counting analysis module according to the time interval. That is, eliminate expired hash value data, delete data outside the backtracking time (default is 500 milliseconds), and count the active hash value data. The statistical results include hash value and hash value repetition count. Once the repetition count reaches the perturbation threshold, the hash perturbation action is triggered.
[0127] Step 6: Determine the hash perturbation factor based on the multiple relationship between the frequency of hash value occurrences and the perturbation threshold;
[0128] Step 7: Modify the hash value according to the hash perturbation factor. The modification method of this invention is to perform a second hash operation using the hash value and a random number, where the range of the random number is equal to the hash perturbation factor. At this time, the number of new hash values output is equal to the hash perturbation factor.
[0129] Step 8: Input the perturbed hash value into steps 3 and 4;
[0130] Step 9: If the number of times the hash value is repeated in step 5 is less than the threshold, do not make any changes to the hash result.
[0131] To implement the method of the embodiments of the present invention, the embodiments of the present invention provide a network request resource balanced distribution device. Figure 6 This is a schematic diagram of the composition structure of the network request resource balanced distribution device provided in an embodiment of the present invention, as shown below. Figure 6 As shown, the device 600 includes: a receiving unit 601, a determining unit 602, an adjusting unit 603, and a distributing unit 604, wherein,
[0132] The receiving unit 601 is configured to receive first information of at least one terminal requesting resources, and determine first data corresponding to the resource request of each of the at least one terminal based on the first information; the first data includes at least the hash value corresponding to the resource request of each terminal and the time when the hash value was generated.
[0133] The determining unit 602 is configured to determine, based on the first data, the number of times that the same first hash value exists within a preset time; and, if the number of times is greater than or equal to a preset threshold, to determine the perturbation factor corresponding to the first hash value based on the number of times and the preset threshold.
[0134] The adjustment unit 603 is used to adjust multiple first hash values according to the disturbance factor to obtain a second hash value corresponding to each first hash value at a different position in a preset hash ring;
[0135] The distribution unit 604 is used to distribute the information of the requested resource corresponding to the second hash value to the edge servers corresponding to the different locations.
[0136] In some embodiments, the apparatus 600 further includes a pre-mapping processing unit, configured to pre-map the first information using a preset hash function to obtain a hash value corresponding to each terminal requesting resources and the time when the hash value was generated; and to use the hash value corresponding to each terminal requesting resources and the time when the hash value was generated as the first data.
[0137] In some embodiments, the apparatus 600 further includes an acquisition unit, configured to acquire a first identifier corresponding to each edge server in at least one edge server, generate a third hash value based on the first identifier; determine a first position of the third hash value in a preset hash ring and a second position of a fourth hash value corresponding to a preset requested resource in the preset hash ring; associate the first position and the second position to obtain a first relationship between the third hash value and the fourth hash value; the first relationship is used to determine the edge server corresponding to the hash value corresponding to each terminal requested resource.
[0138] In some embodiments, the apparatus 600 further includes a matching unit, configured to match the hash value corresponding to each terminal requesting resource with the fourth hash value to obtain a fourth hash value that matches the hash value corresponding to each terminal requesting resource; and to determine the edge server corresponding to the hash value corresponding to each terminal requesting resource based on the first relationship and the matched fourth hash value.
[0139] In some embodiments, the apparatus 600 further includes a deletion unit for determining a fifth hash value outside the preset time based on the time the hash value was generated; and deleting the fifth hash value in the middle of the first data.
[0140] In some embodiments, the determining unit 602 is further configured to determine a second relationship between the number of times and the preset threshold; and to determine a perturbation factor corresponding to the first hash value based on the second relationship.
[0141] In some embodiments, the adjustment unit 603 is further configured to determine a random parameter corresponding to the disturbance parameter; and adjust multiple first hash values based on the random parameter to obtain a second hash value corresponding to each first hash value at a different position in a preset hash ring.
[0142] It should be noted that the network request resource equalization distribution device provided in the embodiments of the present invention and the network request resource equalization distribution method provided in the aforementioned embodiments of the present invention belong to the same inventive concept. The meanings of the terms appearing here have been explained in detail above and will not be repeated here.
[0143] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of the present invention, the embodiments of the present invention also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the program to implement the steps of the above method embodiments.
[0144] Correspondingly, this application provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0145] It should be noted that the descriptions of the storage medium and device embodiments above are similar to the descriptions of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0146] It should be noted that, Figure 7 This is a schematic diagram of a hardware entity structure of an electronic device provided in an embodiment of the present invention, such as... Figure 7 As shown, the hardware entity of the electronic device 700 includes a processor 701 and a memory 703. Optionally, the electronic device 700 may also include a communication interface 702.
[0147] It is understood that memory 703 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), Sync Link Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 703 described in this embodiment of the invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0148] The methods disclosed in the above embodiments of the present invention can be applied to, or implemented by, processor 701. Processor 701 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above methods can be completed by integrated logic circuits in the hardware of processor 701 or by instructions in software form. Processor 701 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 701 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of the present invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor.
[0149] The component module can be located in a storage medium, which is located in memory 703. The processor 701 reads the information in memory 703 and, in conjunction with its hardware, completes the steps of the aforementioned method.
[0150] In an exemplary embodiment, the device may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned method.
[0151] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative; for example, [the following is a possible interpretation].
[0152] The division of units described above is merely a logical functional division. In actual implementation, there may be other division methods, such as: multiple units or components may be combined, integrated into another system, or some features may be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed may be through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0153] The units described above as separate components may or may not be physically separate. The component shown as unit 0 may or may not be a physical unit; that is, it may be located in one place, or...
[0154] The network can be distributed across multiple network units; some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0155] Furthermore, in the various embodiments of the present invention, all functional units can be integrated into a single processing unit.
[0156] Alternatively, each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0157] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for balanced distribution of network request resources, characterized in that, The method includes: The system receives first information requesting resources from at least one terminal, and determines first data corresponding to the resource request for each of the at least one terminal based on the first information; the first data includes at least a hash value corresponding to the resource request for each terminal and the time when the hash value was generated. Based on the first data, determine the number of times the same first hash value exists within a preset time period; If the number of occurrences is greater than or equal to a preset threshold, the perturbation factor corresponding to the first hash value is determined based on the number of occurrences and the preset threshold. The multiple first hash values are adjusted according to the perturbation factor to obtain the second hash value corresponding to each first hash value at a different position in the preset hash ring; The information of the requested resource corresponding to the second hash value is distributed to the edge servers corresponding to the different locations.
2. The method according to claim 1, characterized in that, The step of determining the first data corresponding to the resource request of each of the at least one terminals based on the first information includes: The first information is pre-mapped using a preset hash function to obtain the hash value corresponding to each terminal's requested resource and the time when the hash value was generated. The hash value corresponding to each terminal requesting resources and the time when the hash value was generated are used as the first data.
3. The method according to claim 2, characterized in that, The method further includes: Obtain a first identifier corresponding to each edge server in at least one edge server, and generate a third hash value based on the first identifier; Determine the first position of the third hash value in the preset hash ring and the second position of the fourth hash value corresponding to the preset requested resource in the preset hash ring; Associating the first position and the second position yields a first relationship between the third hash value and the fourth hash value; the first relationship is used to determine the edge server corresponding to the hash value of each terminal requesting resources.
4. The method according to claim 3, characterized in that, The method further includes: The hash value corresponding to the resource requested by each terminal is matched with the fourth hash value to obtain the fourth hash value that matches the hash value corresponding to the resource requested by each terminal. Based on the first relationship and the matched fourth hash value, the edge server corresponding to the hash value of each terminal requesting resources is determined.
5. The method according to claim 1, characterized in that, The method further includes: A fifth hash value outside the preset time is determined based on the time when the hash value was generated; The fifth hash value is deleted from the middle of the first data.
6. The method according to claim 1, characterized in that, The step of determining the perturbation factor corresponding to the first hash value based on the number of occurrences and the preset threshold includes: Determine a second relationship between the number of times and the preset threshold; The perturbation factor corresponding to the first hash value is determined based on the second relationship.
7. The method according to claim 1, characterized in that, The perturbation factor includes at least a perturbation parameter; the step of adjusting multiple first hash values according to the perturbation factor to obtain a second hash value corresponding to each first hash value at a different position in a preset hash ring includes: Determine the random parameters corresponding to the disturbance parameters; Based on the random parameters, multiple first hash values are adjusted to obtain second hash values corresponding to different positions of each first hash value in a preset hash ring.
8. A device for balanced distribution of network request resources, characterized in that, The device includes: a receiving unit, a determining unit, an adjusting unit, and a distributing unit, wherein, The receiving unit is configured to receive first information of at least one terminal requesting resources, and determine first data corresponding to the resource request of each of the at least one terminal based on the first information; the first data includes at least the hash value corresponding to the resource request of each terminal and the time when the hash value was generated. The determining unit is configured to determine, based on the first data, the number of times the same first hash value exists within a preset time; and, if the number of times is greater than or equal to a preset threshold, to determine the perturbation factor corresponding to the first hash value based on the number of times and the preset threshold. The adjustment unit is used to adjust multiple first hash values according to the disturbance factor to obtain a second hash value corresponding to each first hash value at a different position in a preset hash ring; The distribution unit is used to distribute the information of the requested resource corresponding to the second hash value to the edge servers corresponding to the different locations.
9. An electronic device, characterized in that, include: Memory, used to store executable instructions; A processor, when executing executable instructions stored in the memory, implements the method for balanced distribution of network request resources as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, It stores executable instructions for use by a processor to implement the method for balanced distribution of network request resources as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Load balancing method and device
CN109981476A
Method for managing server load distribution by using hash function results, and apparatus for same
WO2013094837A1