Request processing method and device
By selecting the array unit with the smallest subscript as the target unit in load balancing and dynamically updating the number of connections, the problem of traversing large overhead and performance bottlenecks in the prior art is solved, and efficient load balancing and request distribution is achieved, which is suitable for large-scale and high-concurrency environments.
Patent Information
- Application Number
- CN202510585750.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-07
- Publication Date
- 2025-07-04
AI Technical Summary
In the load balancing, the prior art has problems such as high traversal overhead, high implementation complexity and high concurrency environments, and it is difficult to quickly select low-load instances for request distribution.
By selecting the array unit with the smallest subscript as the target unit from the array unit of the candidate instance, the target instance is determined based on the number of connections, and moving it to adjacent array units for request distribution, dynamically update the connection number status, avoiding traversal and complex reorder operations.
It realizes load balancing with the minimum number of connections, improves the efficiency and scalability of request processing, reduces the request response time, and is suitable for large-scale and high-concurrency scenarios.
Smart Images

Figure CN120263793A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular, to a request processing method and apparatus. Background Art
[0002] In the prior art, load balancing usually distributes requests by traversing all candidate instances and selecting the instance with the lightest load. As the number of instances increases, the traversal overhead increases significantly, affecting the response efficiency of the system. Some solutions use complex data structures for optimization, but this increases the implementation complexity and maintenance cost, and there are performance bottlenecks in high-concurrency environments. Therefore, there is an urgent need for a request distribution method that can quickly select low-load instances, is simple to implement, and easy to expand, so as to improve the load balancing effect and reduce the request response time. Summary of the Invention
[0003] In view of this, embodiments of the present invention at least provide a request processing method, apparatus, electronic device, and storage medium, which can achieve load balancing with the minimum number of connections, improve the load balancing effect and reduce the request response time, and at the same time improve the scalability of the request processing method.
[0004] In a first aspect, an embodiment of the present invention provides a request processing method, including:
[0005] In response to receiving a request, select the array unit with the smallest subscript from the array units containing candidate instances as the target unit; the subscript of the array unit represents the number of connections corresponding to the candidate instance in the array unit;
[0006] Determine a target instance for distributing the request from the candidate instances in the target unit;
[0007] Move the target instance from the target unit to the next array unit adjacent to the target unit, and distribute the request through the target instance.
[0008] Optionally, before selecting the array unit with the smallest subscript from the array units containing candidate instances in response to receiving a request, it further includes:
[0009] Create a connection number array; the number of array units in the connection number array is determined based on the maximum connection number of the candidate instances; the subscripts of the array units in the connection number array start from 0 and increase;
[0010] In response to the completion of creating the connection number array, place each candidate instance in the first array unit of the connection number array for request distribution.
[0011] Optionally, after receiving the request, it further includes:
[0012] Determine whether the array cell with the smallest subscript in the array cell containing candidate instances is the array cell with the largest subscript in the connection number array;
[0013] In response to the array cell with the smallest subscript in the array cell of the candidate instance not being the array cell with the largest subscript in the connection number array, determine a target instance for distributing the request from each candidate instance in the target cell;
[0014] In response to the array cell with the smallest subscript in the array cell of the candidate instance being the array cell with the largest subscript in the connection number array, return a request distribution failure message to the request initiator.
[0015] Optionally, moving the target instance from the target cell to the next array cell adjacent to the target cell includes:
[0016] Add the target instance to the end of the existing candidate instances in the next array cell adjacent to the target cell.
[0017] Optionally, after distributing the request through the target instance, it further includes:
[0018] In response to the completion of request distribution, release the target instance from the next array cell adjacent to the target cell and move the target instance to the target cell.
[0019] Optionally, releasing the target instance from the next array cell adjacent to the target cell includes:
[0020] Based on the identifier of the target instance, determine the instance information of the target instance;
[0021] Based on the instance information, determine the position of the target instance in the next array cell adjacent to the target cell;
[0022] In response to the position of the target instance in the next array cell adjacent to the target cell being the end, delete the target instance from the next array cell adjacent to the target cell;
[0023] In response to the position of the target instance in the next array cell adjacent to the target cell not being the end, overwrite the target instance with the candidate instance at the end of the next array cell adjacent to the target cell and delete the candidate instance at the end of the next array cell adjacent to the target cell.
[0024] In a second aspect, an embodiment of the present invention provides a request processing device, including:
[0025] A selection module, configured to, in response to receiving a request, select an array cell with the smallest subscript from the array cells containing candidate instances as the target cell; the subscript of the array cell represents the connection number corresponding to the candidate instance in the array cell;
[0026] A determination module, configured to determine a target instance for distributing a request from each candidate instance in a target unit;
[0027] A moving module, configured to move the target instance from the target unit to the next array unit adjacent to the target unit and distribute the request through the target instance.
[0028] In a third aspect, an embodiment of the present invention further provides an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the computer device runs, the processor communicates with the memory through the bus. When the machine-readable instructions are executed by the processor, the steps in the above first aspect, or any optional implementation manner in the first aspect, are executed.
[0029] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, the steps in the above first aspect, or any optional implementation manner in the first aspect, are executed.
[0030] In a fifth aspect, an embodiment of the present invention further provides a computer program product, including a computer program, and the computer program implements the method of any of the above embodiments when executed by a processor.
[0031] In any of the above aspects or any implementation manner of any aspect, the candidate instances are classified and stored in array units with different subscripts according to the number of connections, achieving efficient minimum connection number load balancing. When a request is received, the target unit can be preferentially selected from the array unit with the smallest subscript, and the connection number corresponding to this unit is the smallest, ensuring that each request is distributed to the instance with the lowest current load as much as possible, thereby effectively balancing the load distribution among the instances. After determining the target instance, the target instance is further moved to the next array unit corresponding to the connection number plus one, realizing the dynamic update of the connection number status, without traversing all instances or performing complex rearrangement operations, reducing the processing overhead. Since the search and update processes are both local operations based on array units, it avoids the performance bottlenecks brought by traditional traversal or using complex data structures, and is particularly suitable for large-scale and high-concurrency scenarios. Through this method, not only can the accuracy of load balancing be significantly improved, the queuing delay of requests on high-load instances be reduced, but also the implementation process can be simplified, the scalability and processing efficiency of the request distribution process be improved, and thus while ensuring the system response speed, it supports the continuous growth of the number of instances and the amount of requests.
[0032] For the beneficial effects of the above request processing device, electronic device, and storage medium, refer to the description of the above request processing method, which will not be elaborated here. Description of the Drawings
[0033] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the accompanying drawings required for the embodiments. The accompanying drawings herein are incorporated into the specification and form a part of this specification. These drawings illustrate the embodiments in accordance with the present invention and, together with the specification, are used to explain the technical solutions of the present invention. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.
[0034] Figure 1 Shows a flowchart of a request processing method provided by an embodiment of the present invention;
[0035] Figure 2 Shows a schematic diagram of a request processing method provided by an embodiment of the present invention;
[0036] Figure 3 Shows a schematic diagram of a request processing apparatus provided by an embodiment of the present invention;
[0037] Figure 4 Shows an exemplary system architecture to which the embodiments of the present invention can be applied;
[0038] Figure 5 Shows a schematic diagram of the structure of a computer system of a terminal device or a server for implementing the embodiments of the present invention. Detailed implementation manners
[0039] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Usually, the components of the embodiments of the present invention described and illustrated herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.
[0040] It should be noted that in the technical solutions of the present invention, the collection, use, storage, sharing, transfer, and other processing of user personal information all comply with the provisions of relevant laws and regulations, and it is necessary to inform the user and obtain the consent or authorization of the user. When applicable, technical processing such as de-identification and / or anonymization and / or encryption is performed on user personal information.
[0041] The above problems and solutions are all the results obtained by the inventors after practice and careful research. The discovery process of the above problems and the solutions proposed for the above problems should be the contributions made by the inventors to this invention during the process of this invention.
[0042] Next, the technical solutions of the present invention will be clearly and completely described in conjunction with the accompanying drawings of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Usually, the components of the present invention described and illustrated in the accompanying drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the present invention claimed, but only represents the selected embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts belong to the scope of protection of the present invention.
[0043] It should be noted that similar reference numerals and letters denote similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0044] For the convenience of understanding this embodiment, first, a request processing method disclosed in the embodiments of the present invention will be introduced in detail. The execution subject of the request processing method provided in the embodiments of the present invention is generally a computer device with certain computing capabilities. Such computer devices include, for example: terminal devices or servers or other processing devices. The terminal device can be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementation manners, the request processing method can be implemented by a processor calling computer-readable instructions stored in a memory.
[0045] See Figure 1 As shown, it is a flowchart of the request processing method provided in the embodiments of the present invention. The method includes S101 to S103, where:
[0046] S101: In response to receiving a request, select the array unit with the smallest subscript from the array units containing candidate instances as the target unit.
[0047] In the embodiments of the present invention, an instance can refer to a specific running unit for processing requests, such as a server node, an application container, a microservice module, or a process thread, etc. Each instance has independent resources and processing capabilities and can receive and respond to requests initiated by a request initiator. As Figure 2As shown Figure 2 Each rectangular cell in it can represent an array cell, and the number corresponding to each array cell is the subscript of the array cell, which is used to represent the number of connections corresponding to the candidate instance in the array cell.
[0048] In the embodiment of the present invention, before selecting the array cell with the smallest subscript as the target cell from the array cells containing candidate instances in response to receiving a request, it further includes: creating a connection number array; the number of array cells in the connection number array is determined based on the maximum connection number of the candidate instances; the subscripts of the array cells in the connection number array start from 0 and increase; in response to the completion of creating the connection number array, each candidate instance is placed in the first array cell of the connection number array for request distribution.
[0049] In a specific implementation, the executor of the embodiment of the present invention can first determine the number of array cells in the connection number array based on the maximum connection number in the candidate instances, so as to ensure that the connection number array can cover the possible connection number range of each current candidate instance. As Figure 2 shown Figure 2 In it, N represents the maximum connection number of the candidate instances. The array cells in the connection number array are arranged in increasing order starting from the subscript 0, and each array cell corresponds to a specific connection value, representing the set of candidate instances in the current connection number state. After the connection number array is created, all candidate instances can be initially placed in the first array cell of the connection number array, that is, the array cell with the subscript 0. Since each candidate instance has not processed any requests at this time, the connection numbers are all zero and are uniformly classified into the cell with the subscript 0.
[0050] In another possible implementation, the connection number can also be used as the primary key of the hash table, and the candidate instances with the same connection number are all hung under the same primary key. The value corresponding to the primary key can be a list of instances. It should be noted that the above method is only used as an example of a feasible implementation in the embodiment of the present invention and does not constitute an improper limitation to the present invention. In actual applications, the corresponding connection number identification method can be set according to actual needs and situations. The embodiment of the present invention does not make specific limitations on this, as long as its function can be realized.
[0051] In the embodiment of the present invention, after receiving a request, it further includes: determining whether the array cell with the smallest subscript in the array cell containing the candidate instance is the array cell with the largest subscript in the connection number array; in response to the array cell with the smallest subscript in the candidate instance array cell not being the array cell with the largest subscript in the connection number array, determining a target instance for distributing the request from the candidate instances in the target cell; in response to the array cell with the smallest subscript in the candidate instance array cell being the array cell with the largest subscript in the connection number array, returning a request distribution failure message to the request initiator.
[0052] In a specific implementation, after receiving the request sent by the request initiator, it can be determined whether the array unit with the smallest subscript in the array units containing the candidate instance is the array unit with the largest subscript in the connection number array. When the array unit with the smallest subscript in the array units containing the candidate instance is the array unit with the largest subscript in the connection number array, that is, Figure 2 As shown in the middle f section, it indicates that all candidate instances in the current connection number array have reached the maximum number of connections and cannot process the current request. At this time, a request distribution failure message can be generated. The specific content of the request distribution failure message can be arbitrary, which may include the cause of failure, current status and subsequent suggestions, such as "Request distribution failed: All candidate instances have reached the maximum number of connections and cannot accept new requests", "Request distribution failed: The number of connections of all current candidate instances has reached the upper limit set by the system, and new requests cannot be distributed. Please try again later or expand instance resources", etc. The embodiment of the present invention does not make specific limitations on this, and its function shall prevail. On the contrary, when the array unit with the smallest subscript in the array unit of the candidate instance is not the array unit with the largest subscript in the connection number array, it indicates that there is an instance in the current connection number array that can be used to distribute requests. In order to achieve load balancing and avoid overloading of certain instances, the target instance can be determined from the candidate instance with the smallest number of connections for request distribution.
[0053] In another possible implementation, when all candidate instances in the connection number array have reached the maximum number of connections, in addition to generating a request distribution failure message, the request can also be placed in a waiting queue. Since the instance may be released after the request distribution is completed, the request in the waiting queue can perform the instance matching step after the instance is released. At the same time, a corresponding waiting prompt message can also be generated and sent to the request initiator; the form and content of the waiting prompt message can be set arbitrarily, for example, a pop-up window can be used to prompt the request initiator that "your request has entered the waiting queue, the current system resources are tight, and all instances are at the processing limit. Requests will be allocated and processed in turn after the resources are released, please wait patiently." It should be noted that the above description of the waiting prompt message is only used as an example of a feasible implementation method in the embodiment of the present invention. In actual applications, it can be set according to actual needs and circumstances. The embodiment of the present invention does not make specific limitations on this, and its function can be realized.
[0054] S102: Determine a target instance for distributing the request from candidate instances in the target unit.
[0055] In an embodiment of the present invention, when the array element with the smallest subscript in the array unit of candidate instances is not the array element with the largest subscript in the connection number array, it indicates that there are instances in the current connection number array that can be used to distribute requests. To achieve load balancing and avoid overloading of some instances, a target instance can be determined from the candidate instances with the smallest connection number for request distribution. When there is only one candidate instance in the target unit, the candidate instance can be directly determined as the target instance. As Figure 2 shown in section a, when there are multiple candidate instances in the target unit, a candidate instance can be randomly selected from the candidate instances in the target unit as the target instance. Alternatively, the target instance can also be determined in sequence according to the numbers of the candidate instances included in the target unit. Or, the target instance can also be determined based on the resource information and load information of different candidate instances. It should be noted that the above methods for determining the target instance from multiple candidate instances are only examples of feasible implementation manners in the embodiments of the present invention, and do not constitute improper limitation to the present invention. In actual applications, it can be set according to actual situations and requirements, and the embodiments of the present invention do not make specific limitations on this, as long as its function can be realized.
[0056] S103: Move the target instance from the target unit to the next array unit adjacent to the target unit, and distribute requests through the target instance.
[0057] In an embodiment of the present invention, moving the target instance from the target unit to the next array unit adjacent to the target unit includes: adding the target instance to the end of the existing candidate instances in the next array unit adjacent to the target unit.
[0058] In specific implementation, after determining the target instance for request distribution, the connection number of the target instance needs to be incremented by one on the original basis. As Figure 2 shown in sections a and b, the original connection number of candidate instance 2 is 0. When candidate instance 2 is determined as the target instance for request distribution, candidate instance 2 can be moved to the array unit with the corresponding connection number of 1. Specifically, when moving the target instance, if there are no other candidate instances in the array unit with a connection number of 1, the target instance can be directly moved to the array unit with a connection number of 1. If there are already other candidate instances in the array unit with a corresponding connection number of 1, as Figure 2 shown in section c, if candidate instance 1 and candidate instance 3 need to be moved to the array unit with a subscript of 1, they can be arranged in sequence at the end of candidate instance 2. Thus, moving the target instance does not involve the position movement or rearrangement of existing candidate instances, and the operation time complexity is O(1). For a high-concurrency scenario with a large number of instances, it can reduce memory operations and the computing overhead of the central processing unit, which is beneficial to maintaining the high performance of the execution entity in the embodiments of the present invention.
[0059] In another possible implementation, if the business scenario requires that the newly allocated instance can be reused as soon as possible, the target instance can also be inserted into the head of the corresponding array cell, and the existing candidate instances in the data cell are sequentially shifted backward, so that the most recently moved instance can be preferentially selected. The above method of moving the target instance is only an example of a feasible implementation in the embodiments of the present invention and does not constitute an improper limitation of the present invention. In actual applications, it can be set according to actual needs. For example, if the scenario is to consider instance attributes, it can be inserted in an orderly manner in the corresponding array cell according to sorting rules such as the creation time and load health of the instance. The embodiments of the present invention do not make specific limitations on this, as long as its function can be achieved.
[0060] In the embodiments of the present invention, as described above, when the target instance completes the distribution of the request, the corresponding target instance can be released. As Figure 2 shown in section d to e, after the target instance 2 completes the distribution of the corresponding request, the number of connections needs to be reduced by one on the original basis. Specifically, after the target instance distributes the request, it further includes: in response to the completion of the request distribution, releasing the target instance from the next array cell adjacent to the target cell and moving the target instance to the target cell.
[0061] In a specific implementation, after the target instance distributes the request, the operation of releasing the target instance can continue. Specifically, when the target instance completes the processing of the current request, it is detected whether the corresponding number of connections needs to be updated. If it is detected that the current request has been processed, the target instance can be released from the next array cell adjacent to the target cell where it is located and moved back to the original target cell. In this way, the number of connections of the target instance is correspondingly reduced, which can reflect its real-time load change. During the movement, the target instance can be directly inserted into the end of the target cell to ensure the simplicity and consistency of the internal instance arrangement of the array cell; other methods of moving the target instance to the target cell are similar to the methods described above for moving the target instance to the next array cell adjacent to the target cell and will not be elaborated here.
[0062] In the embodiments of the present invention, releasing the target instance from the next array cell adjacent to the target cell includes: determining the instance information of the target instance based on the identifier of the target instance; determining the position of the target instance in the next array cell adjacent to the target cell based on the instance information; in response to the position of the target instance in the next array cell adjacent to the target cell being the end, deleting the target instance from the next array cell adjacent to the target cell; in response to the position of the target instance in the next array cell adjacent to the target cell not being the end, covering the target instance with the candidate instance at the end of the next array cell adjacent to the target cell and deleting the candidate instance at the end of the next array cell adjacent to the target cell.
[0063] In a specific implementation, based on the identification information of the target instance, the detailed instance information corresponding to the target instance can be determined, such as the storage location of the instance, the number of connections, the subscript of the array cell where it is located, etc. Then, based on the obtained instance information, the specific position of the target instance in the next array cell adjacent to the target cell can be further located. After determining the position, it is judged whether the target instance is at the end position of the array cell. If the target instance is exactly at the end position, the instance can be directly deleted from the array cell to implement the release operation. If the target instance is not at the end position, a coverage strategy can be adopted, that is, the data of another candidate instance at the end position of the array cell is overwritten to the position of the target instance, thereby completing the release of the target instance, and finally deleting the candidate instance at the end. In this way, the target instance can be efficiently removed without destroying the overall ordered structure of the array cell, and the operation time complexity is O(1). For a high-concurrency scenario with a large number of instances, it can reduce the memory operation and the computing overhead of the central processing unit, which is beneficial to maintaining the high performance of the execution entity of the embodiment of the present invention.
[0064] Exemplarily, assume that the array cell with subscript 1 contains candidate instances A, B, and C, and the arrangement order is A, B, C in sequence. When the target instance is candidate instance B, first, the position of instance B in the array cell is located as the middle position through the identification information. Since instance B is not at the end, a coverage operation is required. Specifically, the instance information of the candidate instance C at the end can be overwritten to the position of candidate instance B, so that the position where instance B originally was becomes the information of instance C, and then the instance C at the end position is deleted to complete the release of the target instance B. If the target instance was originally at the end, for example, the target instance is C, then C can be directly deleted without overwriting other instances.
[0065] According to the second aspect of the embodiments of the present invention, as Figure 3 shown, a request processing device 300 is provided, including:
[0066] A selection module 301, configured to select the array cell with the smallest subscript as the target cell from the array cells containing candidate instances in response to receiving a request; the subscript of the array cell represents the number of connections corresponding to the candidate instance in the array cell;
[0067] A determination module 302, configured to determine a target instance for distributing the request from the candidate instances in the target cell;
[0068] A moving module 303, configured to move the target instance from the target cell to the next array cell adjacent to the target cell and distribute the request through the target instance.
[0069] Optionally, the apparatus further includes a creation module 304; specifically, the creation module 304 is configured to:
[0070] Create a connection count array; the number of array elements in the connection count array is determined based on the maximum connection count of the candidate instances; the subscript of the array elements in the connection count array starts from 0 and increases incrementally;
[0071] In response to the completion of the creation of the connection count array, place each candidate instance into the first array element of the connection count array for request distribution.
[0072] Optionally, the selection module 301 is further configured to:
[0073] Determine whether the array element with the smallest subscript in the array element containing the candidate instance is the array element with the largest subscript in the connection count array;
[0074] In response to the array element with the smallest subscript in the array element of the candidate instance not being the array element with the largest subscript in the connection count array, determine a target instance for request distribution from the candidate instances in the target cell;
[0075] In response to the array element with the smallest subscript in the array element of the candidate instance being the array element with the largest subscript in the connection count array, return a request distribution failure message to the request initiator.
[0076] Optionally, the moving module 303 is specifically configured to:
[0077] Add the target instance to the end of the candidate instances already existing in the next array element adjacent to the target cell.
[0078] Optionally, the moving module 303 is further configured to:
[0079] In response to the completion of request distribution, release the target instance from the next array element adjacent to the target cell and move the target instance to the target cell.
[0080] Optionally, the moving module 303 is specifically configured to:
[0081] Determine the instance information of the target instance based on the identifier of the target instance;
[0082] Determine the position of the target instance in the next array element adjacent to the target cell based on the instance information;
[0083] In response to the position of the target instance in the next array element adjacent to the target cell being the end, delete the target instance from the next array element adjacent to the target cell;
[0084] In response to the position of the target instance not being at the end in the next array cell adjacent to the target cell, overwrite the target instance with the candidate instance at the end in the next array cell adjacent to the target cell, and delete the candidate instance at the end in the next array cell adjacent to the target cell.
[0085] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for request processing, including: one or more processors; a storage device for storing one or more programs, which when executed by the one or more processors cause the one or more processors to implement the method provided in the first aspect of the embodiment of the present invention.
[0086] According to a fourth aspect of an embodiment of the present invention, there is provided a computer-readable medium having a computer program stored thereon, and when the program is executed by a processor, the method provided in the first aspect of the embodiment of the present invention is implemented.
[0087] According to a fifth aspect of an embodiment of the present invention, there is provided a computer program product including a computer program, and when the computer program is executed by a processor, the method of any of the above embodiments is implemented.
[0088] Figure 4 An exemplary system architecture 400 to which the request processing method or request processing apparatus according to the present invention can be applied is shown.
[0089] As Figure 4 shown, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 is used to provide a medium for communication links between the terminal devices 401, 402, 403 and the server 405. The network 404 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0090] Users can use the terminal devices 401, 402, 403 to interact with the server 405 through the network 404 to receive or send messages, etc. Various communication client applications may be installed on the terminal devices 401, 402, 403, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0091] The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, and desktop computers, etc.
[0092] The server 405 can be a server that provides various services. For example, it can be a back-end management server (only an example) that supports shopping websites browsed by users using the terminal devices 401, 402, and 403. The back-end management server can process the requests received and feedback the processing results (only an example) to the terminal devices.
[0093] It should be noted that the method for request processing provided by the embodiments of the present invention is generally executed by the server 405. Correspondingly, the request processing device is generally set in the server 405. The method for request processing provided by the embodiments of the present invention can also be executed by the terminal devices 401, 402, and 403. Correspondingly, the request processing device can be set in the terminal devices 401, 402, and 403.
[0094] It should be understood that Figure 4 the numbers of the terminal devices, networks, and servers in
[0095] are merely illustrative. According to the implementation requirements, there can be any number of terminal devices, networks, and servers. Figure 5 Next, refer to Figure 5 which shows a schematic structural diagram of a computer system 500 of a terminal device suitable for implementing the embodiments of the present invention. Figure 5 The terminal device shown is only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present invention.
[0096] As Figure 5 shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to the programs stored in the read-only memory (ROM) 502 or the programs loaded from the storage section 508 into the random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. The input / output (I / O) interface 505 is also connected to the bus 504.
[0097] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including, for example, a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. The drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed so that the computer program read from it can be installed into the storage section 508 as needed.
[0098] In particular, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes program code for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-described functions defined in the system of the present invention are performed.
[0099] It should be noted that the computer-readable medium shown in the present invention can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. And in the present invention, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries the computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0100] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code, and the above-mentioned module, segment of a program, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, as well as combinations of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0101] The modules described in the embodiments of the present invention can be implemented in software or in hardware. The described modules can also be provided in a processor. For example, a processor includes a selection module, a determination module, and a movement module. In some cases, the names of these modules do not constitute a limitation on the module itself. For example, the selection module can also be described as "responding to a received request, selecting the array unit with the smallest subscript from the array units containing candidate instances as the target unit module".
[0102] As another aspect, the present invention also provides a computer-readable medium, which can be included in the device described in the above embodiments; or can exist separately and not be assembled into the device. The above computer-readable medium carries one or more programs. When the one or more programs are executed by the device, the device implements the following method: responding to a received request, selecting the array unit with the smallest subscript from the array units containing candidate instances as the target unit; the subscript of the array unit represents the number of connections corresponding to the candidate instance in the array unit; determining a target instance for distributing the request from the candidate instances in the target unit; moving the target instance from the target unit to the next adjacent array unit of the target unit, and distributing the request through the target instance.
[0103] Finally, it should be noted that the above embodiments are only specific implementation manners of the present invention, used to illustrate the technical solutions of the present invention, rather than limiting it. The protection scope of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that any person skilled in the technical field of the present invention can still modify the technical solutions described in the foregoing embodiments, or can easily think of changes, or perform equivalent replacements on some of the technical features; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A request processing method, characterized in that, including: Upon receiving a request, selecting, from array cells containing candidate instances, the array cell with the smallest subscript as the target cell; the subscript of the array cell represents the number of connections corresponding to the candidate instance in the array cell; determining, from the candidate instances in the target cell, a target instance for distributing the request; moving the target instance from the target cell to the next adjacent array cell and distributing the request through the target instance.
2. The method according to claim 1, characterized in that, Before selecting, upon receiving a request, from array cells containing candidate instances, the array cell with the smallest subscript as the target cell, further including: creating a connection number array; the number of array cells in the connection number array is determined based on the maximum connection number of candidate instances; the subscripts of the array cells in the connection number array start incrementing from 0; upon completion of creating the connection number array, putting each candidate instance into the first array cell of the connection number array for request distribution.
3. The method according to claim 1 or 2, characterized in that, After receiving the request, further including: judging whether the array cell with the smallest subscript in the array cells containing candidate instances is the array cell with the largest subscript in the connection number array; upon the array cell with the smallest subscript in the array cells of candidate instances not being the array cell with the largest subscript in the connection number array, determining, from the candidate instances in the target cell, a target instance for distributing the request; upon the array cell with the smallest subscript in the array cells of candidate instances being the array cell with the largest subscript in the connection number array, returning a request distribution failure message to the request initiator.
4. The method according to claim 1, characterized in that, Moving the target instance from the target cell to the next adjacent array cell includes: adding the target instance to the end of the existing candidate instances in the next adjacent array cell to the target cell.
5. The method according to claim 1, characterized in that After distributing the request through the target instance, further including: upon completion of request distribution, releasing the target instance from the next adjacent array cell to the target cell and moving the target instance to the target cell.
6. The method according to claim 5, characterized in that, Releasing the target instance from the next adjacent array cell to the target cell includes: determining the instance information of the target instance based on the identifier of the target instance; determining the position of the target instance in the next adjacent array cell to the target cell based on the instance information; upon the position of the target instance in the next adjacent array cell to the target cell being at the end, deleting the target instance from the next adjacent array cell to the target cell; upon the position of the target instance in the next adjacent array cell to the target cell not being at the end, overwriting the target instance with the candidate instance at the end in the next adjacent array cell to the target cell and deleting the candidate instance at the end in the next adjacent array cell to the target cell.
7. A request processing device, characterized in that, including: a selection module for selecting, upon receiving a request, from array cells containing candidate instances, the array cell with the smallest subscript as the target cell; the subscript of the array cell represents the number of connections corresponding to the candidate instance in the array cell; A determination module, configured to determine a target instance for distributing a request from each candidate instance in a target unit; A moving module, configured to move the target instance from the target unit to the next array unit adjacent to the target unit, and distribute the request through the target instance.
8. An electronic device, characterized in that, Comprising: One or more processors; A storage device, configured to store one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-6.
9. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, the method according to any one of claims 1-6 is implemented.
10. A computer program product, comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-6.