Server allocation method and apparatus, storage medium, and electronic device
Patent Information
- Application Number
- CN202210320817.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-29
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2042-03-29
AI Technical Summary
[0005]本发明实施例提供了一种服务器的分配方法和装置、存储介质及电子设备,以至少解决现有技术中服务器间的负载不均衡的技术问题
[0019]根据本发明实施例的又一方面,还提供了一种电子设备,包括存储器和处理器,上述存储器中存储有计算机程序,上述处理器被设置为通过所述计算机程序执行上述的服务器的分配方法。
Smart Images

Figure CN116932176B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computers, and more specifically, to a server allocation method and apparatus, storage medium, and electronic device. Background Technology
[0002] In related technologies, load balancing distributes the load (e.g., tasks, requests) evenly across multiple operating units (e.g., servers, components) for processing, in order to optimize resource utilization, maximize throughput, minimize response time, and avoid overload.
[0003] Currently, load balancing typically uses a round-robin method. Taking request distribution to servers as an example, the round-robin method distributes requests to servers sequentially. The round-robin algorithm assumes that all servers have the same processing capacity, without considering actual server performance, current load, or response speed. However, when the request service interval varies significantly, the round-robin algorithm can easily lead to load imbalances among servers.
[0004] There is currently no effective solution to the above problems. Summary of the Invention
[0005] This invention provides a server allocation method and apparatus, storage medium and electronic device to at least solve the technical problem of unbalanced load among servers in the prior art.
[0006] According to one aspect of the present invention, a server allocation method is provided, comprising: obtaining an i-th request and generating an i-th random number for the i-th request within a target value range, wherein i is a positive integer greater than or equal to 2, the target value range is divided into an i-th group of value intervals, the number of value intervals in the i-th group of value intervals is N, each value interval in the i-th group of value intervals corresponds to one of N servers, and N is a positive integer greater than or equal to 2; determining the value interval in the i-th group of value intervals where the i-th random number is located, wherein each value interval in the i-th group of value intervals is obtained by adjusting the interval size of each value interval in the (i-1)-th group of value intervals according to the allocation result of the (i-1)-th server, the (i-1)-th group of value intervals including The target value range is divided into N value intervals. The correspondence between the (i-1)th value interval and the N servers is the same as the correspondence between the i-th value interval and the N servers. The (i-1)th server allocation result represents the (i-1)th server among the N servers used to process the (i-1)th request. When adjusting the interval size of each value interval in the (i-1)th value interval, the interval size corresponding to the (i-1)th used server is reduced. The i-th request is sent to the i-th used server among the N servers, wherein the i-th used server corresponds to the value interval in which the i-th random number is located in the (i-1)th value interval, and the i-th used server is used to process the i-th request.
[0007] Optionally, before generating the i-th random number for the i-th request within the target value range, the method further includes: obtaining the (i-1)-th request and generating the (i-1)-th random number for the (i-1)-th request within the target value range; determining the value range in which the (i-1)-th random number is located within the (i-1)-th group of value ranges; sending the (i-1)-th request to the (i-1)-th server among the N servers, wherein the (i-1)-th ...
[0008] Optionally, the step of adjusting the size of each value interval in the (i-1)th group of value intervals according to the allocation result of the (i-1)th server to obtain the i-th group of value intervals includes: reducing the size of the value interval in the (i-1)th group of value intervals corresponding to the server used in the (i-1)th time; and increasing the size of some or all of the value intervals in the (i-1)th group of value intervals except for the value interval corresponding to the server used in the (i-1)th time.
[0009] Optionally, increasing the size of some or all of the value intervals in the (i-1)th group of value intervals, excluding the value interval corresponding to the server used in the (i-1)th time, includes: when the value interval corresponding to the server used in the (i-1)th time is the target value interval for the (i-1)th time, and the size of the target value interval for the (i-1)th time has been reduced by a first value, increasing the size of each value interval in the (i-1)th group of value intervals, excluding the target value interval for the (i-1)th time, by a second value, wherein the second value = the first value / (N-1); or when the value interval corresponding to the server used in the (i-1)th time is the target value interval for the (i-1)th time, and the size of the target value interval for the (i-1)th time has been reduced by a first value, increasing the size of M value intervals in the (i-1)th group of value intervals, excluding the target value interval for the (i-1)th time, by a third value, wherein M is less than N-1, and the third value = the first value / M.
[0010] Optionally, reducing the size of the value interval corresponding to the server used in the (i-1)th group of value intervals includes: if the server used in the (i-1)th time has processed P consecutive requests before the (i-1)th request, reducing the size of the value interval corresponding to the server used in the (i-1)th time by a first value, where P is a positive integer greater than or equal to 2, and the first value is greater than a default second value; when processing the P consecutive requests, the size of the value interval corresponding to the server used in the (i-1)th time is reduced by the second value; or if the server used in the (i-1)th time has processed Q requests in the P consecutive requests before the (i-1)th request, reducing the size of the value interval corresponding to the server used in the (i-1)th time by the first value, where Q is less than P, Q is a positive integer greater than or equal to 2, and the first value is greater than the default second value; when processing the Q requests, the size of the value interval corresponding to the server used in the (i-1)th time is reduced by the second value.
[0011] Optionally, determining the value interval where the i-th random number is located within the i-th group of value intervals includes: when N is odd and the i-th random number represents the i-th angle, determining the target sector region where the i-th angle is located within the i-th group of sector regions of the target circular region, and determining the angle interval corresponding to the target sector region as the value interval where the i-th random number is located, wherein each sector region in the i-th group of sector regions corresponds to a value interval in the i-th group of values, and the larger the value interval, the larger the angle interval of the corresponding sector region, and each sector region in the i-th group of sector regions is... Based on the allocation result of the (i-1)th server, the fan-shaped regions are obtained by adjusting the angle range of each fan-shaped region in the (i-1)th group of fan-shaped regions of the target circular region. Both the (i-1)th group of fan-shaped regions and the i-th group of fan-shaped regions include N fan-shaped regions into which the target circular region is divided. The correspondence between the (i-1)th group of fan-shaped regions and the N servers is the same as the correspondence between the i-th group of fan-shaped regions and the N servers. When adjusting the angle range of each fan-shaped region in the (i-1)th group of fan-shaped regions, the angle range of the fan-shaped region corresponding to the server used in the (i-1)th time is reduced.
[0012] Optionally, determining the value interval where the i-th random number is located within the i-th group of value intervals further includes: when N is even and the i-th random number represents the value of the i-th line segment, determining the target line segment where the value of the i-th line segment is located within the i-th group of line segments in the target value range, and determining the value interval corresponding to the target line segment as the value interval where the i-th random number is located, wherein each line segment in the i-th group of line segments corresponds to a value interval in the i-th group of values, and the larger the value interval, the longer the corresponding line segment. Each line segment in the line segment is obtained by adjusting the length of each line segment in the (i-1)th group of line segments according to the allocation result of the (i-1)th server. Both the (i-1)th group of line segments and the i-th group of line segments include N line segments into which the target value range is divided. The correspondence between the (i-1)th group of line segments and the N servers is the same as the correspondence between the i-th group of line segments and the N servers. When adjusting the length of each line segment in the (i-1)th group of line segments, the length of the line segment corresponding to the server used in the (i-1)th time is reduced.
[0013] Optionally, after sending the i-th request to the server used for the ith time among the N servers, the method further includes: if the i-th request is for requesting target media resources, determining the value interval in which the i-th random number is located within the j-th group of value intervals, wherein the target value range is divided into the j-th group of value intervals, the number of value intervals in the j-th group of value intervals is S, each value interval in the j-th group of value intervals corresponds to one of the S selection modes, S is a positive integer greater than or equal to 2, j is a positive integer greater than or equal to 2, and each value interval in the j-th group of value intervals is obtained by adjusting the interval size of each value interval in the (i-1)-th group of value intervals according to the selection result of the (i-1)-th mode, wherein the j-th -1 value intervals include S value intervals into which the target value range is divided. The correspondence between the (j-1)th value interval and the S selection modes is the same as the correspondence between the j-th value interval and the S selection modes. The (i-1)th mode selection result represents the (i-1)th selection mode used to process the (i-1)th request among the S selection modes. When adjusting the interval size of each value interval in the (j-1)th value interval, the interval size of the value interval corresponding to the (i-1)th selection mode is reduced. The target media resource is selected from the target media resource set through the ith selection mode, wherein the ith selection mode corresponds to the value interval in which the ith random number is located in the j-th value interval.
[0014] Optionally, before sending the i-th request to the server used for the i-th time among the N servers, the method further includes: determining the value interval in which the i-th random number is located within the K-th set of value intervals, wherein the target value range is divided into the K-th set of value intervals, the number of value intervals in the K-th set of value intervals is T, each value interval in the K-th set of value intervals corresponds to one of the T server clusters, K is a positive integer greater than or equal to 2, T is a positive integer greater than or equal to 2, and each value interval in the K-th set of value intervals is determined according to the allocation result of the (i-1)-th cluster. The value intervals obtained by adjusting the interval size are as follows: the (K-1)th group of value intervals includes T value intervals into which the target value range is divided. The correspondence between the (K-1)th group of value intervals and the T server clusters is the same as the correspondence between the Kth group of value intervals and the T server clusters. The (i-1)th cluster allocation result represents the server cluster used for processing the (i-1)th request in the T server clusters. When adjusting the interval size of each value interval in the (K-1)th group of value intervals, the interval size of the value interval corresponding to the (i-1)th used server cluster is reduced.
[0015] Optionally, sending the i-th request to the i-th server among the N servers for the i-th time includes: allocating the i-th server for the i-th time in the server cluster for the i-th time, wherein the server cluster for the i-th time corresponds to the value range in the (K-1)-th group of value ranges of the i-th random number, and the server cluster for the i-th time includes the N servers.
[0016] According to another aspect of the present invention, a server allocation apparatus is also provided, comprising: an acquisition module, configured to acquire an i-th request and generate an i-th random number for the i-th request within a target value range, wherein i is a positive integer greater than or equal to 2, the target value range is divided into an i-th group of value intervals, the number of value intervals in the i-th group of value intervals is N, and each value interval in the i-th group of value intervals corresponds to one of N servers, where N is a positive integer greater than or equal to 2; and a determination module, configured to determine the value interval in the i-th group of value intervals where the i-th random number is located, wherein each value interval in the i-th group of value intervals is obtained by adjusting the interval size of each value interval in the (i-1)-th group of value intervals according to the allocation result of the (i-1)-th server, wherein the (i-1)-th group of value intervals... The interval includes N value intervals into which the target value range is divided. The correspondence between the (i-1)th group of value intervals and the N servers is the same as the correspondence between the i-th group of value intervals and the N servers. The allocation result of the (i-1)th server indicates the server used for the (i-1)th time to process the (i-1)th request among the N servers. When adjusting the size of each value interval in the (i-1)th group of value intervals, the size of the value interval corresponding to the server used for the (i-1)th time is reduced. The sending module is used to send the i-th request to the server used for the ith time among the N servers, wherein the server used for the ith time corresponds to the value interval in which the i-th random number is located in the (i-1)th group of value intervals, and the server used for the ith time is used to process the i-th request.
[0017] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, wherein the computer program is configured to execute the allocation method of the server described above when it is run.
[0018] According to another aspect of the embodiments of this application, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the allocation method of the server described above.
[0019] According to another aspect of the present invention, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to execute the server allocation method described above through the computer program.
[0020] In this embodiment of the invention, each value interval in the i-th group of value intervals corresponds to a server. When allocating a server for the i-th request, an i-th random number is first generated for the i-th request. Based on the value interval in which the i-th random number is located in the i-th group of value intervals, the server allocated to the i-th request is determined. Since each value interval in the i-th group of value intervals is obtained by adjusting the size of each value interval in the (i-1)-th group of value intervals according to the allocation result of the (i-1)-th server, the size of the value interval in the (i-1)-th group of value intervals corresponding to the server used in the (i-1)-th time is reduced during the adjustment. In this way, by dynamically adjusting the value intervals, the probability of each server being allocated each time is dynamic, thereby reducing the load imbalance between servers and solving the technical problem of load imbalance between servers in the prior art. Attached Figure Description
[0021] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0022] Figure 1 This is a schematic diagram of an application environment for an optional server allocation method according to an embodiment of the present invention;
[0023] Figure 2 This is a flowchart of an optional server allocation method according to an embodiment of the present invention;
[0024] Figure 3 This is a schematic diagram of an optional value range according to an embodiment of the present invention;
[0025] Figure 4 This is a schematic diagram illustrating an optional value range adjustment according to an embodiment of the present invention;
[0026] Figure 5 This is a schematic diagram of another optional value range adjustment according to an embodiment of the present invention;
[0027] Figure 6 This is a schematic diagram illustrating another optional value range adjustment according to an embodiment of the present invention;
[0028] Figure 7 This is a schematic diagram illustrating another optional value range adjustment according to an embodiment of the present invention;
[0029] Figure 8 This is a schematic diagram illustrating another optional value range adjustment according to an embodiment of the present invention;
[0030] Figure 9 This is a schematic diagram of an optional circular region according to an embodiment of the present invention;
[0031] Figure 10 This is a schematic diagram of another optional circular region according to an embodiment of the present invention;
[0032] Figure 11 This is an optional line segment diagram according to an embodiment of the present invention;
[0033] Figure 12 This is another optional line segment diagram according to an embodiment of the present invention;
[0034] Figure 13 This is a schematic diagram illustrating an optional mode selection according to an embodiment of the present invention;
[0035] Figure 14 This is a schematic diagram of an optional server cluster according to an embodiment of the present invention;
[0036] Figure 15 This is a schematic diagram of another optional server cluster according to an embodiment of the present invention;
[0037] Figure 16 This is a schematic diagram illustrating another optional value range adjustment according to an embodiment of the present invention;
[0038] Figure 17 This is a schematic diagram of the structure of an optional target image recognition device according to an embodiment of the present invention;
[0039] Figure 18 This is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present invention;
[0040] Figure 19 This is a computer system architecture block diagram of an optional electronic device according to an embodiment of the present invention. Detailed Implementation
[0041] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0042] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0043] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0044] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0045] Machine learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learn-by-doing.
[0046] According to one aspect of the present invention, a server allocation method is provided. Optionally, as an alternative implementation, the above-described server allocation method may be applied to, but is not limited to, [examples of other methods]. Figure 1 The application environment shown above includes terminal device 101, server 102, and database 103.
[0047] Optionally, in this embodiment, the terminal device 101 may be a terminal device configured with a target client, which may include, but is not limited to, at least one of the following: mobile phone (such as Android phone, iOS phone, etc.), laptop computer, tablet computer, PDA, MID (Mobile Internet Devices), PAD, desktop computer, intelligent voice interaction device, smart home appliance, vehicle terminal, aircraft, etc. The target client may be a video client, instant messaging client, browser client, game client, etc.
[0048] Optionally, the aforementioned networks may include, but are not limited to, wired networks and wireless networks, wherein the wired network includes local area networks (LANs), metropolitan area networks (MANs), and wide area networks (WANs), and the wireless network includes Bluetooth, Wi-Fi, and other networks that enable wireless communication.
[0049] Optionally, the server 102 mentioned above can be a single server, a server cluster consisting of multiple servers, or a cloud server.
[0050] Optionally, the database 103 is used to store data, including but not limited to the i-th value range and the (i-1)-th value range.
[0051] The above is merely an example, and no limitation is made in this embodiment.
[0052] Alternatively, as an optional implementation, such as Figure 2 As shown, the server allocation method described above includes:
[0053] Step S202: Obtain the i-th request and generate the i-th random number for the i-th request within the target value range, where i is a positive integer greater than or equal to 2. The target value range is divided into the i-th group of value intervals, and the number of value intervals in the i-th group of value intervals is N. Each value interval in the i-th group of value intervals corresponds to one of the N servers, where N is a positive integer greater than or equal to 2.
[0054] The target value range can be set according to actual conditions, such as 0 to 1000, 0° to 360°, etc., where the i-th random number is the value randomly generated by the i-th request. For example, if the target value range is 0 to 1000, a value can be randomly generated within the range of 0 to 1000 as the i-th random number. The target value range is divided into N value intervals, each corresponding to a server.
[0055] Taking a target value range of 0 to 1000 and N=2 as an example, such as Figure 3 The target value range of 0 to 1000 is divided into value interval 1 and value interval 2. Value interval 1 ranges from [0, 700], and value interval 2 ranges from (700, 1000). In this embodiment, the i-th value interval includes value interval 1 and value interval 2. Value interval 1 corresponds to server 1, and value interval 2 corresponds to server 2.
[0056] Step S204: Determine the value interval in which the i-th random number is located within the i-th group of value intervals. Each value interval in the i-th group of value intervals is obtained by adjusting the interval size of each value interval in the (i-1)-th group of value intervals based on the allocation result of the (i-1)-th server. The (i-1)-th group of value intervals includes N value intervals into which the target value range is divided. The correspondence between the (i-1)-th group of value intervals and the N servers is the same as the correspondence between the i-th group of value intervals and the N servers. The allocation result of the (i-1)-th server indicates the server among the N servers used to process the (i-1)-th request. When adjusting the interval size of each value interval in the (i-1)-th group of value intervals, the interval size of the value interval corresponding to the server used in the (i-1)-th request is reduced.
[0057] Among them, with Figure 3 Taking the i-th value range shown as an example, assuming the i-th random number is 500, 500 is within the value range [0, 700], which means the i-th random number is within value range 1. Therefore, the i-th request is sent to server 1 corresponding to value range 1, and server 1 processes the i-th request.
[0058] Step S206: The i-th request is sent to the server used for the i-th time among the N servers, wherein the server used for the i-th time corresponds to the value range in the (i-1)-th group of value ranges of the i-th random number, and the server used for the i-th time is used to process the i-th request.
[0059] Optionally, before generating the i-th random number for the i-th request within the target value range, the method further includes: obtaining the (i-1)-th request and generating the (i-1)-th random number for the (i-1)-th request within the target value range; determining the value range in which the (i-1)-th random number is located within the (i-1)-th group of value ranges; sending the (i-1)-th request to the (i-1)-th server among the N servers, wherein the (i-1)-th ...
[0060] As an optional implementation, after assigning a server to a request once, the target value range needs to be redefined. For example... Figure 4 As shown, the (i-1)th set of value intervals includes value intervals 3 and 4, and the ith set of value intervals includes value intervals 1 and 2. Value intervals 3 and 1 both correspond to server 1, and value intervals 4 and 2 both correspond to server 2. When assigning a server to the (i-1)th request, an (i-1)th random number is generated for the (i-1)th request. Assuming the (i-1)th random number is 900, which falls within value interval 4 of the (i-1)th set of value intervals, then server 2 is assigned to the (i-1)th request. Since server 2 has already been assigned to the (i-1)th request, the probability of server 2 being assigned will decrease when assigning a server to the next request (the ith request). Therefore, the value intervals in the (i-1)th set of value intervals are adjusted, and the size of value interval 4 is reduced to obtain value interval 2 in the ith set of value intervals. Since the target value range remains unchanged, the size of value interval 3 is increased to obtain value interval 1 in the i-th value interval. In this way, when allocating a server for the i-th request, the probability of server 1 being allocated increases and the probability of server 2 being allocated decreases, thus achieving load balancing among servers.
[0061] Optionally, the step of adjusting the size of each value interval in the (i-1)th group of value intervals according to the allocation result of the (i-1)th server to obtain the i-th group of value intervals includes: reducing the size of the value interval in the (i-1)th group of value intervals corresponding to the server used in the (i-1)th time; and increasing the size of some or all of the value intervals in the (i-1)th group of value intervals except for the value interval corresponding to the server used in the (i-1)th time.
[0062] As an optional implementation, Figure 4For example, the interval corresponding to the server used in the (i-1)th group of value intervals is value interval 4. Decreasing value interval 4 yields value interval 2 in the i-th group of value intervals. The value intervals in the (i-1)th group of value intervals other than value interval 4 are value intervals 3. Increasing the size of value interval 3 yields value interval 1 in the i-th group of value intervals.
[0063] As another optional implementation, Figure 5 For example, the (i-1)th group of value intervals includes value intervals a, b, c, and d, and the i-th group of value intervals includes value intervals a', b', c', and d'. Value intervals a and a' both correspond to server a, value intervals b and b' both correspond to server b, value intervals c and c' both correspond to server c, and value intervals d and d' both correspond to server d.
[0064] When assigning a server to the (i-1)th request, generate the (i-1)th random number for the (i-1)th request. Assuming the (i-1)th random number is 150 and falls within the value range 'a' of the (i-1)th group of value ranges, then assign server 'a' to the (i-1)th request.
[0065] Since server a has already been assigned to the (i-1)th request, the probability of server a being assigned to the next request (the i-th request) will decrease. Therefore, the values in the (i-1)th set of value intervals are adjusted, and the size of value interval a is reduced to obtain value interval a' in the i-th set of value intervals.
[0066] Increase the size of the intervals other than interval a in the (i-1)th group of values, such as... Figure 5 The diagram shows that the value interval b in the (i-1)th group of value intervals is increased to obtain the value interval b' in the i-th group of value intervals. The size of the other value intervals is not adjusted. Figure 5 The value interval c in the (i-1)th group of values is the same as the value interval c' in the i-th group, and the value interval d in the (i-1)th group of values is the same as the value interval d' in the i-th group.
[0067] Optionally, increasing the size of some or all of the value intervals in the (i-1)th group of value intervals, excluding the value interval corresponding to the server used in the (i-1)th time, includes: when the value interval corresponding to the server used in the (i-1)th time is the target value interval for the (i-1)th time, and the size of the target value interval for the (i-1)th time has been reduced by a first value, increasing the size of each value interval in the (i-1)th group of value intervals, excluding the target value interval for the (i-1)th time, by a second value, wherein the second value = the first value / (N-1).
[0068] As an optional implementation, Figure 6 For example, the (i-1)th group of value intervals includes value intervals e, f, g, and h, and the ith group of value intervals includes value intervals e', f', g', and h'. Value intervals e and e' both correspond to server e, value intervals f and f' both correspond to server f, value intervals g and g' both correspond to server g, and value intervals h and h' both correspond to server h.
[0069] When assigning a server to the (i-1)th request, an (i-1)th random number is generated for the (i-1)th request. Assuming that the (i-1)th random number is 150 and falls within the value range e of the (i-1)th group of value ranges, then server e is assigned to the (i-1)th request.
[0070] Since server e has already been assigned to the (i-1)th request, the probability of server e being assigned to the next request (the i-th request) will decrease. Therefore, the value intervals in the (i-1)th group of value intervals are adjusted, reducing the size of value interval e to obtain value interval e' in the i-th group of value intervals. The first value to be reduced can be determined according to the actual situation. In this embodiment, the value interval e is reduced from 0-200 to 0-50, which is a reduction of 150.
[0071] Since the (i-1)th group of value intervals includes 4 value intervals, N=4, then the second value = 150 / (4-1) = 50. Therefore, the size of each value interval in the (i-1)th group of value intervals, except for value interval e, is increased by 50. Figure 6The diagram shows that by increasing the value intervals f, g, and h in the (i-1)th group of value intervals by 50, we obtain the value intervals f', g', and h' in the i-th group of value intervals shown in the diagram. In this embodiment, since the (i-1)th request is assigned to the server (server e) used in the (i-1)th time, when allocating servers in the next instance (when allocating servers for the i-th request), the value interval corresponding to server e is reduced. This reduces the probability of server e being assigned to the i-th request again, thus reducing the probability of server e being repeatedly assigned. Furthermore, the value intervals corresponding to other services become larger, increasing the probability of other servers being assigned. This achieves a dynamic balance in the probability of server allocation, thereby achieving the effect of load balancing among servers.
[0072] Optionally, if the value interval corresponding to the server used in the (i-1)th time is the target value interval for the (i-1)th time, and the size of the target value interval for the (i-1)th time is reduced by a first value, the size of the M value intervals in the (i-1)th group of value intervals other than the target value interval for the (i-1)th time is increased by a third value, where M is less than N-1, and the third value = the first value / M.
[0073] As an optional implementation, Figure 7 For example, the (i-1)th group of value intervals includes value intervals x, y, z, and t, and the i-th group of value intervals includes value intervals x', y', z', and t'. Value intervals x and x' both correspond to server x, value intervals y and y' both correspond to server y, value intervals z and z' both correspond to server z, and value intervals t and t' both correspond to server t.
[0074] When assigning a server to the (i-1)th request, generate the (i-1)th random number for the (i-1)th request. Assuming the (i-1)th random number is 100 and falls within the value range x of the (i-1)th group of value ranges, then assign server x to the (i-1)th request.
[0075] Since server x has already been assigned to the (i-1)th request, the probability of server x being assigned to the next request (the i-th request) will decrease. Therefore, the value intervals in the (i-1)th group of value intervals are adjusted, reducing the size of value interval x to obtain value interval x' in the i-th group of value intervals. The first value to be reduced can be determined according to the actual situation. In this embodiment, the value interval e is reduced from 0-200 to 0-50, which is reduced by 150.
[0076] Since the (i-1)th group of value intervals includes 4 value intervals, N=4. Assuming M=2<N-1, the third value = 150 / 2 = 75, and the interval sizes of M value intervals in the (i-1)th group of value intervals other than value interval x are all increased by 75. In this embodiment, assuming that the value intervals to be enlarged are value interval y and value interval z in the (i-1)th group of value intervals, as Figure 7 shown in , both value interval y and value interval z in the (i-1)th group of value intervals are enlarged by 75, to obtain value interval y' and value interval z' in the ith group of value intervals as shown in the figure. In this embodiment, since the server used for the (i-1)th time (server x) is allocated to the (i-1)th request, when allocating a server next time (when allocating a server to the ith request), reducing the size of the value interval corresponding to server x can reduce the probability of reallocating server x to the ith request, that is, reduce the probability of repeated allocation of server x. In addition, the value intervals corresponding to some other servers are enlarged, so that the probability that the server corresponding to the enlarged part of the value interval is allocated is increased, which can achieve the dynamic balance of the server allocation probability, and further achieve the effect of load balancing among servers.
[0077] Optionally, the reducing the interval size of the value interval corresponding to the server used for the (i-1)th time in the (i-1)th group of value intervals includes: when the server used for the (i-1)th time has processed P consecutive requests before the (i-1)th request, reducing the interval size of the value interval corresponding to the server used for the (i-1)th time by a first value, wherein P is a positive integer greater than or equal to 2, the first value is greater than a default second value, and when processing the P consecutive requests, the interval size of the value interval corresponding to the server used for the (i-1)th time is reduced by the second value; or, when the server used for the (i-1)th time has processed Q requests among P consecutive requests before the (i-1)th request, reducing the interval size of the value interval corresponding to the server used for the (i-1)th time by the first value, wherein Q is less than P, Q is a positive integer greater than or equal to 2, the first value is greater than the default second value, and when processing the Q requests, the interval size of the value interval corresponding to the server used for the (i-1)th time is reduced by the second value.
[0078] As an alternative embodiment, if the same server is allocated consecutively, the adjustment value of the value interval corresponding to the server can be appropriately increased. The above P and Q can be set according to actual conditions, for example, they can be 2, 3, 4, 5, etc. Taking P=2 as an example, as Figure 8 shown, value interval x0, value interval x1, value interval x2 and value interval x3 all correspond to server x, and value interval y0, value interval y1, value interval y2 and value interval y3 all correspond to server y.
[0079] When assigning a server to the (i-3)th request, generate the (i-3)th random number for the (i-1)th request. Assuming the (i-3)th random number is 10 and falls within the value range x0 of the (i-3)th group of values, then assign server x to the (i-3)th request.
[0080] Since server x has already been assigned to the (i-3)th request, the probability of server x being assigned to the next request (the (i-2)th request) will decrease. Therefore, the value intervals in the (i-3)th group are adjusted, and the size of value interval x0 is reduced to obtain value interval x1 in the (i-2)th group. The default second value for reduction can be determined according to the actual situation. In this embodiment, the default second value is 100. Reducing the size of x0 by 100 yields the value interval x1 shown in the figure.
[0081] Similarly, when assigning a server to the (i-2)th request, an (i-2)th random number is generated for the (i-2)th request. Assuming that the (i-2)th random number is 80 and falls within the value range x1 of the (i-2)th group of value ranges, then a server x is assigned to the (i-2)th request.
[0082] Since server x has already been assigned to the (i-2)th request, the probability of server x being assigned to the next request (the (i-1)th request) will decrease. Therefore, we adjust the value intervals in the (i-2)th group of value intervals, reducing the size of value interval x1 to obtain value interval x2 in the (i-1)th group of value intervals. Similarly, the default second value is reduced to 100, and reducing the size of x1 by 100 yields value interval x2 as shown in the figure.
[0083] If, when assigning a server to the (i-1)th request, an (i-1)th random number is generated for the (i-1)th request, and assuming the (i-1)th random number is 60, which is located in the value interval x2 within the (i-1)th group of value intervals, then server x is assigned to the (i-1)th request.
[0084] Since server x has already been allocated twice consecutively (the (i-2)th and (i-3)th times), the probability of server x being allocated again for the next request (the i-th request) will decrease. Therefore, the value intervals in the (i-1)th group are adjusted, and the size of value interval x2 is reduced to obtain value interval x3 in the i-th group. The first value to be reduced must be greater than the second value mentioned above to prevent server x from being allocated again in the next request. In this embodiment, the first value is 200, and the size of x2 is reduced by 200 to obtain value interval x3 in the figure.
[0085] In the above implementation, if the same server is assigned multiple times consecutively, the value of the corresponding value range for that server is increased, causing the range length to continuously decrease and the probability of being assigned to a server to drop. Meanwhile, the range lengths of other value ranges are continuously increased, increasing the probability of being assigned to a server. This achieves a dynamic balance in the probability of server allocation, thereby achieving load balancing among servers.
[0086] Optionally, determining the value interval where the i-th random number is located within the i-th group of value intervals includes: when N is odd and the i-th random number represents the i-th angle, determining the target sector region where the i-th angle is located within the i-th group of sector regions of the target circular region, and determining the angle interval corresponding to the target sector region as the value interval where the i-th random number is located, wherein each sector region in the i-th group of sector regions corresponds to a value interval in the i-th group of values, and the larger the value interval, the larger the angle interval of the corresponding sector region, and each sector region in the i-th group of sector regions is... Based on the allocation result of the (i-1)th server, the fan-shaped regions are obtained by adjusting the angle range of each fan-shaped region in the (i-1)th group of fan-shaped regions of the target circular region. Both the (i-1)th group of fan-shaped regions and the i-th group of fan-shaped regions include N fan-shaped regions into which the target circular region is divided. The correspondence between the (i-1)th group of fan-shaped regions and the N servers is the same as the correspondence between the i-th group of fan-shaped regions and the N servers. When adjusting the angle range of each fan-shaped region in the (i-1)th group of fan-shaped regions, the angle range of the fan-shaped region corresponding to the server used in the (i-1)th time is reduced.
[0087] As an optional implementation, the circular area is divided into multiple sector areas, each sector area corresponding to a server. The angle of the sector area can be dynamically adjusted. The larger the angle, the greater the probability of a random number being hit, and the smaller the angle, the lower the probability of a random number being hit.
[0088] like Figure 9 The circular area shown is divided into three sector areas as an example. The target circular area serves as the global decision area. Using an initial threshold, the circle is divided into three sectors, and the angle of each sector is related to the actual business situation. Here, we illustrate this by assuming the three initial angles are equal. For example... Figure 9 The circle shown is divided into three regions, each 120 degrees, by thresholds 1 and 2: region A (0-120°), region B (120°-240°), and region C (240°-360°), each 120 degrees.
[0089] Random numbers can be generated using random algorithms. After receiving a request, a corresponding random number is generated for that request; this number can be a positive integer greater than or equal to 0° and less than 360°. A random algorithm is an algorithm that uses probability and statistical methods to randomly select the next computational step during its execution. For example, the XorShift algorithm can quickly generate unsigned 32-bit and 64-bit pseudo-random numbers. Random number generation libraries in Go can be used to generate random numbers using timestamps as keys.
[0090] After allocating a server for each request, the angles of the sector regions within the circular area need to be adjusted. If sector A is hit in the current request, the angle of sector A is reduced to decrease the probability of hitting that sector again in the next request, i.e., the angle of that sector is decreased. At the same time, the angles of other sector regions are increased to dynamically adjust the probability of each server being assigned, thereby achieving a dynamic load balance among the servers.
[0091] Assuming, such as Figure 9 The area is initially divided into sector regions A, B, and C, where the angle of region A equals the angle of region B equals the angle of region C equals 120°. Region A corresponds to an angle range of 0-120°, region B to 120°-240°, and region C to 240°-360°. The probability of hitting region A equals the probability of hitting region B equals the probability of hitting region C equals 1 / 3. Region A corresponds to server A, region B to server B, and region C to server C.
[0092] When assigning a server to the first request, a first random number is generated for the first request. Assume the random number is 10°, where 0 < 10° < 120°, and it hits region A. Then server A is assigned to handle the first request.
[0093] To assign server A to the first request, the sector regions need to be re-divided. When a decision hits a region, the probability of hitting that region again should be reduced; that is, the angle of that region should be decreased, while the angles of the other two regions should be increased. Specifically, the angle of region A should be decreased, while the angles of regions B and C should be increased, resulting in... Figure 9 The diagram shows regions A1, A2, and A3. Taking an adjustment angle of 30 degrees as an example, the hit probability of region A1 after adjustment is 90 / 360, and the hit probability of region B1 is equal to the hit probability of region C1, which is 135 / 360.
[0094] If the same server's sector area is hit multiple times consecutively, the angle of that sector area will continuously decrease, causing the probability of that server being hit to continuously decrease. Meanwhile, the angle of other sector areas will continuously increase, causing the probability of servers corresponding to those other sector areas to increase.
[0095] Taking servers E, F, and G as examples, the target circular area includes the (i-1)th group of sector regions (regions E, F, and G). When assigning a server for the (i-1)th request, a (i-1)th random number is generated randomly between 0° and 360°. If (0 < (i-1)th random number <= 90°), region E is hit; if (90° < (i-1)th random number <= 180°), region F is hit; and if (180° < (i-1)th random number <= 360°), region G is hit. Assuming the (i-1)th random number is 200°, region G is hit, then server G is assigned to the (i-1)th request, and server G processes the (i-1)th request.
[0096] After allocating server G for the (i-1)th request, the angles of each sector within the target circular region are adjusted. The angle of sector G is decreased, while the angles of other sectors are increased. In this implementation, the adjustment values for the sector angles can be set according to actual conditions, resulting in the following: Figure 10 As shown in the diagram, with E1, F1, and G1, when allocating servers for the next request (the i-th request), the probability of server G being assigned decreases, while the probability of servers E and F being assigned increases. This achieves dynamic adjustment of the probability of each server being assigned, thus realizing load balancing among servers.
[0097] Optionally, determining the value interval where the i-th random number is located within the i-th group of value intervals further includes: when N is even and the i-th random number represents the value of the i-th line segment, determining the target line segment where the value of the i-th line segment is located within the i-th group of line segments in the target value range, and determining the value interval corresponding to the target line segment as the value interval where the i-th random number is located, wherein each line segment in the i-th group of line segments corresponds to a value interval in the i-th group of values, and the larger the value interval, the longer the corresponding line segment. Each line segment in the line segment is obtained by adjusting the length of each line segment in the (i-1)th group of line segments according to the allocation result of the (i-1)th server. Both the (i-1)th group of line segments and the i-th group of line segments include N line segments into which the target value range is divided. The correspondence between the (i-1)th group of line segments and the N servers is the same as the correspondence between the i-th group of line segments and the N servers. When adjusting the length of each line segment in the (i-1)th group of line segments, the length of the line segment corresponding to the server used in the (i-1)th time is reduced.
[0098] As an optional implementation, the target value range is divided into multiple line segments. The longer the line segment, the higher the probability of a random number being hit; the shorter the line segment, the lower the probability of a random number being hit. The target value range can be set according to actual conditions, for example, 1000.
[0099] In the initial division of the target value range, [0, 1000] can be divided into two line segments. The length of each line segment is related to the actual business situation, or it can be set to have two equal initial lengths. Taking the initial division as an average division as an example, the length of each line segment is 500. The target value range [0, 1000] is divided into two line segments: line segment A [0-500] and region B (500-1000).
[0100] Random numbers can be generated using random algorithms, with decision points being positive integers greater than or equal to 0 and less than 10000. Alternatively, they can be positive integers greater than or equal to 0 and less than 1000. A random algorithm is an algorithm that uses probability and statistical methods to randomly select the next computational step during its execution. For example, the XorShift algorithm can quickly generate unsigned 32-bit and 64-bit pseudo-random numbers. Random numbers can also be generated using Go's random number generation library, using a timestamp as the key.
[0101] After allocating a server for each request, the lengths of the line segments within the target value range need to be adjusted. If line segment A is hit in the current request, the length of line segment A is reduced to decrease the probability of hitting that line segment again in the next request. In other words, the length of that line segment is reduced, while the lengths of other line segments are increased to dynamically adjust the probability of each server being assigned, thereby achieving a dynamic load balance among the servers.
[0102] Assuming, such as Figure 11 The target value range is initially divided into line segment A and line segment B, where the length of line segment A equals the length of line segment B, which is 500. Line segment A corresponds to a value range of 0-500, and line segment B corresponds to a value range of 500-1000. The probability of hitting line segment A equals the probability of hitting line segment B, which is 1 / 2. Line segment A corresponds to server A, and line segment B corresponds to server B.
[0103] When assigning a server to the first request, a first random number is generated for the first request. Let's say the random number is 100, where 0 < 100 < 500, and it matches line segment A. Then, server A is assigned to handle the first request.
[0104] To assign server A to the first request, the line segment lengths need to be redefined. When a decision hits a line segment, the probability of hitting that line segment again should be reduced, i.e., the length of that line segment should be decreased, while the lengths of other line segments should be increased. That is, the length of line segment A is decreased, and the length of line segment B is increased, resulting in... Figure 11 The diagram shows line segments A1 and A2. Taking an adjustment of 100 as an example, the hit probability of line segment A1 after adjustment is 400 / 1000, and the hit probability of line segment B1 is 600 / 1000.
[0105] If the same server's corresponding line segment is hit multiple times consecutively, the probability of that server being hit decreases as the length of that line segment decreases over time, while the lengths of other line segments increase as the probability of those other line segments being hit increases.
[0106] Taking servers E and F as examples, the target value range includes the (i-1)th group of line segments (line segment E and line segment F). When assigning the (i-1)th server for the (i-1)th request, a (i-1)th random number is randomly generated between 0 and 1000. When (0 < (i-1)th random number <= 700), line segment E is hit; when (700 < (i-1)th random number <= 1000), line segment F is hit. Assuming the (i-1)th random number is 200, hitting region E, then server E is assigned to the (i-1)th request, and server E processes the (i-1)th request.
[0107] After allocating server E for the (i-1)th request, the lengths of each line segment within the target value range are adjusted. The length of line segment E is decreased, while the lengths of other line segments are increased. In this implementation, the adjustment values for the line segment lengths can be set according to actual conditions, resulting in the following: Figure 12 As shown by line segments E1 and F1, when allocating servers for the next request (the i-th request), the probability of server E being assigned decreases, while the probability of server F being assigned increases. This achieves dynamic adjustment of the probability of each server being assigned, thus realizing load balancing among servers.
[0108] Optionally, after sending the i-th request to the server used for the ith time among the N servers, the method further includes: if the i-th request is for requesting target media resources, determining the value interval in which the i-th random number is located within the j-th group of value intervals, wherein the target value range is divided into the j-th group of value intervals, the number of value intervals in the j-th group of value intervals is S, each value interval in the j-th group of value intervals corresponds to one of the S selection modes, S is a positive integer greater than or equal to 2, j is a positive integer greater than or equal to 2, and each value interval in the j-th group of value intervals is obtained by adjusting the interval size of each value interval in the (i-1)-th group of value intervals according to the selection result of the (i-1)-th mode, wherein the j-th -1 value intervals include S value intervals into which the target value range is divided. The correspondence between the (j-1)th value interval and the S selection modes is the same as the correspondence between the j-th value interval and the S selection modes. The (i-1)th mode selection result represents the (i-1)th selection mode used to process the (i-1)th request among the S selection modes. When adjusting the interval size of each value interval in the (j-1)th value interval, the interval size of the value interval corresponding to the (i-1)th selection mode is reduced. The target media resource is selected from the target media resource set through the ith selection mode, wherein the ith selection mode corresponds to the value interval in which the ith random number is located in the j-th value interval.
[0109] As an optional implementation, the target media resources mentioned above can be media resources such as images, videos, and audio. This application can be applied to recommendation systems for dynamic cover images of short videos, short video recommendation systems, etc. Taking a dynamic cover image recommendation system as an example, the recommendation modes for dynamic cover images include a top popularity value selection mode and a best click-through rate selection mode. The above S selection modes include: a top popularity value selection mode and a best click-through rate selection mode. The top popularity value selection mode recommends dynamic cover images with the highest popularity value (e.g., top 2 or top 5) to the user from the dynamic cover image set. The best click-through rate selection mode recommends dynamic cover images with the highest click-through rate (e.g., top 2 or top 5) to the user from the dynamic cover image set.
[0110] After the i-th request is sent to the server used for the i-th time, the server used for the i-th time processes the i-th request. Assuming that the i-th request is for a dynamic cover image, the server used for the i-th time will choose one of the two modes, the top selection mode based on degree value and the best selection mode based on click-through rate, to recommend a dynamic cover image to the user.
[0111] The j-th value range mentioned above includes two value ranges: one corresponding to the top popularity selection mode and the other corresponding to the best click-through rate selection mode. The j-th value range is obtained by adjusting the values of each value range in the (j-1)-th value range. After selecting the (i-1)th selection mode for the (i-1)-th request in the (j-1)-th value range, the (j-1)-th value range is adjusted to obtain the j-th value range mentioned above.
[0112] like Figure 13 As shown, in the (j-1)th group of value intervals, the value interval for the top popularity selection mode is 0-500, and the value interval for the best click-through rate selection mode is 500-1000. If the (i-1)th request selects the top popularity selection mode as the selection mode used in the (i-1)th time, then when selecting the i-th selection mode for the next request (the i-th request), the probability of the top popularity selection mode being selected should decrease, and the probability of the best click-through rate selection mode being selected should increase. This adjustment of the value intervals for the top popularity selection mode and the best click-through rate selection mode in the (j-1)th group of value intervals yields the j-th group of value intervals. As shown in the figure, in the j-th group of value intervals, the value interval for the top popularity selection mode is 0-400; decreasing the value interval decreases the probability of selection, while increasing the value interval for the best click-through rate selection mode is 400-1000; increasing the value interval increases the probability of selection. Through this embodiment, the selection probabilities of each selection mode achieve a dynamic balance.
[0113] Optionally, before sending the i-th request to the server used for the ith time among the N servers, the method further includes: determining the value interval in which the i-th random number is located within the K-th set of value intervals, wherein the target value range is divided into the K-th set of value intervals, the number of value intervals in the K-th set of value intervals is T, each value interval in the K-th set of value intervals corresponds to one of the T server clusters, K is a positive integer greater than or equal to 2, T is a positive integer greater than or equal to 2, each value interval in the K-th set of value intervals is obtained by adjusting the interval size of each value interval in the (i-1)-th set of value intervals according to the allocation result of the (i-1)-th cluster, the (i-1)-th set of value intervals includes the T value intervals into which the target value range is divided, and the (i-1)-th set of value intervals and the T value intervals are... The correspondence between server clusters and the correspondence between the Kth group of value intervals and the T server clusters is the same. The (i-1)th cluster allocation result represents the (i-1)th server cluster used to process the (i-1)th request among the T server clusters. When adjusting the size of each value interval in the (K-1)th group of value intervals, the size of the value interval corresponding to the (i-1)th used server cluster is reduced. Sending the i-th request to the i-th used server among the N servers includes: allocating the i-th used server for the i-th request in the i-th used server cluster, wherein the i-th used server cluster corresponds to the value interval in the (K-1)th group of value intervals where the i-th random number is located, and the i-th used server cluster includes the N servers.
[0114] As an alternative implementation, if each value interval corresponds to a separate server in a large server cluster, the target value range will be divided into numerous value intervals, making the division and dynamic adjustment of the target value range quite complex. In this implementation, a large server cluster can be divided into multiple smaller server clusters, and the target value range can be divided into multiple value intervals, with each interval corresponding to one server cluster. Furthermore, each server within each server cluster can be further divided into multiple value intervals. For example... Figure 14As shown, after obtaining the i-th request, an i-th random number is generated for the i-th request. Based on the value range of the i-th random number within circular region 0, the server cluster corresponding to the i-th request is determined. Assume that within circular region 0, the value range for cluster 1 is 0°-90°, for cluster 2 it is 90°-200°, and for cluster 3 it is 200°-360°. If the i-th random number is 50° and falls within the value range corresponding to cluster 1, then a server is assigned to the i-th random number from among server 1, server 2, and server 3 in server cluster 1. Assume that within circular region 1, the value range for server 1 is 0°-100°, for server 2 it is 100°-220°, and for server 3 it is 220°-360°. If the i-th random number is 50° and falls within the value range corresponding to server 1, then the i-th request is sent to server 1, and server 1 processes the i-th request.
[0115] As another alternative implementation, such as Figure 15 As shown, after obtaining the i-th request, an i-th random number is generated for the i-th request, and the server cluster corresponding to the i-th request is determined based on the value range of the i-th random number. Figure 15 The diagram assumes that the value range for cluster 1 is 0-700, and the value range for cluster 2 is 700-1000. If the i-th random number is 50 and falls within the value range for cluster 1, then a server is assigned to the i-th random number between server 1 and server 2 in cluster 1. Similarly, if the value range for server 1 is 0-300, and the value range for server 2 is 300-1000, and the i-th random number is 500 and falls within the value range for server 1, then the i-th request is sent to server 1 for processing.
[0116] As an optional implementation, the value range corresponding to the aforementioned server cluster is also dynamically adjusted. For example... Figure 16 As shown in the figure, it is assumed that the value interval of the K-1th group includes the value interval corresponding to cluster a, the value interval corresponding to cluster b, and the value interval corresponding to cluster c.
[0117] After receiving the (i-1)th request, generate the (i-1)th random number for it. Assuming this random number falls within the value range corresponding to cluster b, allocate a server for the (i-1)th request within cluster b. Since cluster b has already been selected, the probability of cluster b being allocated a server for the next request should decrease. Therefore, the value range corresponding to cluster b can be narrowed, while the value ranges of other clusters can be widened. Figure 16As shown, the value range corresponding to cluster b is reduced to obtain cluster b1 in the Kth value range, while the value ranges corresponding to other clusters are increased to obtain clusters a1 and c1 in the Kth value range. In this implementation, by dynamically adjusting the value ranges corresponding to the server clusters, the probability of server clusters being assigned can be dynamically adjusted, achieving load balancing among server clusters.
[0118] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.
[0119] According to another aspect of the present invention, an apparatus for recognizing a target image for implementing the above-described target image recognition method is also provided. For example... Figure 17 As shown, the device includes: an acquisition module 1702, configured to acquire the i-th request and generate the i-th random number for the i-th request within a target value range, where i is a positive integer greater than or equal to 2, the target value range is divided into an i-th group of value intervals, the number of value intervals in the i-th group of value intervals is N, and each value interval in the i-th group of value intervals corresponds to one of N servers, where N is a positive integer greater than or equal to 2; and a determination module 1704, configured to determine the value interval in the i-th group of value intervals where the i-th random number is located, wherein each value interval in the i-th group of value intervals is obtained by adjusting the interval size of each value interval in the (i-1)-th group of value intervals according to the allocation result of the (i-1)-th server, and the (i-1)-th group of value intervals includes the target value range. The value range is divided into N value intervals. The correspondence between the (i-1)th value interval and the N servers is the same as the correspondence between the i-th value interval and the N servers. The (i-1)th server allocation result represents the (i-1)th server among the N servers used to process the (i-1)th request. When adjusting the size of each value interval in the (i-1)th value interval, the size of the value interval corresponding to the (i-1)th used server is reduced. The sending module 1706 is used to send the i-th request to the i-th used server among the N servers, wherein the i-th used server corresponds to the value interval in which the i-th random number is located in the (i-1)th value interval, and the i-th used server is used to process the i-th request.
[0120] Optionally, the above-described apparatus is further configured to: obtain the (i-1)th request before generating the i-th random number within the target value range for the i-th request; generate the (i-1)th random number within the target value range for the (i-1)th request; determine the value range in which the (i-1)th random number is located within the (i-1)th set of value ranges; send the (i-1)th request to the (i-1)th server among the N servers used for the (i-1)th time, wherein the (i-1)th server used corresponds to the value range in which the (i-1)th random number is located, and the (i-1)th server used is used to process the (i-1)th request; and, based on the allocation result of the (i-1)th server, adjust the value range obtained by adjusting the size of each value range in the (i-1)th set of value ranges to obtain the i-th set of value ranges.
[0121] Optionally, the above-described device is further configured to reduce the size of the value interval corresponding to the server used in the (i-1)th group of value intervals; and to increase the size of some or all of the value intervals in the (i-1)th group of value intervals, excluding the value interval corresponding to the server used in the (i-1)th time.
[0122] Optionally, the above-described apparatus is further configured to, when the value interval corresponding to the server used for the (i-1)th time is the target value interval for the (i-1)th time, and the size of the target value interval for the (i-1)th time has been reduced by a first value, increase the size of each value interval in the (i-1)th group of value intervals except for the target value interval for the (i-1)th time by a second value, wherein the second value = the first value / (N-1); when the value interval corresponding to the server used for the (i-1)th time is the target value interval for the (i-1)th time, and the size of the target value interval for the (i-1)th time has been reduced by a first value, increase the size of the M value intervals in the (i-1)th group of value intervals except for the target value interval for the (i-1)th time by a third value, wherein M is less than N-1, and the third value = the first value / M.
[0123] Optionally, the above-described apparatus is further configured to, when the server used for the (i-1)th time has processed P consecutive requests before the (i-1)th request, reduce the size of the interval corresponding to the server used for the (i-1)th time by a first value, where P is a positive integer greater than or equal to 2, and the first value is greater than a default second value; when processing the P consecutive requests, the size of the interval corresponding to the server used for the (i-1)th time is reduced by the second value; when the server used for the (i-1)th time has processed Q requests in the P consecutive requests before the (i-1)th request, reduce the size of the interval corresponding to the server used for the (i-1)th time by the first value, where Q is less than P, Q is a positive integer greater than or equal to 2, and the first value is greater than the default second value; when processing the Q requests, the size of the interval corresponding to the server used for the (i-1)th time is reduced by the second value.
[0124] Optionally, the above-described device is further configured to, when N is odd and the i-th random number represents the i-th angle, determine the target sector region where the i-th angle is located within the i-th group of sector regions of the target circular region, and determine the angle interval corresponding to the target sector region as the value interval of the i-th random number, wherein each sector region in the i-th group of sector regions corresponds to a value interval in the i-th group of values, and the larger the value interval, the larger the angle interval of the corresponding sector region, and each sector region in the i-th group of sector regions is allocated according to the (i-1)-th server. As a result, the fan-shaped regions obtained by adjusting the angle range of each fan-shaped region in the (i-1)th group of fan-shaped regions of the target circular region, both the (i-1)th group of fan-shaped regions and the i-th group of fan-shaped regions include N fan-shaped regions into which the target circular region is divided. The correspondence between the (i-1)th group of fan-shaped regions and the N servers is the same as the correspondence between the i-th group of fan-shaped regions and the N servers. When adjusting the angle range of each fan-shaped region in the (i-1)th group of fan-shaped regions, the angle range of the fan-shaped region corresponding to the server used in the (i-1)th time is reduced.
[0125] Optionally, the above-described device is further configured to, when N is an even number and the i-th random number represents the value of the i-th line segment, determine the target line segment containing the value of the i-th line segment in the i-th group of line segments within the target value range, and determine the value interval corresponding to the target line segment as the value interval where the i-th random number is located, wherein each line segment in the i-th group of line segments corresponds to a value interval in the i-th group of values, and the larger the value interval, the longer the corresponding line segment. Each line segment in the i-th group of line segments is determined according to the i-th random number. The i-1 server allocation results are obtained by adjusting the length of each segment in the i-1th group of line segments. Both the i-1th group of line segments and the i-th group of line segments include N line segments that divide the target value range. The correspondence between the i-1th group of line segments and the N servers is the same as the correspondence between the i-th group of line segments and the N servers. When adjusting the length of each segment in the i-1th group of line segments, the length of the line segment corresponding to the server used in the i-1th time is reduced.
[0126] Optionally, the above-described apparatus is further configured to, after sending the i-th request to the server used for the i-th time among the N servers, if the i-th request is for requesting target media resources, determine the value interval in the j-th group of value intervals where the i-th random number is located, wherein the target value range is divided into the j-th group of value intervals, the number of value intervals in the j-th group of value intervals is S, each value interval in the j-th group of value intervals corresponds to one of the S selection modes, S is a positive integer greater than or equal to 2, j is a positive integer greater than or equal to 2, and each value interval in the j-th group of value intervals is obtained by adjusting the interval size of each value interval in the (i-1)-th group of value intervals according to the selection result of the (i-1)-th mode. -1 value intervals include S value intervals into which the target value range is divided. The correspondence between the (j-1)th value interval and the S selection modes is the same as the correspondence between the j-th value interval and the S selection modes. The (i-1)th mode selection result represents the (i-1)th selection mode used to process the (i-1)th request among the S selection modes. When adjusting the interval size of each value interval in the (j-1)th value interval, the interval size of the value interval corresponding to the (i-1)th selection mode is reduced. The target media resource is selected from the target media resource set through the ith selection mode, wherein the ith selection mode corresponds to the value interval in which the ith random number is located in the j-th value interval.
[0127] Optionally, the above-described apparatus is further configured to determine the value interval in which the i-th random number is located within the K-th value interval before sending the i-th request to the server used for the i-th time among the N servers. The target value range is divided into the K-th value interval, the number of value intervals in the K-th value interval is T, each value interval in the K-th value interval corresponds to one of the T server clusters, K is a positive integer greater than or equal to 2, and T is a positive integer greater than or equal to 2. Each value interval in the K-th value interval is determined based on the allocation result of the (i-1)-th cluster. The value intervals obtained by adjusting the interval size are as follows: the (K-1)th group of value intervals includes T value intervals into which the target value range is divided. The correspondence between the (K-1)th group of value intervals and the T server clusters is the same as the correspondence between the Kth group of value intervals and the T server clusters. The (i-1)th cluster allocation result represents the server cluster used for processing the (i-1)th request in the T server clusters. When adjusting the interval size of each value interval in the (K-1)th group of value intervals, the interval size of the value interval corresponding to the (i-1)th used server cluster is reduced.
[0128] Optionally, the above-described apparatus is further configured to allocate the server for the i-th request in the server cluster used for the i-th time, wherein the server cluster used for the i-th time corresponds to the value range in the (K-1)-th group of value ranges of the i-th random number, and the server cluster used for the i-th time includes the N servers.
[0129] Alternatively, as those skilled in the art will understand, Figure 18 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones (such as Android phones, iOS phones, etc.), tablets, PDAs, mobile internet devices (MIDs), PADs, and other terminal devices. Figure 18 This does not limit the structure of the aforementioned electronic devices or electronic equipment. For example, electronic devices or electronic equipment may also include components that are more... Figure 18 The more or fewer components shown (such as network interfaces, etc.), or having the same Figure 18 The different configurations shown.
[0130] The memory 1802 can be used to store software programs and modules, such as the program instructions / modules corresponding to the server allocation method and apparatus in this embodiment of the invention. The processor 1804 executes various functional applications and data processing by running the software programs and modules stored in the memory 1802, thereby implementing the aforementioned server allocation method. The memory 1802 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1802 may further include memory remotely located relative to the processor 1804, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Specifically, the memory 1802 may be used, but is not limited to, to store information such as the i-th set of value intervals and the (i-1)-th set of value intervals. As an example, such as... Figure 18 As shown, the memory 1802 may include, but is not limited to, the acquisition module 1702, the determination module 1704, and the sending module 1706 of the server's distribution device. Furthermore, it may include, but is not limited to, other module units of the server's distribution device, which will not be elaborated upon in this example.
[0131] Optionally, the transmission device 1806 described above is used to receive or send data via a network. Specific examples of the network described above may include wired networks and wireless networks. In one example, the transmission device 1806 includes a Network Interface Controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In another example, the transmission device 1806 is a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0132] In addition, the aforementioned electronic device also includes: a display 1808 for displaying the aforementioned target media resources; and a connection bus 1810 for connecting the various module components in the aforementioned electronic device.
[0133] In other embodiments, the aforementioned terminal device or server can be a node in a distributed system, wherein the distributed system can be a blockchain system, which is a distributed system formed by connecting multiple nodes through network communication. The nodes can form a peer-to-peer (P2P) network, and any form of computing device, such as a server, terminal, or other electronic device, can become a node in the blockchain system by joining this peer-to-peer network.
[0134] According to one aspect of this application, a computer program product is provided, comprising a computer program / instructions containing program code for performing the methods shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication section 1909, and / or installed from a removable medium 1911. When the computer program is executed by a central processing unit 1901, it performs various functions provided in embodiments of this application.
[0135] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0136] Figure 19 A schematic block diagram of a computer system architecture for implementing an electronic device according to embodiments of the present application is shown.
[0137] It should be noted that, Figure 19 The computer system 1900 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0138] like Figure 19 As shown, the computer system 1900 includes a central processing unit (CPU) 1901, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 1902 or programs loaded from storage section 1908 into random access memory (RAM) 1903. The RAM 1903 also stores various programs and data required for system operation. The CPU 1901, ROM 1902, and RAM 1903 are interconnected via a bus 1904. An input / output interface 1905 (I / O interface) is also connected to the bus 1904.
[0139] The following components are connected to the input / output interface 1905: an input section 1906 including a keyboard, mouse, etc.; an output section 1907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1908 including a hard disk, etc.; and a communication section 1909 including a network interface card such as a local area network card, modem, etc. The communication section 1909 performs communication processing via a network such as the Internet. A drive 1910 is also connected to the input / output interface 1905 as needed. Removable media 1911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on the drive 1910 as needed so that computer programs read from them can be installed into the storage section 1908 as needed.
[0140] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1909, and / or installed from removable medium 1911. When the computer program is executed by central processing unit 1901, it performs various functions defined in the system of this application.
[0141] According to one aspect of this application, a computer-readable storage medium is provided, wherein a processor of a computer device reads computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the methods provided in the various alternative implementations described above.
[0142] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0143] S1, obtain the i-th request, and generate the i-th random number for the i-th request within the target value range, where i is a positive integer greater than or equal to 2, the target value range is divided into the i-th group of value intervals, the number of value intervals in the i-th group of value intervals is N, and each value interval in the i-th group of value intervals corresponds to one of the N servers, where N is a positive integer greater than or equal to 2;
[0144] S2, determine the value interval where the i-th random number is located in the i-th group of value intervals, wherein each value interval in the i-th group of value intervals is obtained by adjusting the interval size of each value interval in the i-1 group of value intervals according to the allocation result of the i-1th server. The i-1th group of value intervals includes N value intervals into which the target value range is divided. The correspondence between the i-1th group of value intervals and the N servers is the same as the correspondence between the i-th group of value intervals and the N servers. The allocation result of the i-1th server indicates the server used for processing the i-1th request among the N servers. When adjusting the interval size of each value interval in the i-1th group of value intervals, the interval size of the value interval corresponding to the server used in the i-1th time is reduced.
[0145] S3, the i-th request is sent to the i-th server among the N servers, wherein the i-th server corresponds to the value range in the (i-1)-th group of value ranges of the i-th random number, and the i-th server is used to process the i-th request.
[0146] Optionally, in this embodiment, those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0147] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0148] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0149] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection between units or modules, and may be electrical or other forms.
[0150] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or 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.
[0151] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0152] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A server allocation method, characterized in that, include: Based on the server allocation result of the (i-1)th server, the server used for the (i-1)th time is determined, wherein the server used for the (i-1)th time is used to process the (i-1)th request, and i is a positive integer greater than or equal to 2; If the historical usage count of the server used in the (i-1)th time reaches the threshold, the size of the value interval corresponding to the server used in the (i-1)th group of value intervals is reduced according to the first adjustment value to obtain the adjusted (i-1)th group of value intervals. The historical usage count is used to indicate the total number of historical requests that the server used in the (i-1)th time has continuously processed before processing the (i-1)th request. The (i-1)th group of value intervals includes N value intervals obtained by dividing the target value range, where N is a positive integer greater than or equal to 2. The first adjustment value is greater than the second adjustment value. If the historical usage count of the server used in the (i-1)th time has not yet reached the threshold, the value interval corresponding to the server used in the (i-1)th time is reduced according to the second adjustment value. Obtain the i-th request and generate the i-th random number for the i-th request within the target value range, wherein the adjusted (i-1)-th value range is determined as the i-th value range, and each value range in the i-th value range corresponds to one of the N servers; In the i-th set of value intervals, the value interval in which the i-th random number is located is determined, wherein the correspondence between the (i-1)-th set of value intervals and the N servers is the same as the correspondence between the i-th set of value intervals and the N servers; The i-th request is sent to the i-th server among the N servers, wherein the i-th server corresponds to the value range in which the i-th random number is located in the (i-1)-th group of value ranges, and the i-th server is used to process the i-th request.
2. The method according to claim 1, characterized in that, Before generating the i-th random number within the target value range for the i-th request, the method further includes: Obtain the (i-1)th request, and generate the (i-1)th random number for the (i-1)th request within the target value range; Determine the value interval in which the (i-1)th random number is located within the value interval of the (i-1)th group; The (i-1)th request is sent to the (i-1)th server among the N servers, wherein the (i-1)th server corresponds to the value range of the (i-1)th random number, and the (i-1)th server is used to process the (i-1)th request. Based on the allocation result of the (i-1)th server, the value intervals obtained by adjusting the size of each value interval in the (i-1)th group of value intervals are obtained, thus forming the i-th group of value intervals.
3. The method according to claim 2, characterized in that, The value interval obtained by adjusting the interval size of each value interval in the (i-1)th group of value intervals according to the allocation result of the (i-1)th server, is the i-th group of value intervals, including: Reduce the size of the value interval corresponding to the server used in the (i-1)th group of value intervals; Increase the size of some or all of the value intervals in the (i-1)th group of value intervals, excluding the value interval corresponding to the server used in the (i-1)th time.
4. The method according to claim 3, characterized in that, The step of increasing the size of some or all of the value intervals in the (i-1)th group of value intervals, excluding the value interval corresponding to the server used in the (i-1)th time, includes: If the value interval corresponding to the server used in the (i-1)th time is the target value interval for the (i-1)th time, and the size of the target value interval for the (i-1)th time has been reduced by a first value, then the size of each value interval in the (i-1)th group of value intervals, except for the target value interval for the (i-1)th time, is increased by a second value, where the second value = the first value / (N-1); or If the value interval corresponding to the server used in the (i-1)th time is the target value interval for the (i-1)th time, and the size of the target value interval for the (i-1)th time is reduced by a first value, then the size of the M value intervals in the (i-1)th group of value intervals other than the target value interval for the (i-1)th time is increased by a third value, where M is less than N-1, and the third value = the first value / M.
5. The method according to claim 3, characterized in that, The step of reducing the size of the value interval corresponding to the server used in the (i-1)th group of value intervals includes: If the server used in the (i-1)th instance has processed P consecutive requests before the (i-1)th request, the size of the interval corresponding to the server used in the (i-1)th instance is reduced by a first value, where P is a positive integer greater than or equal to 2, and the first value is greater than a default second value. When processing the P consecutive requests, the size of the interval corresponding to the server used in the (i-1)th instance is reduced by the second value; or If the server used in the (i-1)th time has processed Q requests in the P consecutive requests preceding the (i-1)th request, the size of the interval corresponding to the server used in the (i-1)th time will be reduced by the first value, where Q is less than P, Q is a positive integer greater than or equal to 2, and the first value is greater than the default second value. When processing the Q requests, the size of the interval corresponding to the server used in the (i-1)th time will be reduced by the second value.
6. The method according to any one of claims 1 to 5, characterized in that, Determining the value interval in which the i-th random number lies within the i-th value interval includes: When N is odd and the i-th random number represents the i-th angle, the target sector region containing the i-th angle is determined within the i-th group of sector regions of the target circular region. The angle interval corresponding to the target sector region is determined as the value interval of the i-th random number. Each sector region in the i-th group of sector regions corresponds to a value interval in the i-th group of values; the larger the value interval, the larger the angle interval of the corresponding sector region. Each sector region in the i-th group of sector regions is assigned according to the (i-1)-th server allocation result. The sector region is obtained by adjusting the angle range of each sector region in the (i-1)th group of sector regions of the target circular region. Both the (i-1)th group of sector regions and the i-th group of sector regions include N sector regions into which the target circular region is divided. The correspondence between the (i-1)th group of sector regions and the N servers is the same as the correspondence between the i-th group of sector regions and the N servers. When adjusting the angle range of each sector region in the (i-1)th group of sector regions, the angle range of the sector region corresponding to the server used in the (i-1)th time is reduced.
7. The method according to any one of claims 1 to 5, characterized in that, The step of determining the value interval in which the i-th random number is located within the i-th value interval further includes: When N is even and the i-th random number represents the value of the i-th line segment, the target line segment containing the value of the i-th line segment is determined from the i-th group of line segments within the target value range. The value interval corresponding to the target line segment is determined as the value interval where the i-th random number is located. Each line segment in the i-th group of line segments corresponds to a value interval within the i-th group of values. The larger the value interval, the longer the corresponding line segment. Each line segment in the i-th group of line segments is determined based on the (i-1)-th service... The allocation result is a line segment obtained by adjusting the length of each line segment in the (i-1)th group of line segments. Both the (i-1)th group of line segments and the i-th group of line segments include N line segments that divide the target value range. The correspondence between the (i-1)th group of line segments and the N servers is the same as the correspondence between the i-th group of line segments and the N servers. When adjusting the length of each line segment in the (i-1)th group of line segments, the length of the line segment corresponding to the server used in the (i-1)th time is reduced.
8. The method according to any one of claims 1 to 5, characterized in that, After sending the i-th request to the server used for the i-th time among the N servers, the method further includes: When the i-th request is for a target media resource, the value interval in which the i-th random number is located is determined within the j-th value interval. The target value range is divided into the j-th value interval, and the number of value intervals in the j-th value interval is S. Each value interval in the j-th value interval corresponds to one of S selection modes, where S is a positive integer greater than or equal to 2, and j is a positive integer greater than or equal to 2. Each value interval in the j-th value interval is selected based on the i-1 mode selection result, by performing a range enlargement operation on each value interval in the (j-1)-th value interval. The value range obtained by small adjustments, wherein the (j-1)th group of value ranges includes S value ranges into which the target value range is divided, the correspondence between the (j-1)th group of value ranges and the S selection modes is the same as the correspondence between the jth group of value ranges and the S selection modes, and the (i-1)th mode selection result represents the (i-1)th selection mode used to process the (i-1)th request among the S selection modes, when adjusting the size of each value range in the (j-1)th group of value ranges, the size of the value range corresponding to the (i-1)th selection mode is reduced; The target media resource is selected from the target media resource set by using the selection mode for the i-th time, wherein the selection mode used for the i-th time corresponds to the value interval in the j-th group of value intervals of the i-th random number.
9. The method according to any one of claims 1 to 5, characterized in that, Before sending the i-th request to the server used for the i-th time among the N servers, the method further includes: determining the value interval in which the i-th random number is located within the K-th set of value intervals, wherein the target value range is divided into the K-th set of value intervals, the number of value intervals in the K-th set of value intervals is T, each value interval in the K-th set of value intervals corresponds to one of the T server clusters, K is a positive integer greater than or equal to 2, T is a positive integer greater than or equal to 2, and each value interval in the K-th set of value intervals is determined according to the allocation result of the (i-1)-th cluster, and each value interval in the (K-1)-th set of value intervals is... The range of values obtained by adjusting the range size is as follows: the (K-1)th group of value ranges includes T value ranges into which the target value range is divided. The correspondence between the (K-1)th group of value ranges and the T server clusters is the same as the correspondence between the Kth group of value ranges and the T server clusters. The (i-1)th cluster allocation result represents the server cluster used for processing the (i-1)th request in the T server clusters. When adjusting the range size of each value range in the (K-1)th group of value ranges, the range size of the value range corresponding to the server cluster used in the (i-1)th request is reduced. Sending the i-th request to the i-th server among the N servers for the i-th time includes: allocating the i-th server for the i-th time in the server cluster for the i-th time, wherein the server cluster for the i-th time corresponds to the value range in the (K-1)-th group of value ranges of the i-th random number, and the server cluster for the i-th time includes the N servers.
10. A server allocation device, characterized in that, include: The acquisition module is used to acquire the i-th request and generate the i-th random number for the i-th request within the target value range. The adjusted (i-1)-th value range is determined as the i-th value range, and each value range in the i-th value range corresponds to one of the N servers. The determining module is used to determine the value interval in which the i-th random number is located within the i-th value interval, wherein the correspondence between the (i-1)-th value interval and the N servers is the same as the correspondence between the i-th value interval and the N servers; The sending module is used to send the i-th request to the i-th server among the N servers, wherein the i-th server corresponds to the value range in which the i-th random number is located in the (i-1)-th group of value ranges, and the i-th server is used to process the i-th request; The apparatus is further configured to, before acquiring the i-th request, determine the server used for the (i-1)th time based on the (i-1)th server allocation result, wherein the (i-1)th server used is used to process the (i-1)th request, and i is a positive integer greater than or equal to 2; if the historical usage count of the (i-1)th server used reaches a threshold, reduce the size of the value interval corresponding to the (i-1)th server used in the (i-1)th group of value intervals according to a first adjustment value, to obtain an adjusted (i-1)th group of value intervals, wherein the historical usage count is used to indicate the total number of historical requests that the (i-1)th server used has continuously processed before processing the (i-1)th request, the (i-1)th group of value intervals includes N value intervals obtained by dividing the target value range, where N is a positive integer greater than or equal to 2, the first adjustment value is greater than a second adjustment value, and if the historical usage count of the (i-1)th server used has not yet reached the threshold, the value interval corresponding to the (i-1)th server used is reduced according to the second adjustment value.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method according to any one of claims 1 to 9.
12. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 9.
13. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 9 through the computer program.
Citation Information
Patent Citations
Distributed block data access method and device
CN106506608A
Task distribution method and device in cluster environment
CN112115202A