Load balancing method, device, equipment, medium and program product
By generating candidate server sequences in a distributed system and allocating servers according to the number of requests, the problem of unbalanced load processing in the prior art is solved, and more efficient resource utilization and system performance improvement is achieved.
Patent Information
- Application Number
- CN202411687829.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-02-25
AI Technical Summary
In the distributed system, the load processing between the server and the client is unbalanced, resulting in some servers being overloaded while other servers being idle, resulting in waste of resources and instability of the system.
By receiving the client's request, a candidate server sequence carrying the target request identification is generated, and the target server is allocated in the sequence according to the target number to achieve load balancing.
It realizes balanced allocation of client requests, avoids overloading of a single server, and improves the overall performance and throughput of distributed systems.
Smart Images

Figure CN119520529A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a load balancing method, device, equipment, medium and program product. Background Art
[0002] For a distributed system with multiple clients and multiple servers, it is extremely important to load-balance computing resources among multiple servers to handle all transaction requests and to send all messages from clients to each server for processing in the best way possible.
[0003] In the prior art, when registering a request message on the server side, all servers register the same request message. When the client side publishes a request message, all servers will receive the request and make a judgment to see who can "grab" it faster. Whoever can grab the opportunity to process it will get the chance. In this way, some servers may always "grab" the opportunity to process the request due to configuration or network reasons, causing the load pressure to be too concentrated and increasing the risk of system instability, while other servers will always fail to "grab" the opportunity, resulting in a waste of server resources and uneven load processing. Summary of the invention
[0004] The technical solution of the present invention aims to provide a load balancing method, device, equipment, medium and program product to solve the problem of how to achieve load balancing between the service end and the client end of each server in a distributed system in the prior art.
[0005] To achieve the above object, the present invention is achieved by:
[0006] In a first aspect, an embodiment of the present invention provides a load balancing method, comprising:
[0007] Receive a first request sent by a client, where the first request is used to request allocation of a server, and the first request carries a target request identifier;
[0008] Generate a candidate server sequence according to the target request identifier, wherein a subscription request corresponding to each candidate server in the candidate server sequence carries the target request identifier;
[0009] According to the target number, a corresponding target server is allocated to the first request in the candidate server sequence, the target number being the number of target requests currently received from at least one client, the target request carrying the target request identifier.
[0010] Optionally, the load balancing method further comprises:
[0011] Generate a second request according to the target request identifier and the server identifier of the target server, wherein the second request is used to request the target server to respond;
[0012] Send the second request to the target server.
[0013] Optionally, the load balancing method, wherein generating a candidate server sequence according to the target request identifier, includes:
[0014] In a preset data storage system, obtaining a candidate server whose subscription request carries the target request identifier;
[0015] Generate a candidate server sequence including the candidate server.
[0016] Optionally, in the load balancing method, before obtaining the candidate server carrying the request identifier in the subscription request, the method further comprises:
[0017] Receive a subscription request sent by a server, wherein the subscription request carries a server identifier and a request identifier;
[0018] In the preset data storage system, the subscription request corresponding to the server is stored.
[0019] Optionally, in the load balancing method, when storing the subscription request corresponding to the server, the method further comprises:
[0020] Set the effective duration corresponding to the server;
[0021] Generating a candidate server sequence including the candidate server comprises:
[0022] Within the valid time period corresponding to the candidate server, a candidate server sequence including the candidate server is generated.
[0023] Optionally, the load balancing method, wherein, according to the target number, allocating a corresponding target server to the first request in the candidate server sequence comprises:
[0024] Determine the target position according to the remainder of dividing the target number by the length of the candidate server sequence;
[0025] Acquire a target server at the target position in the candidate server sequence;
[0026] The target server is allocated to the first request.
[0027] Optionally, in the load balancing method, the position of the candidate server in the candidate server sequence is related to the subscription order of the candidate server.
[0028] In a second aspect, an embodiment of the present invention further provides a load balancing device, comprising:
[0029] A first receiving module, configured to receive a first request sent by a client, wherein the first request is used to request allocation of a server, and the first request carries a target request identifier;
[0030] A first generating module is used to generate a candidate server sequence according to the target request identifier, wherein a subscription request corresponding to each candidate server in the candidate server sequence carries the target request identifier;
[0031] An allocation module is used to allocate a corresponding target server for the first request in the candidate server sequence according to a target number of times, wherein the target number of times is the number of target requests currently received from at least one client, and the target request carries the target request identifier.
[0032] In a third aspect, an embodiment of the present invention further provides a load balancing device, comprising: a processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the load balancing method as described in the first aspect is implemented.
[0033] In a fourth aspect, an embodiment of the present invention further provides a readable storage medium, on which a program is stored, and when the program is executed by a processor, the load balancing method as described in the first aspect is implemented.
[0034] In a fifth aspect, an embodiment of the present invention further provides a computer program product, comprising computer instructions, which, when executed by a processor, implement the load balancing method as described in the first aspect.
[0035] The beneficial effects of the above technical solution of the present invention are as follows:
[0036] In an embodiment of the present invention, a first request sent by a client is received, the first request is used to request the allocation of a server, and the first request carries a target request identifier; based on the target request identifier, a candidate server sequence is generated, and the subscription request corresponding to each candidate server in the candidate server sequence carries the target request identifier; based on the target number of times, a corresponding target server is allocated to the first request in the candidate server sequence, the target number of times is the number of target requests currently received from at least one client, and the target request carries the target request identifier. In this way, the server will be evenly allocated to the client's requests based on the number of requests carrying the target request identifier, avoiding overloading of a single server, achieving a load balancing effect, and improving the overall performance and throughput of the distributed system. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A schematic diagram of an application system architecture of a load balancing method according to an embodiment of the present invention;
[0038] Figure 2 A schematic diagram of a load balancing method according to an embodiment of the present invention;
[0039] Figure 3 A schematic diagram of a flow chart of one implementation of the load balancing method according to an embodiment of the present invention;
[0040] Figure 4 A flow chart of another implementation of the load balancing method according to an embodiment of the present invention;
[0041] Figure 5 A flow chart of another implementation of the load balancing method according to an embodiment of the present invention;
[0042] Figure 6 A schematic diagram of the software architecture of the converged communication platform according to an embodiment of the present invention;
[0043] Figure 7 This is a schematic diagram of the structure of the load balancing device according to an embodiment of the present invention;
[0044] Figure 8 The figure is a hardware block diagram of the load balancing device described in the embodiment of the present invention. DETAILED DESCRIPTION
[0045] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0046] In various embodiments of the present invention, it should be understood that the size of the serial numbers of the following processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0047] Additionally, the terms "system" and "network" are often used interchangeably herein.
[0048] The terms "first", "second", etc. in the specification and claims of the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first" and "second" are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0049] When describing the embodiments of the present invention, some concepts used in the following description are first explained.
[0050] Load Balancing is a technology that distributes workloads (such as network traffic, data requests, computing tasks, etc.) to multiple computing resources (such as servers, virtual machines, containers, etc.) in order to optimize performance, improve reliability, and increase scalability.
[0051] A distributed system is a system consisting of multiple computers connected by a network, each running its own process and communicating and coordinating through message passing. A distributed system aims to split a large problem into multiple small problems, solve them one by one, and finally work together to complete a specific task.
[0052] Redis, an open source, memory-based structured data storage medium, can be used as a database, cache service or message service. Redis uses memory to store data, supports a variety of data structures, such as strings, lists, sets, etc., and has fast data reading and writing speeds and rich features.
[0053] Redis Publish / Subscribe (Pub / Sub) is a messaging mechanism provided by Redis that uses the "Publisher-Subscriber" model to handle messaging. In this model, the publisher publishes messages to a group of subscribers without caring about who the subscribers are or whether the subscribers have received the message. The publisher and subscriber model allows a complex communication topology to be established between multiple clients. In this model, the publisher can publish messages to a specific topic, and the subscriber can subscribe to one or more topics and receive messages when the publisher publishes a message. Since the publisher and subscriber do not have to be connected directly, the publisher and subscriber can run completely independently as long as they are both connected to the Redis instance. Therefore, Redis's publish / subscribe function can be used to build distributed applications.
[0054] The application system architecture of the load balancing method described in the embodiment of the present invention is as follows: Figure 1 As shown, the application system is a distributed system, including a basic communication module, Redis, multiple client terminals and multiple server terminals; wherein, the basic communication module realizes the sending of requests, receiving of responses and receiving of notification information between modules based on the publishing and subscription message communication mechanism of Redis and the access of key values; the server terminal quotes the subscription request of the basic communication module, can receive the request sent by the client and respond; the client terminal quotes the publishing message of the basic communication module, sends the message to the server terminal, and waits for the response message of the server terminal.
[0055] It should be noted that the above-mentioned basic communication module can be understood as a load balancing device in the embodiment of the present invention.
[0056] like Figure 2 As shown, an embodiment of the present invention provides a load balancing method, including:
[0057] S201, receiving a first request sent by a client, where the first request is used to request allocation of a server, and the first request carries a target request identifier.
[0058] In the embodiment of the present invention, the load balancing method can be applied to the above-mentioned basic communication module. The client invokes the sending request function of the basic communication module to send a first request, and the basic communication module receives the first request sent by the client.
[0059] S202: Generate a candidate server sequence according to the target request identifier, wherein a subscription request corresponding to each candidate server in the candidate server sequence carries the target request identifier.
[0060] In an embodiment of the present invention, the server calls the subscription request function of the basic communication module, and each candidate server in the candidate server sequence carries the target request identifier and the server identifier of the candidate server in the subscription request when making a subscription request, so that the candidate server can receive the first request sent by the client carrying the target request identifier.
[0061] S203, assigning a corresponding target server to the first request in the candidate server sequence according to a target number, wherein the target number is the number of target requests currently received from at least one client, and the target request carries the target request identifier.
[0062] In an embodiment of the present invention, the basic communication module can assign a corresponding target server to the first request in the candidate server sequence according to the number of all target requests currently received that carry the target request identifier, thereby achieving balanced load distribution, avoiding excessive load on a single server, and making full use of server resources.
[0063] In one embodiment, optionally, the method further comprises:
[0064] Generate a second request according to the target request identifier and the server identifier of the target server, wherein the second request is used to request the target server to respond;
[0065] Send the second request to the target server.
[0066] In an embodiment of the present invention, a second request is generated according to the target request identifier and the server identifier of the target server, that is, the second request includes the target request identifier and the server identifier of the target server, and the second request is published. Since the target server has carried the target request identifier in the subscription request when subscribing, the target server will receive the second request and return a response result.
[0067] In one implementation mode, optionally, S202, generating a candidate server sequence according to the target request identifier includes:
[0068] In a preset data storage system, obtaining a candidate server whose subscription request carries the target request identifier;
[0069] Generate a candidate server sequence including the candidate server.
[0070] It should be noted that the preset data storage system is Redis. When the candidate server sends a subscription request, it sends a subscription request to the basic communication module. The basic communication module stores the subscription request corresponding to the candidate server in Redis, that is, stores the server identifier and target request identifier corresponding to the candidate server.
[0071] In this way, the basic communication module can obtain all candidate servers whose subscription requests carry the target request identifier in Redis, and then generate a candidate server sequence.
[0072] In one implementation manner, optionally, before obtaining the candidate server carrying the request identifier in the subscription request, the method further includes:
[0073] Receive a subscription request sent by a server, wherein the subscription request carries a server identifier and a request identifier;
[0074] In the preset data storage system, the subscription request corresponding to the server is stored.
[0075] It should be noted that when each server makes a subscription request, it will send a subscription request to the basic communication module, and the subscription request carries a server identifier and a request identifier. Furthermore, the basic communication module stores the subscription request corresponding to each server in the preset data storage system.
[0076] Figure 3 The following is a flow chart of one implementation of the load balancing method according to an embodiment of the present invention. The implementation includes the following steps:
[0077] S301, the server sends a subscription request carrying a request identifier and a server identifier.
[0078] S302, the request identifier and server identifier of the Redis storage service.
[0079] In one implementation manner, optionally, in the case of storing a subscription request corresponding to the server, the method further includes:
[0080] Set the effective duration corresponding to the server;
[0081] Generating a candidate server sequence including the candidate server comprises:
[0082] Within the valid time period corresponding to the candidate server, a candidate server sequence including the candidate server is generated.
[0083] It should be noted that the basic communication module stores the server identifier and request identifier corresponding to each server in the preset data storage system, and sets the validity period corresponding to each candidate server.
[0084] Thus, when generating a candidate server sequence, it is necessary to select candidate servers within the effective time to generate the candidate server sequence.
[0085] In one implementation mode, optionally, S203, allocating a corresponding target server for the first request in the candidate server sequence according to the target number of times, includes:
[0086] Determine the target position according to the remainder of dividing the target number by the length of the candidate server sequence;
[0087] Acquire a target server at the target position in the candidate server sequence;
[0088] The target server is allocated to the first request.
[0089] It should be noted that each time the basic communication module receives a request sent by the client, it obtains the number of request identifiers carried in the request.
[0090] In an embodiment of the present invention, a target position is determined according to a remainder obtained by dividing a target number of times by a length of the candidate server sequence, a target server at the target position is obtained in the candidate server sequence, and the first request is assigned to the target server. Exemplarily, if the remainder is 1, the target position is the first position, and the target server is the candidate server at the first position in the candidate server sequence.
[0091] It should also be noted that each time the embodiment of the present invention allocates a corresponding server to a client, the current target number will be increased by 1, and the remainder of the target number and the length of the candidate server sequence will also be increased by 1 each time. Therefore, each server in the preset data storage system is taken in sequence, and finally according to this logic, each request will be sequentially handed over to the next server for processing, realizing full polling processing of requests and realizing a completely evenly distributed load method.
[0092] Optionally, the position of the candidate server in the candidate server sequence is related to the subscription order of the candidate server.
[0093] It should be noted that the subscription order is the order in which the candidate server sends subscription requests to the basic communication module.
[0094] Figure 4 This is a flow chart of another implementation of the load balancing method according to an embodiment of the present invention. In this implementation, the method includes the following steps:
[0095] S401, the client sends a first request carrying a target request identifier.
[0096] S402, in Redis, obtaining a candidate server with a target request identifier carried in the subscription request, and generating a candidate server sequence.
[0097] S403: Obtain the number of all currently received target requests carrying the target request identifier.
[0098] S404, according to the remainder obtained by dividing the target number of times by the length of the candidate server sequence, obtaining the target server in the candidate server sequence that is at a position corresponding to the remainder.
[0099] S405: Send a second request carrying a target request identifier and a server identifier of the target server to the target server.
[0100] S406, the target server receives the second request, processes it, and returns a response result.
[0101] In addition, if the server needs to exit Figure 1 If the server cluster in the server n is no longer providing services to the client, the validity period corresponding to server n will expire, Redis will no longer store the subscription request corresponding to server n, and the basic communication module will not include server n in the candidate server sequence.
[0102] Figure 5 This is a flow chart of another implementation of the load balancing method according to an embodiment of the present invention. In this implementation, the method includes the following steps:
[0103] S501, obtaining service stop information of server n.
[0104] S502: The validity period corresponding to the server n expires, and the request identifier and server identifier of the server n are deleted.
[0105] S503: When generating a candidate server sequence, server n is no longer included.
[0106] Figure 6 The software architecture diagram of the converged communication platform of the embodiment of the present invention. The converged communication platform is positioned to provide professional call center services for various enterprises, and realizes various functions of the traditional call center. The converged communication platform is the basic functional module for executing the load balancing method described in the embodiment of the present invention. It mainly performs a series of processing functions on calls, including CTI function, call processing (basic call function, advanced call function), WEB customer service function, platform maintenance function (queue management, IVR management, routing strategy management, voice file management, etc.). It is a full-featured call center platform. With the increase in the call business volume of enterprises, the converged communication platform is improved to a cluster deployment architecture, and focuses on improving the high concurrent processing capability of call traffic.
[0107] like Figure 6 As shown, the converged communication platform includes multiple vcc server clusters, each vcc server includes vcc2web, vcc2, and vcc2switch services, vcc2web implements the enterprise management end and the agent application end, vcc2 implements CTI traffic control processing, and vcc2switch implements the access control function of Freeswitch soft switch. vcc2core is a basic communication package, and vcc2core is used for the message subscription and publishing mechanism in the embodiment of the present invention. There is message request sending and response interaction between the modules of vcc2web, vcc2, and vcc2switch. After the three functional modules are introduced into vcc2core, the request sending and response are performed through the message interaction mechanism implemented by vcc2core.
[0108] Next, taking the operation of an agent logging into a session bar as an example, the load balancing method described in the embodiment of the present invention is applied, including the following steps:
[0109] The vcc2 module of each vcc server registers the login request;
[0110] When the agent clicks the login button, nginx will distribute the operation to the vcc2web service of one of the vccs for processing, such as the vcc2-1 server.
[0111] The vcc2web module of the vcc2-1 server sends a login request through vcc2core.
[0112] vcc2core searches for the registration server and, through the above load balancing method, selects the vcc2 module of the vcc2-2 server to process this request.
[0113] The vcc2 module of the vcc2-2 server receives the login request.
[0114] The vcc2 module of the vcc2-2 server performs operations such as recording the agent's login operation in the database, recording the login status in Redis, and recording the agent status in the queue, and returns the login result to the vcc2web service of the vcc2-1 server;
[0115] The vcc2web service of the vcc2-1 server pushes the results to the agent browser, and the agent can see the result of successful agent login.
[0116] When all enterprise seats log in, the login request is processed by the vcc2 module in each server of the vcc cluster 1...n, so that the overall concurrency performance provided is better.
[0117] In summary, by adopting the load balancing method described in the embodiment of the present invention, based on the message publishing and subscription mechanism of Redis, the client's requests are evenly distributed to the server, so as to avoid uneven distribution of requests and realize balanced request polling processing among multiple servers in the distributed system, which significantly improves the system performance, reliability, scalability and resource utilization, and saves bandwidth.
[0118] like Figure 7 As shown, an embodiment of the present invention further provides a load balancing device, including:
[0119] A first receiving module 701 is used to receive a first request sent by a client, where the first request is used to request allocation of a server, and the first request carries a target request identifier;
[0120] A first generating module 702 is configured to generate a candidate server sequence according to the target request identifier, wherein a subscription request corresponding to each candidate server in the candidate server sequence carries the target request identifier;
[0121] The allocation module 703 is used to allocate the corresponding target server for the first request in the candidate server sequence according to the target number, wherein the target number is the number of target requests sent by at least one client currently received, and the target request carries the target request identifier.
[0122] Optionally, the load balancing device further comprises:
[0123] A second generating module, used to generate a second request according to the target request identifier and the server identifier of the target server, wherein the second request is used to request the target server to respond;
[0124] The first sending module is used to send the second request to the target server.
[0125] Optionally, in the load balancing device, the first generating module 702 is specifically configured to:
[0126] In a preset data storage system, obtaining a candidate server whose subscription request carries the target request identifier;
[0127] Generate a candidate server sequence including the candidate server.
[0128] Optionally, the load balancing device further comprises:
[0129] A second receiving module, configured to receive a subscription request sent by a server, wherein the subscription request carries a server identifier and a request identifier;
[0130] The storage module is used to store the subscription request corresponding to the server in the preset data storage system.
[0131] Optionally, the load balancing device further comprises:
[0132] A setting module, used to set the effective time corresponding to the server;
[0133] The first generating module 702 is specifically configured to:
[0134] Within the valid time period corresponding to the candidate server, a candidate server sequence including the candidate server is generated.
[0135] Optionally, in the load balancing device, the allocation module 703 is specifically configured to:
[0136] Determine the target position according to the remainder of dividing the target number by the length of the candidate server sequence;
[0137] Acquire a target server at the target position in the candidate server sequence;
[0138] The target server is allocated to the first request.
[0139] Optionally, in the load balancing device, the position of the candidate server in the candidate server sequence is related to the subscription order of the candidate server.
[0140] It should be noted that the load balancing device provided in the embodiment of the present invention is a device capable of executing the above-mentioned load balancing method, and all embodiments of the above-mentioned load balancing method are applicable to the device and can achieve the same or similar technical effects.
[0141] like Figure 8 As shown, an embodiment of the present invention also provides a load balancing device, including: a processor 801; and a memory 802 connected to the processor 801 through a bus interface, the memory 802 is used to store programs and data used by the processor 801 when performing operations, and the processor 801 calls and executes the programs and data stored in the memory 802.
[0142] The load balancing device further includes a transceiver 803, which is used to perform the following processes under the control of the processor 801:
[0143] Receive a first request sent by a client, where the first request is used to request allocation of a server, and the first request carries a target request identifier;
[0144] The processor 801 is used to read the program in the memory 802 and execute the following process:
[0145] Generate a candidate server sequence according to the target request identifier, wherein a subscription request corresponding to each candidate server in the candidate server sequence carries the target request identifier;
[0146] According to the target number, a corresponding target server is allocated to the first request in the candidate server sequence, the target number being the number of target requests currently received from at least one client, the target request carrying the target request identifier.
[0147] Among them, Figure 8In the embodiment, the bus architecture may include any number of interconnected buses and bridges, specifically one or more processors represented by processor 801 and various circuits of memory represented by memory 802 are linked together. The bus architecture may also link together various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface. The transceiver 803 may be a plurality of components, namely, a transmitter and a transceiver, providing a unit for communicating with various other devices on a transmission medium. For different user devices, the user interface 804 may also be an interface capable of externally and internally connecting required devices, and the connected devices include but are not limited to a keypad, a display, a speaker, a microphone, a joystick, and the like.
[0148] The processor 801 is responsible for managing the bus architecture and general processing, and the memory 802 can store data used by the processor 501 when performing operations.
[0149] Optionally, the processor 801 is further configured to read a program and execute the following steps:
[0150] Generate a second request according to the target request identifier and the server identifier of the target server, wherein the second request is used to request the target server to respond;
[0151] The transceiver 803 is further configured to, under the control of the processor 801, execute the following steps:
[0152] Send the second request to the target server.
[0153] Optionally, the processor 801 is specifically configured to read a program and execute the following steps:
[0154] In a preset data storage system, obtaining a candidate server whose subscription request carries the target request identifier;
[0155] Generate a candidate server sequence including the candidate server.
[0156] The transceiver 803 is further configured to, under the control of the processor 801, execute the following steps:
[0157] Receive a subscription request sent by a server, wherein the subscription request carries a server identifier and a request identifier;
[0158] Optionally, the processor 801 is further configured to read a program and execute the following steps:
[0159] In the preset data storage system, the subscription request corresponding to the server is stored.
[0160] Optionally, the processor 801 is specifically configured to read a program and execute the following steps:
[0161] Set the effective duration corresponding to the server;
[0162] Within the valid time period corresponding to the candidate server, a candidate server sequence including the candidate server is generated.
[0163] Optionally, the processor 801 is specifically configured to read a program and execute the following steps:
[0164] Determine the target position according to the remainder of dividing the target number by the length of the candidate server sequence;
[0165] Acquire a target server at the target position in the candidate server sequence;
[0166] The target server is allocated to the first request.
[0167] Optionally, the position of the candidate server in the candidate server sequence is related to the subscription order of the candidate server.
[0168] A specific embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps in the above-mentioned load balancing method are implemented and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0169] In addition, an embodiment of the present invention further provides a computer program product, including computer instructions, which, when executed by a processor, implement the above Figure 2 The various processes of the method embodiment shown can achieve the same technical effect, and will not be described again here to avoid repetition.
[0170] In the several embodiments provided by the present invention, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0171] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0172] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform some steps of the sending and receiving methods described in various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.
[0173] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A load balancing method, characterized in that: include: Receive a first request sent by a client, where the first request is used to request allocation of a server, and the first request carries a target request identifier; Generate a candidate server sequence according to the target request identifier, wherein a subscription request corresponding to each candidate server in the candidate server sequence carries the target request identifier; According to the target number, a corresponding target server is allocated to the first request in the candidate server sequence, the target number being the number of target requests currently received from at least one client, the target request carrying the target request identifier.
2. The load balancing method according to claim 1, characterized in that: The method further comprises: Generate a second request according to the target request identifier and the server identifier of the target server, wherein the second request is used to request the target server to respond; Send the second request to the target server.
3. The load balancing method according to claim 1, characterized in that: Generate a candidate server sequence according to the target request identifier, including: In a preset data storage system, obtaining a candidate server whose subscription request carries the target request identifier; Generate a candidate server sequence including the candidate server.
4. The load balancing method according to claim 3, characterized in that: Before obtaining the candidate server that the subscription request carries the request identifier, the method further includes: Receive a subscription request sent by a server, wherein the subscription request carries a server identifier and a request identifier; In the preset data storage system, the subscription request corresponding to the server is stored.
5. The load balancing method according to claim 4, characterized in that: In the case of storing the subscription request corresponding to the server, the method further includes: Set the effective duration corresponding to the server; Generating a candidate server sequence including the candidate server comprises: Within the valid time period corresponding to the candidate server, a candidate server sequence including the candidate server is generated.
6. The load balancing method according to claim 1, characterized in that: Allocating a corresponding target server for the first request in the candidate server sequence according to the target number of times includes: Determine the target position according to the remainder of dividing the target number by the length of the candidate server sequence; Acquire a target server at the target position in the candidate server sequence; The target server is allocated to the first request.
7. The load balancing method according to claim 6, characterized in that: The position of the candidate server in the candidate server sequence is related to the subscription order of the candidate server.
8. A load balancing device, characterized in that: include: A first receiving module, configured to receive a first request sent by a client, wherein the first request is used to request allocation of a server, and the first request carries a target request identifier; A first generating module is used to generate a candidate server sequence according to the target request identifier, wherein a subscription request corresponding to each candidate server in the candidate server sequence carries the target request identifier; An allocation module is used to allocate a corresponding target server for the first request in the candidate server sequence according to a target number of times, wherein the target number of times is the number of target requests currently received from at least one client, and the target request carries the target request identifier.
9. A load balancing device, characterized in that: include: A processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the load balancing method according to any one of claims 1 to 7 is implemented.
10. A readable storage medium, characterized in that: The readable storage medium stores a program, and when the program is executed by a processor, the load balancing method according to any one of claims 1 to 7 is implemented.
11. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the load balancing method according to any one of claims 1 to 7.