Load balancing method and related equipment

By receiving HTTP requests from user equipment and redirecting based on load status, the problem of load imbalance in multi-partition environment is solved, and automatic load balancing and stability improvement is achieved.

CN113407332BActive Publication Date: 2025-04-18TENCENT CLOUD COMPUTING (CHANGSHA) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202011412143.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-03
Publication Date
2025-04-18
Estimated Expiration
2040-12-03

AI Technical Summary

Technical Problem

The prior art is difficult to achieve balanced distribution of server load in a multi-partition environment, resulting in poor user experience and unbalanced server pressure.

Method used

Automatic load balancing is achieved by receiving the target service request sent by the user equipment based on the HTTP protocol, and processing the request or redirecting to a lighter-load partition server based on the current load state, using the redirection capability of the HTTP protocol to achieve automatic load balancing.

Benefits of technology

It realizes that the user group is automatically divided into servers without the need for users to select partitions, reducing the implementation complexity, improving operational stability, and achieving the effect of server load balancing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113407332B_ABST
    Figure CN113407332B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of cloud computing, and provides a load balancing method and related equipment, the load balancing method comprising: receiving a target service request sent by a user device based on the HTTP protocol; processing the target service request or redirecting a partition server based on the HTTP protocol based on the current load status; if the partition server is redirected based on the HTTP protocol, feeding back corresponding redirection information so that the user device sends the target service request based on the redirection information. The implementation of the present application achieves the effect of automatically partitioning and serving user groups by utilizing the load capacity of its service that the server can obtain and the redirection capacity of the HTTP protocol, while reducing the complexity of implementation and improving the stability of operation without requiring the user to select a partition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud computing technology, and in particular to a load balancing method and related equipment. Background Art

[0002] Many services implemented on the Internet cannot support unlimited expansion of the user scale due to the limitations of their service characteristics. For example, when there are a large number of online players in large-scale games, a single server cannot support all service requests. It is necessary to set up multiple partitions for operation, divide the overall users, and use servers in different partitions to provide services to effectively share the pressure on the server.

[0003] In the prior art, when multiple partitions are set, users are generally asked to actively select a partition or rely on a real-time online crowd counting system to perform crowd counting to perform user partitioning. However, if users actively select a partition, not only will the user experience be poor, but the load of each partition server will also be unbalanced; if the system is relied upon to perform user partitioning based on real-time online crowd counting, although it is relatively user-friendly, the implementation is complex, and it is prone to failures due to the operation of the system, and the operational stability is low. Summary of the invention

[0004] The present application provides a load balancing method and related devices, which can solve at least one of the above technical problems. The technical solution is as follows:

[0005] In a first aspect, a load balancing method is provided, which is applied to a current partition server, and includes: receiving a target service request sent by a user device based on an HTTP protocol;

[0006] Based on the current load status, process the target service request or redirect the partition server based on the HTTP protocol;

[0007] If the partition server is redirected based on the HTTP protocol, corresponding redirection information is fed back so that the user equipment sends the target service request based on the redirection information.

[0008] In combination with the first aspect, in a first implementation of the first aspect, processing the target service request based on the current load state or redirecting the partition server based on the HTTP protocol includes any of the following:

[0009] Acquire current information related to the load, and when determining that the load state is a medium load based on the information, process the target service request;

[0010] The current information related to the load is obtained, and when the load state is determined to be low load or high load based on the information, the partition server is redirected based on the HTTP protocol.

[0011] In combination with the first implementation of the first aspect, in the second implementation of the first aspect, the redirection of the partition server based on the HTTP protocol includes any one of the following:

[0012] When the load status is high, initiate the task of expanding the partition server and redirect to the next partition server based on the HTTP protocol;

[0013] When the load status is low, the task of merging the current partition server with other partition servers is performed, and redirecting to the previous partition server based on the HTTP protocol.

[0014] In combination with the second implementation of the first aspect, in a third implementation of the first aspect, the merging with other partition servers includes at least one of the following:

[0015] Setting a virtual identifier; the virtual identifier is used to redirect to the previous partition server based on the virtual identifier when receiving a service request after merging with other partition servers;

[0016] When merging with other partition servers, if it is determined that the current load reaches a preset threshold, if no service request is received within a preset time period, the task of destroying the current partition server is executed;

[0017] When merging with other partition servers or after executing the task of destroying the current partition server, when receiving a service request sent based on the redirection information, redirecting the partition server corresponding to the service request to the previous partition server;

[0018] When merging with other partition servers, the merge is stopped when receiving the task of extending the partition server;

[0019] After executing the task of destroying the current partition server, when receiving the task of extending the partition server, the task of rebuilding the partition server is executed to continue processing service requests or redirecting the partition server.

[0020] In combination with the first aspect, in a fourth implementation of the first aspect, further comprising:

[0021] If the target service request is processed, corresponding request success information is fed back to receive the next service request sent by the user equipment.

[0022] In a second aspect, a load balancing method is provided, which is applied to a user device, comprising: for a target service request sent based on the HTTP protocol, repeatedly performing the following steps until request success information is obtained:

[0023] Receiving response information fed back by the partition server based on the current load status; the response information includes request success information corresponding to processing the target service request or redirection information corresponding to redirecting the partition server based on the HTTP protocol;

[0024] When the redirection information is received, the target service request is sent based on the redirection information.

[0025] In combination with the second aspect, in a first implementation of the second aspect, the target service request carries a preset partition identifier or a partition identifier corresponding to a partition server that successfully responded to a previous service request; and the method further includes:

[0026] Upon receiving the request success information, storing the partition identifier corresponding to the partition server that processes the target service request;

[0027] The request success information includes a status code fed back by the partition server when processing the target service request or a reminder message generated when no information fed back by the partition server is received within a preset time period.

[0028] In combination with the second aspect, in a second implementation of the second aspect, the redirection information includes a next partition identifier corresponding to the high load state or a previous partition identifier corresponding to the low load state; and resending the target service request based on the redirection information includes any one of the following:

[0029] resending the target service request based on the next partition identifier;

[0030] The target service request is resent based on the previous partition identifier.

[0031] In a third aspect, a load balancing device is provided, including:

[0032] A receiving module, used to receive a target service request sent by a user device based on the HTTP protocol;

[0033] A processing module, used for processing the target service request based on the current load status or redirecting the partition server based on the HTTP protocol;

[0034] The feedback module is used to feedback corresponding redirection information if the partition server is redirected, so that the user equipment sends the target service request based on the redirection information.

[0035] In combination with the third aspect, in a first implementation manner of the third aspect, the processing module includes any of the following units:

[0036] a processing unit, configured to obtain current information related to the load, and when determining that the load state is a medium load based on the information, process the target service request;

[0037] The redirection unit is used to obtain current information related to the load, and when the load state is determined to be low load or high load based on the information, redirect the partition server based on the HTTP protocol.

[0038] In combination with the first implementation of the third aspect, in a second implementation of the third aspect, the redirection unit includes any of the following subunits:

[0039] A first redirection subunit is used to initiate a task of expanding a partition server and redirect it to a next partition server when the load state is high load;

[0040] The second redirection subunit is used to merge with other partition servers and redirect to the previous partition server when the load state is low.

[0041] In combination with the second implementation manner of the third aspect, in a third implementation manner of the third aspect, the second redirection subunit is further configured to perform at least one of the following:

[0042] Setting a virtual identifier; the virtual identifier is used to redirect to the previous partition server based on the virtual identifier when receiving a service request after merging with other partition servers;

[0043] When merging with other partition servers, if it is determined that the current load reaches a preset threshold, if no service request is received within a preset time period, the task of destroying the current partition server is executed;

[0044] When merging with other partition servers or after executing the task of destroying the current partition server, when receiving a service request sent based on the redirection information, redirecting the partition server corresponding to the service request to the previous partition server;

[0045] When merging with other partition servers, the merge is stopped when receiving the task of extending the partition server;

[0046] After executing the task of destroying the current partition server, when receiving the task of extending the partition server, the task of rebuilding the partition server is executed to continue processing service requests or redirecting the partition server.

[0047] In combination with the third aspect, in a fourth implementation of the third aspect, the device also includes a success feedback module: for feeding back corresponding request success information if processing the target service request, so as to receive the service request sent by the user equipment next time.

[0048] In a fourth aspect, a load balancing device is provided, including: a loop module, configured to repeatedly execute the following steps for a target service request sent based on the HTTP protocol until request success information is obtained:

[0049] Receiving response information based on the current load status feedback; the response information includes request success information corresponding to the target service request or redirection information corresponding to the partition server redirection based on the HTTP protocol;

[0050] When the redirection information is received, the target service request is resent based on the redirection information.

[0051] In combination with the fourth aspect, in a first implementation of the fourth aspect, the target service request carries a preset partition identifier or a partition identifier corresponding to a partition server that successfully responds to a previous service request; the device further includes a storage module, which is used to store the partition identifier corresponding to the partition server that processes the target service request when receiving the request success information;

[0052] The request success information includes a status code fed back by the partition server when processing the target service request or a reminder message generated when no information fed back by the partition server is received within a preset time period.

[0053] In combination with the fourth aspect, in a second implementation of the fourth aspect, the redirection information includes a next partition identifier corresponding to the high load state or a previous partition identifier corresponding to the low load state; and the loop module includes any one of the following units:

[0054] A first sending unit, configured to resend the target service request based on the next partition identifier;

[0055] The second sending unit is configured to resend the target service request based on the previous partition identifier.

[0056] In a fifth aspect, an electronic device is provided, comprising: one or more processors; a memory; one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to: execute the load balancing method described in the first aspect and any one of the aspects and any one of the embodiments of the second aspect and any one of the embodiments.

[0057] In a sixth aspect, a computer-readable storage medium is provided, wherein the storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the load balancing method described in the first aspect and any one of the aspects and the second aspect and any one of the embodiments thereof.

[0058] The beneficial effects of the technical solution provided by this application are:

[0059] The present application provides a load balancing method and related equipment. Compared with the prior art, the method provided by the present application processes the target service request or redirects the partition server based on the HTTP protocol based on the current load state when receiving a target service request sent by a user device based on the HTTP protocol; if the partition server is redirected based on the HTTP protocol, the corresponding redirection information is fed back so that the user device sends the target service request based on the redirection information. The implementation of the present application achieves the effect of automatically partitioning user groups and serving them, and realizing server load balancing by utilizing the load capacity of its service that the server can obtain and the redirection capacity of HTTP. This reduces the complexity of implementation and improves the stability of operation without requiring users to select partitions.

[0060] Additional aspects and advantages of the present application will be partially given in the following description, which will become apparent from the following description, or will be understood through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in describing the embodiments of the present application.

[0062] Figure 1 It is a module block diagram corresponding to the automatic partitioning solution based on the real-time online population counting system in the prior art;

[0063] Figure 2 A flow chart of a load balancing method provided in an embodiment of the present application;

[0064] Figure 3 A flow chart of another load balancing method provided in an embodiment of the present application;

[0065] Figure 4 A flow chart of a load balancing method provided in an embodiment of the present application;

[0066] Figure 5 A schematic diagram of an operating environment of a load balancing method provided in an embodiment of the present application;

[0067] Figure 6 A schematic diagram of a load balancing device provided in an embodiment of the present application

[0068] Figure 7 A schematic diagram of the structure of another load balancing device provided in an embodiment of the present application;

[0069] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0070] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present application.

[0071] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.

[0072] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0073] The following describes the terms or related technologies that may be involved in the embodiments of this application:

[0074] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, image websites and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.

[0075] Cloud computing refers to the delivery and use model of IT infrastructure, which means obtaining required resources through the network in an on-demand and easily scalable manner; in a broad sense, cloud computing refers to the delivery and use model of services, which means obtaining required services through the network in an on-demand and easily scalable manner. This service can be related to IT and software, the Internet, or other services. Cloud computing is the product of the development and integration of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing. With the development of the Internet, real-time data streams, and the diversification of connected devices, as well as the promotion of search services, social networks, mobile commerce, and open collaboration, cloud computing has developed rapidly. Different from the previous parallel distributed computing, the emergence of cloud computing will promote revolutionary changes in the entire Internet model and enterprise management model from a conceptual perspective.

[0076] User: A user of an Internet service.

[0077] User device: The electronic device used by the user.

[0078] Partition: Divide users into different service partitions. For example, based on geographical location, it can be East China, North China, South China, Central China, etc.

[0079] Zone server: A backend server that provides services to all user devices in a certain zone. A zone server may be a distributed cluster or a single machine. This application can treat a zone server as a whole.

[0080] Create a new partition (extend partition): When a partition has many user devices and the load is high, create a new partition to schedule some users in the partition to the new partition.

[0081] Merge partitions (zone merging): When the number of user devices under a partition decreases, merge the partition into another partition.

[0082] Partition management module: used to control the creation of new partitions or the merging of partitions according to the status of the partitions.

[0083] Real-time online population counting system: Systems that can count the number of online users in real time generally use big data analysis tools such as Storm and Spark to obtain results by counting the access logs of user devices.

[0084] Observation and control module: used to observe and control the load. The above-mentioned real-time online people counting system belongs to an observation and control module.

[0085] Gateway: uniformly receives service requests sent by user devices based on the HTTP (HyperText Transfer Protocol) protocol, and forwards the user device requests to different servers; traffic scheduling, session persistence, and load balancing can be implemented in the gateway.

[0086] In the prior art, in view of the fact that multiple services implemented on the Internet cannot support unlimited expansion of the user scale due to the limitations of their service characteristics, and multiple partitions need to be set up for operation, a manual operation solution is proposed. Generally, manual operation is adopted. When there are many users, users are asked to actively select a partition from the multiple partitions currently set; when there are few users, partitions are manually merged to reduce the number of partitions that users can choose, thereby achieving the purpose of merging partitions (such as reducing resource waste). The following example of the manual operation solution is used in the scenario of an online game, which specifically includes the following steps:

[0087] (1) First, divide the regions and arrange the regional servers according to the online activity of each zone;

[0088] (2) When a user logs into the game, the user is guided to select a partition. The user can enter the game only after selecting a partition;

[0089] (3) When the number of online game users decreases, or the online activity of some partitions decreases, call back to step (1) to reduce some partitions.

[0090] (4) When the number of online game users increases, or when some partitions have too many online users and are about to exceed the server load, call back to step (1) to add some partitions.

[0091] The manual operation scheme mentioned above usually needs to cooperate with issuing announcements to users when changing partitions, or merge partitions at the request of users, to maintain the activity of users in the partitions so that the service can continue to operate well. It can be seen that the products produced by the manual operation scheme are less user-friendly, such as requiring users to select partitions by themselves or requiring users to issue requests to change partitions. To solve this problem, in the prior art, an automatic partitioning scheme based on a real-time online population counting system is proposed. The real-time online population counting system is used to feed back the real-time counted number of online people to a partition management module responsible for dividing the area. The partition management module controls the creation of new partitions or the merging of partitions and dispatches users to appropriate partitions.

[0092] Specifically, compared with the manual operation scheme, the automatic partitioning scheme based on the real-time online population counting system saves the manual operation of partitioning and merging, and can rely on computers to intelligently partition and merge. Among them, the real-time online population counting system is crucial in this scheme. Through this system, the total number of online users and the number of online users in each partition can be counted, and then whether to create or merge partitions can be determined based on the number of online users. The products generated by this scheme are mainly Figure 1 The following is composed of several modules shown in Figure 1 The scheme is described. Specifically, the scheme includes the following steps:

[0093] 1. Automatically divide user devices into partitions according to a certain schedule; the system records the relationship between user devices and partitions;

[0094] 2. The access behavior of the user device generates an access log. The real-time online population counting system perceives the access log of the user device in real time and feeds it back to the partition management module.

[0095] 3. The real-time online population counting system feeds back the load status of each partition to the partition management module, which then creates new partitions or merges partitions according to the set strategy.

[0096] It can be seen that the automatic partitioning scheme based on the real-time online population counting system does not require users to select partitions, and has a higher user experience than the manual operation scheme. However, in some scenarios where the infrastructure is relatively backward, the automatic partitioning scheme based on the real-time online population counting system may require manual operation and maintenance to deploy new partitions and merge partitions, so manual intervention is still required. In addition, the real-time online population counting system is generally completed by big data processing cluster suites such as Kafka, ZooKeeper, Storm, and Spark, which is very expensive; or it can be judged by counting the load of each partition, such as the number of connections, CPU usage and other indicators, but it still needs to adopt complex observation and control modules to provide support to observe and control the load of each partition and the load of the overall partition.

[0097] In response to the above problems, the present application provides a load balancing method, which, without introducing complex observation and control modules, is based on the load capacity of the server that can obtain its service, combined with the redirection capability of HTTP, to achieve the effect of automatically dividing user groups into different regions and serving them.

[0098] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0099] A load balancing method provided in the embodiment of the present application is applied to the server side, and can be specifically executed by the electronic device provided in the embodiment of the present application. Specifically, the electronic device can be a server, and the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms, but is not limited to this. Figure 2 As shown, the load balancing method provided in the embodiment of the present application includes the following steps S201-S203:

[0100] Step S201: receiving a target service request sent by a user device based on the HTTP protocol.

[0101] Specifically, the target service request can be a request initiated by a user device based on a service provided on the Internet, such as a request initiated based on the need to change game equipment when a user logs into an online game. Among them, in an embodiment of the present application, the target service request can be sent using the HTTP protocol or the HTTPS protocol. The HTTP protocol is an application layer protocol for distributed, collaborative and hypermedia information systems; the HTTPS protocol is a network protocol constructed by SSL (Secure Sockets Layer) + HTTP protocol that can perform encrypted transmission and identity authentication. Optionally, the data transmission, redirection and other operations based on the HTTP protocol involved in the embodiment of the present application can also be adapted to the HTTPS protocol.

[0102] Optionally, the target service request can be a user-initial request or a user-submitted request; when the target service request is a user-initial request, the application scenario can be adapted to when the user device initially initiates a service request (the user is a new user), and based on a default partition identifier or a random partition identifier, the target service request is initiated to the corresponding partition server. When the target service request is a user-submitted request, the application scenario can be adapted to when the user device has an existing request history (the user is an old user), and based on the identifier of the partition server that successfully responded to the previous service request, the target service request is initiated to the corresponding partition server.

[0103] Step S202: Based on the current load status, process the target service request or redirect the partition server based on the HTTP protocol.

[0104] Specifically, load can be understood as the average number of threads in the running queue within a specific time interval; if the load is too high, the partition server may be unable to process requests and / or operations. The current load state can be determined by the average load in the last 1 minute, 5 minutes, and / or 15 minutes (the above time is only an example, and the embodiments of the present application are not limited to this). The current load state can be determined by the partition server itself, such as the partition server determines its own load state based on the current throughput, number of connections, CPU or memory usage and other indicator information. For example, when the partition server measures its own load state based on CPU usage, memory usage and IO consumption, when it detects that any one of the items is used too much (exceeding the first set threshold within a specific time), it is determined to be a high load; when it is detected that each indicator is used less (exceeding the second set threshold within a specific time), it is determined to be a low load. The first set threshold and the second set threshold can be set according to the configuration of the partition server. For example, for a partition server running on a single-core CPU, the first set threshold can be set to 0.7. When the load value is not less than 0.7, it is determined that the current load is high (overloaded); the second set threshold can be set to 0.1 or 0. When the load value is not greater than the second set threshold, it is determined that the current load is low, and the partition server can be considered for destruction. In addition, when the load value is between the first set threshold and the second set threshold, it can be determined that the current load state belongs to a moderate load, and the current partition server can provide services normally and process service requests of user devices.

[0105] In a feasible embodiment, the current load status may also be that after the partition server obtains its own indicator information and uploads it to the management platform (which may be a cloud computing platform), the management platform determines the corresponding load status and sends it to the partition server.

[0106] Optionally, in step 202, when the partition server is in different load states, the corresponding results are different. For example, when the current load state of the partition server is medium load (can provide services), the target service request is processed; otherwise, the partition server redirects the partition server based on the HTTP protocol. The specific process of the partition server processing the target service request based on the current load state or redirecting the partition server based on the HTTP protocol will be described in detail in subsequent embodiments.

[0107] Step S203: If the partition server is redirected based on the HTTP protocol, corresponding redirection information is fed back so that the user equipment sends a target service request based on the redirection information.

[0108] Specifically, the embodiment of the present application is implemented based on the HTTP protocol. In the HTTP protocol, the redirection operation is triggered by the partition server by sending a special response (such as redirects). In the HTTP protocol, the status code of the redirection response can be expressed as 3XX (such as 302). In step S203, redirecting the partition server can be understood as the partition server issuing a redirection response, and the corresponding redirection information fed back by the partition server may include the status code corresponding to the redirection response and the information provided by the redirection response. In the embodiment of the present application, the information can be reflected as the partition identifier corresponding to the partition server determined by the redirection. When the user device receives the redirection response (such as receiving a 302 status code), it will resend the target server request to the partition server determined by the redirection according to the partition identifier corresponding to the partition server represented in the information provided by the redirection response. Combined with the attached Figure 4 As shown, for example: the user device sends a service request (http: / / a.com / service / g0 / join?xxx) to partition server 0. When partition server 0 determines that the load is high based on its current load state, it feeds back redirection information (302 http: / / a.com / service / g1 / join?expand=1; 302 is a status code) to the user device. At this time, the user device receives the status code 302 and the URL address. The partition server g1 determined by the redirection can be known in the URL address. Therefore, the user device will send a service request (http: / / a.com / service / group-1 / join?expand=1) to partition server 1 based on the redirection information.

[0109] Optionally, in the present application, the redirection may be a temporary redirection, and the corresponding status code is 302. It can be applied to the scenario where the current partition server cannot provide services to the user and issues a redirection response.

[0110] In this application, the user device can be understood as an HTTP client / terminal, and the partition server can be understood as an HTTP server; the user device initiates a service request and creates a TCP connection to the specified port of the partition server. The partition server detects the service request of the user device at the port. Once the service request is received, the partition server returns a status to the user device, such as returning "200 OK" when the partition server successfully processes the service request, and returns relevant content to the user device, such as the file requested by the user device, error message, or other information.

[0111] In one embodiment, the load balancing method provided by the present application may further include step S204: when processing the target service request, feeding back corresponding request success information to receive the next service request sent by the user equipment.

[0112] Specifically, when the server can currently provide services to the user device, the server will process the target service request and feedback the corresponding request success information and / or request content to the user device. After the user device determines that the current target service request has been processed, it can be regarded as dividing the user device into the current partition server, and when the next service request initiated by the same user device is subsequently sent to the current partition server.

[0113] The above embodiment illustrates the load balancing method provided by the present application, which mainly realizes adaptively dividing user devices into different partition servers based on the current load status by using the redirection capability of HTTP, so as to achieve the effect of load balancing of each server. Specifically, the adaptive means that when dividing the user devices based on the load status of the partition server, if the current load status of the current partition server belongs to the medium load, the user devices are divided into the current partition server (which is reflected in the current partition server processing the service request sent by the user device); if the current load status of the current partition server belongs to the high load, the task of extending the partition server is initiated, and the user devices are instructed to be divided into the partition server obtained by the extension (the next partition server) (which is reflected in the partition server obtained by the extension processing the service request sent by the user device); if the current load status of the current partition server belongs to the low load, the task of merging the current partition server with the previous partition server is executed, and the user devices are instructed to be divided into the previous partition server (which is reflected in the previous partition server processing the service request sent by the user device). Among them, when the redirection operation is performed, the user cannot perceive it, and the whole redirection process is reflected in the user device re-issuing the target service request to other servers based on the partition identifier corresponding to the partition server corresponding to the redirection.

[0114] The following describes the specific process of processing a target service request or redirecting a partition server based on the HTTP protocol based on the current load status in the present application in combination with the accompanying drawings and embodiments.

[0115] Specifically, step S202 processes the target service request or redirects the partition server based on the current load status, including any one of the following steps A1-A2:

[0116] Step A1: Acquire current information related to the load, and when it is determined based on the information that the load state is a medium load, process the target service request.

[0117] Step A2: obtaining current information related to the load, and when determining based on the information that the load state is low load or high load, redirecting the partition server based on the HTTP protocol.

[0118] Specifically, the load status is used to measure the busyness of the server; information related to the load may be indicators such as throughput, number of connections, CPU or memory usage, etc. The load status may be determined based on the number of processes in the runnable state and the uninterrupttable state; optionally, the load status determined based on the load-related information includes the following three situations:

[0119] (1) The load status is moderate: At this point, it can be understood that the server CPU resources can process the target service request.

[0120] Under this load state, the server can process the target service request, such as responding with 200, which means the request is successfully processed; or responding with 202, which means the server accepts to process the request but has not yet processed it.

[0121] (2) The load status is high load: It can be understood that the server resources cannot provide services. For example, high load caused by insufficient CPU resources. For example, when the server has only one CPU, it takes 1 second to process each process. However, if two processes need to be processed at the same time in that 1 second, one process cannot be processed every 1 second. The corresponding server load will continue to increase, and eventually the service request cannot be processed in time. Another example is high load caused by CPU utilization. For example, when the server receives a large number of read requests, IO may become a bottleneck. At this time, the process to be processed is in a non-terminal state while waiting for IO. Therefore, when calculating the server load, it will eventually appear as high load.

[0122] (3) Low load: This means that the server currently needs to process very few processes and may receive very few user requests. You can consider destroying the server to avoid wasting network resources. If the number of processes that the server currently needs to process is only 2, dispatching the process to other partition servers for processing will not affect the original processing capacity of the partition server. Therefore, you can consider destroying the partition server with a low load status.

[0123] When the load status is high load or low load, the server will issue a redirect response (such as response 302).

[0124] In one embodiment, the load state can be distinguished by setting the load value. Assuming that the full load is 1, if the load exceeds 1, it can be regarded as a high load; if the load is less than 0.1, it can be regarded as a low load. The above values ​​are only understood as examples. In actual applications, they can be set according to actual application scenarios, and this application does not limit this.

[0125] Optionally, redirecting the partition server based on the HTTP protocol in step A2 includes at least one of the following steps A21-A22:

[0126] Step A21: When the load status is high, initiate a task to expand the partition server and redirect to the next partition server based on the HTTP protocol.

[0127] Specifically, when the task of extending the partition server is initiated, it can be understood that the server determines that a new partition needs to be created. At this time, a partition will be created in the entire operating system of the product and a partition server will be configured to provide services accordingly. For example: Assuming that the partition where the current partition server is located is identified as N, when the task of extending the partition server is initiated, a partition identified as N+1 will be created in the entire operating environment and a corresponding partition server will be configured.

[0128] Optionally, redirecting to the next partition server may be understood as the server providing the user device with a partition identifier corresponding to the next partition server when issuing a redirect response.

[0129] By implementing the above step A21, the high load characteristics of the zone server itself can be utilized, and the jump redirection capability of HTTP can be used to achieve the purpose of adding user devices to the newly created zone. The following describes the specific process of merging zones when the zone server itself has a low load.

[0130] Step A22: When the load state is low load, the task of merging the current partition server with other partition servers is executed, and redirected to the previous partition server based on the HTTP protocol.

[0131] Among them, when merging with other partition servers, it can be understood that the current partition server determines that the partition needs to be merged. At this time, the entire operating system of the product includes at least two partitions and each is configured with a corresponding partition server. When executing the partition merge, the current partition server is merged with other partition servers. The other partition servers can be any partition server in the entire operating system except the current partition server, or the previous partition server of the current partition server (such as the partition server indicating the expansion of the current partition server). Optionally, when executing the partition merge, it also includes redirecting all user devices served by the current partition server to the previous partition server.

[0132] Specifically, redirecting to the previous partition server can be understood as the server providing the partition identifier corresponding to the previous partition server to the user equipment when issuing a redirection response.

[0133] Optionally, the merging with other partition servers in step A22 may include at least one of the following steps A221-A225:

[0134] Step A221: Setting a virtual identifier; the virtual identifier is used to redirect to the previous partition server based on the virtual identifier after merging with other partition servers when receiving a service request.

[0135] Specifically, assuming that the partition identifier corresponding to the current partition server is N, when the load of the server is very low and it is determined that the partition merge task needs to be performed, the partition server will set a virtual identifier. When the partition server receives a service request sent again by the current user device or receives a service request sent based on redirection information, it will directly issue a redirection response based on the current virtual identifier, and redirect the corresponding service request sent again to the partition identifier N-1 corresponding to the previous partition server. By setting a virtual identifier, the network resources that the partition server determines to redirect can be effectively saved.

[0136] Optionally, the virtual identifier can be set according to the server resource utilization, such as setting identifier 0 or 1 for the partition server, identifier 0 (virtual identifier) ​​indicates that the current partition server needs to be merged with other partition servers (manifested in that the current partition server no longer processes service requests), and identifier 1 indicates that the load status of the current partition server is medium load (manifested in that service requests can be processed normally).

[0137] Step A222: When merging with other partition servers, if it is determined that the current load reaches a preset threshold, and if no service request is received within a preset time period, the task of destroying the current partition server is executed.

[0138] Specifically, considering that in the entire operating system of the product, when the previous service request of the user device is processed by the current partition server, the next service request initiated by the user device will still be sent to the current partition server; and there may be subsequent partitions that converge to the partition corresponding to the current partition server (such as when the current partition server N is merged with the previous partition server N-1, the next partition server N+1 requests to merge with the current partition server N), when determining to execute the task of merging partitions, the application does not execute it directly, but after redirecting all user devices served by the current partition server to other partition servers, when it is determined that its own load reaches a preset threshold (such as the load value drops to 0), waits for a certain period of time (the period of time can be determined based on a preset time period). If no service request is received during the waiting process, the task of destroying the partition server is executed.

[0139] Step A223: when merging with other partition servers or after executing the task of destroying the current partition server, when receiving a service request sent based on the redirection information, redirect the partition server corresponding to the service request to the previous partition server.

[0140] Specifically, assuming that the entire current running system includes three partitions, partitions 0, 1, and 2. When the partition server corresponding to partition 1 determines to merge (or after the merger, that is, after destruction), partition 2 still exists. When the partition server corresponding to partition 2 determines to merge, the partition server corresponding to partition 1 will receive a service request A sent to the partition server corresponding to partition 1 based on the redirection response issued by the partition server corresponding to partition 2. At this time, since the partition server corresponding to partition 1 no longer processes the service request, a redirection response will be issued (the partition server can perform the redirection operation with the help of parameter reduce=1), and the partition server corresponding to partition 1 redirects the partition server corresponding to the service request A to the partition server corresponding to partition 0.

[0141] Step A224: When merging with other partition servers and receiving an extended partition server task, stop the merging.

[0142] Specifically, for example, assuming that the entire current operating system includes three partitions, partitions 0, 1, and 2. When the partition server corresponding to partition 2 determines to merge with the partition server corresponding to partition 1, the user devices included in partition 2 are scheduled to partition 1 during the merging process. During the merging process, when an indication of an expanded partition server is received from other partition servers or a management platform (such as when the partition server corresponding to the current partition 1 is in a high load state and an indication including the parameter expand=1 is received), the partition server corresponding to partition 2 will stop executing the merging operation to retain partition 2 and its corresponding partition server to provide services to users.

[0143] Step A225: After executing the task of destroying the current partition server, when receiving the task of extending the partition server, executing the task of rebuilding the partition server to continue processing service requests or redirecting the partition server.

[0144] Specifically, for example, assume that the entire current running system includes three partitions, partitions 0, 1, and 2; when the partition server corresponding to partition 1 executes the task of destroying the current partition server, the server releases the occupied resources, and the corresponding partition 1 appears as a virtual partition (the corresponding status can be determined by querying a database, etc.). At this time, if an extended partition server task is received (such as receiving a request with expand=1), it will be rebuilt based on the currently destroyed partition 1 (including configuring the corresponding partition server) to obtain the functional scenario corresponding to the original partition 1 (such as providing services to user devices or performing redirection operations).

[0145] During the implementation of the above embodiment, the user of the electronic device cannot perceive the specific situation of the partition, and the entire process (including the redirection operation) can be recorded by the client application.

[0146] The present application also provides a load balancing method that can be performed by a user device, specifically, it can be performed by an electronic device provided in the present application. Specifically, the electronic device can be a client or a web terminal. The client can be a smart phone, a tablet computer, a laptop, a desktop computer, a smart speaker, a smart watch, a smart camera, a robot, etc., but is not limited thereto. Figure 3 As shown, the load balancing method provided in the embodiment of the present application includes the following steps S301:

[0147] Step S301: for the target service request sent based on the HTTP protocol, repeatedly execute the following steps B1-B2 until the request success information is obtained.

[0148] Among them, the target service request carries a preset partition identifier or a partition identifier corresponding to the partition server that successfully responded to the previous service request. Specifically, the preset partition identifier can be the default partition identifier of the client application or a randomly assigned partition identifier when the user is a new user; the partition identifier corresponding to the server that successfully responded to the previous request can be when the user is an old user, when the previous service request was completed, the client application stored the partition identifier of the partition server, and when the target service request is currently initiated, the target service request will be sent to the server that completed the previous service request based on the stored partition identifier. Optionally, if a partition server successfully processes the previous service request of a user device, it can be understood that the user device is divided into this partition server.

[0149] Optionally, when receiving the request success information, the user equipment further stores the partition identifier corresponding to the partition server that processes the target service request.

[0150] Step B1: receiving response information fed back by the partition server based on the current load status; the response information includes request success information corresponding to processing the target service request or redirection information corresponding to redirecting the partition server based on the HTTP protocol.

[0151] The request success information includes a status code fed back by the partition server processing the target service request or a reminder message generated when no information fed back by the partition server is received within a preset time period.

[0152] Optionally, when the current resources of the partition server can be used to provide services to the user device, the target service request initiated by the user device will be processed, and the corresponding status code 200 and the corresponding request content will be fed back to the user device. In a feasible embodiment, even if the partition server has processed the target service request or is preparing to process the target service request, it has not fed back any information to the user device (such as responses 204, 205); at this time, if the user device does not receive the information fed back by the partition server within a preset time period, it will automatically generate a reminder message to determine that the target service request has been processed (considering that if the partition server performs a redirection operation, the user device will inevitably receive the redirection information, so it can be set that when no information is received within the preset time period, it can be assumed that the target service request has been processed by the partition server).

[0153] Step B2: When the redirection information is received, a target service request is sent based on the redirection information.

[0154] Specifically, the redirection information includes a next partition identifier corresponding to the high load state or a previous partition identifier corresponding to the low load state; sending the target service request based on the redirection information in step B2 includes any one of the following steps B21-B22:

[0155] Step B21: resend the target service request based on the next partition identifier.

[0156] Specifically, if the partition server currently receiving the target service request is in a high-load state, the partition server will perform a redirection operation and feedback redirection information to the user device, which includes the next partition identifier corresponding to the next partition server redirected to. The user device will re-initiate the target service request to the server corresponding to the next partition based on the next partition identifier.

[0157] Step B22: Resend the target service request based on the previous partition identifier.

[0158] Specifically, if the partition server currently receiving the target service request is in a low-load state, the partition server will perform a redirection operation and feedback redirection information to the user, which includes the last partition identifier corresponding to the last partition server redirected to. The user device will re-initiate the target service request based on the last partition identifier.

[0159] Optionally, considering the forward redirection, there is a situation where the intermediate partition has been reduced and released, such as assuming that the current running system includes partitions 0, 1, and 2; among them, partition 1 has been reduced and released (such as merged with partition 0), and the system can store the relevant information of partition 1; the user device sends a target service request to the partition server corresponding to partition 2, and when the partition server corresponding to partition 2 performs a redirection operation, it redirects to the partition server corresponding to partition 1; when the user device resends the target service request based on the redirection information fed back by the partition server corresponding to partition 2, since partition 1 has been reduced and released, the target service request resent by the user device at this time will be directly sent to the partition server corresponding to partition 0; in this process, the forwarding of the target service request can be implemented by the gateway, for example: when the user device resends the target service request based on the redirection information (corresponding to the identifier of partition 1), the gateway forwards the target service request to the partition server corresponding to the previous partition (that is, forwards it to the partition server corresponding to partition 0) based on the information that partition 1 has been reduced and released stored in the current system.

[0160] In a feasible embodiment, step B22 and step A221 (partition server sets virtual identifier) ​​shown in the above embodiment can be understood as being adapted to the same application scenario (a certain intermediate partition and its corresponding partition server have been reduced and released, i.e., merged), and processed using different methods. Optionally, the method steps shown in step B22 and step A221 can refer to each other; that is, when a partition executes the partition merge task, the partition server is set with a virtual identifier and the system stores the relevant information that the partition has been reduced and released.

[0161] For the description of how the partition server determines the load status, reference may be made to the description of the above embodiment, which will not be described in detail here.

[0162] When the above embodiments are used to describe the load balancing methods applied to the user end and the load balancing methods applied to the server end, there are references to each other, and references can be made to each other when explaining the specific embodiments.

[0163] The embodiment of the present application can realize the function of dividing the served user equipment into zones and servers. The implementation process is simple and has the ability to automatically divide user equipment. It can be applicable to the scenario where a single machine is used as a zone server and the zone server can be virtualized and automatically expanded.

[0164] In a feasible embodiment, the operating environment of the present application may include a user device and a server, and on this basis, an intermediate server, such as a gateway, may be included to receive a service request initiated by the user device, and automatically forward the service request to the partition server corresponding to the partition identifier in a load-balanced manner according to the partition identifier carried in the service request. Optionally, when utilizing the redirection capability of the HTTP protocol, the embodiment of the present application may design the partition in a uniform resource locator (URL) and process it according to the load-balancing method of the URL HASH.

[0165] To further illustrate the load balancing method provided by this application, Figure 4 and Figure 5 , providing feasible application examples.

[0166] Application Example 1: In a Tracker (a program running on a server) service based on XP2P (a technology based on a new generation of P2P technology), user devices that watch the same video content can be gathered in the same area, so that users can communicate, discuss or share with each other. Then, for video content such as the Spring Festival Gala, since the number of users who request to watch the video content in the same time period is very large, it is impossible to gather all users in the same partition. At this time, a new partition can be created based on information such as the current number of users and the partition server can be configured to divide the user devices into each partition. Among them, the process of user device division can be implemented using the load balancing method provided in this application. For example, if 100 million people watch the Spring Festival Gala at the same time, a very large bandwidth is required. The load balancing method provided in this application can be used to divide 10 partitions, each of which includes 10 million people, and users watch through the partition where their devices are located. At this time, the load balancing effect of 10 partitions can be achieved.

[0167] Application Example 2: Combination Figure 4 and Figure 5The current operating environment includes multiple user devices 501, partition servers 502, and gateways 503.When user device A initiates a target service request, gateway 503 forwards the target service request to the partition server corresponding to partition 0 based on the partition identifier 0 carried in the target service request (for example: http: / / a.com / service / g0 / join?xxx); if the partition server corresponding to partition 0 is in a high-load state, the task of expanding the partition server backward is initiated (at this time, a partition server corresponding to partition 1 is newly added to the operating environment) and a redirection operation is performed to issue a redirection response. Gateway 503 forwards the redirection information fed back by the partition server corresponding to partition 0 to user device A (for example: including status code 302 and the URL address http: / / a.com / service / g0 / join?xxx determined during the redirection response). com / service / g1 / join?expand=1, where parameter expand=1 indicates redirection to the next partition server); user device A resends the target service request based on the received redirection information; when gateway 503 receives the target service request resent by user device A, it forwards the target service request to the partition server corresponding to partition 1 based on the URL address (http: / / a.com / service / group-1 / join?expand=1) carried in the request; when the partition server of partition 1 receives the target service request sent by user device A and determines that it is currently in a high load state, it initiates the task of expanding the partition server backwards. The gateway 503 receives the target service request from the partition server corresponding to partition 1 (in this case, a partition server corresponding to partition 2 is newly added to the running environment) and performs a redirection operation to issue a redirection response. The gateway 503 forwards the redirection information fed back by the partition server corresponding to partition 1 to the user device A (for example, including the status code 302 and the URL address http: / / a.com / service / g2 / join?expand=1 determined in the redirection response, where the parameter expand=1 indicates redirection to the next partition server). The user device A resends the target service request based on the received redirection information. When the gateway 503 receives the target service request resent by the user device A, based on the URL address (http: / / a.com / service / g2 / join?expand=1) carried in the request, the gateway 503 sends the target service request to the next partition server. com / service / group-2 / join?expand=1) forwards the target service request to the partition server corresponding to partition 2 (this process can be regarded as user device A sending a target service request to the partition server corresponding to partition 2); when the partition server of partition 2 receives the target service request sent by user device A, it determines that it is currently in a medium load state, processes the target service request, and feeds back a response status code 200; gateway 503 forwards the status code 200 to user device A. When user device A receives the status code 200, it knows that the current target service request has been successfully processed by the partition server corresponding to partition 2, and user device A stores the partition identifier 2 of the partition server.When user device A initiates a service request next time, it will carry partition identifier 2; when gateway 503 receives the service request, it will forward the service request to the partition server corresponding to partition 2 based on the carried partition identifier 2; after receiving the service request, the partition server corresponding to partition 2 determines that it is currently in a low-load state, and performs a forward convergence operation (merges with the previous partition server) and performs a redirection operation to issue a redirection response; gateway 503 forwards the redirection information fed back by the partition server corresponding to partition 2 to user device A (for example: including status code 302, and the URL address http: / / a.com / service / group-1 / htbt?reduce=1 determined during the redirection response, where parameter reduce=1 represents redirection to the previous partition server); user device A resends the service request based on the redirection information; gateway 503 forwards the service request to the partition server corresponding to partition 1 based on the previous partition identifier carried in the service request (for example: http: / / a.com / service / group-1 / htbt?reduce=1). The above steps B1-B2 will be repeated until the user device A obtains the request success information (such as status code 200). The subsequent execution steps will not be described one by one.

[0168] In combination with the above application example 2, it can be seen that the URL address http: / / a.com / service / g0 / join?xxx includes the partition identifier g0, and the URL address http: / / a.com / service / g1 / join?expand=1 includes the partition identifier g1 and the parameter expand=1. It can be seen that the partition identifier involved in the embodiment of the present application can be designed in combination with the URL address.

[0169] In one embodiment, if Figure 6 As shown, a load balancing device 600 applied to a server is provided, including: a receiving module 601, a processing module 602 and a feedback module 603.

[0170] Specifically: a receiving module 601 is used to receive a target service request sent by a user device based on the HTTP protocol; a processing module 602 is used to process the target service request or redirect the partition server based on the HTTP protocol based on the current load status; a feedback module 603 is used to feedback corresponding redirection information if the partition server is redirected based on the HTTP protocol, so that the user device sends the target service request based on the redirection information.

[0171] Optionally, the processing module 602 includes any of the following units:

[0172] a processing unit, configured to obtain current information related to the load, and when determining that the load state is a medium load based on the information, process the target service request;

[0173] The redirection unit is used to obtain current information related to the load, and when the load state is determined to be low load or high load based on the information, redirect the partition server based on the HTTP protocol.

[0174] Optionally, the redirection unit includes any of the following subunits:

[0175] A first redirection subunit is used to initiate a task of expanding a partition server and redirect it to a next partition server when the load state is high load;

[0176] The second redirection subunit is used to execute the task of merging the current partition server with other partition servers and redirecting to the previous partition server when the load state is low load.

[0177] Optionally, the second redirection subunit is further configured to perform at least one of the following:

[0178] Setting a virtual ID; the virtual ID is used to redirect to the previous partition server based on the virtual ID when receiving a service request after merging with other partition servers;

[0179] When merging with other partition servers, if it is determined that the current load reaches a preset threshold, if no service request is received within a preset time period, the task of destroying the current partition server is executed;

[0180] When merging with other partition servers or executing the task of destroying the current partition server, when receiving a service request sent based on the redirection information, redirect the partition server corresponding to the service request to the previous partition server;

[0181] When merging with other partition servers, the merge is stopped when receiving the task of extending the partition server;

[0182] After executing the task of destroying the current partition server, when receiving the task of extending the partition server, executing the task of rebuilding the partition server to continue processing service requests or redirecting the partition server.

[0183] Optionally, the apparatus 600 further includes a success feedback module: configured to feedback corresponding request success information if the target service request is processed, so as to receive a service request sent by the user equipment next time.

[0184] In one embodiment, if Figure 7As shown, a load balancing device 700 applied to a user end is provided, including: a loop module 701; specifically, the loop module 701 is used to repeatedly execute the following steps for a target service request sent based on the HTTP protocol until request success information is obtained: receiving response information fed back by the partition server based on the current load state; the response information includes request success information corresponding to processing the target service request or redirection information corresponding to redirecting the partition server based on the HTTP protocol; when the redirection information is received, sending the target service request based on the redirection information.

[0185] Optionally, the target service request carries a preset partition identifier or a partition identifier corresponding to a partition server that successfully responded to a previous service request; the device 700 further includes a storage module, which is used to store the partition identifier corresponding to the partition server that processes the target service request when receiving the request success information;

[0186] The request success information includes a status code fed back by the partition server processing the target service request or a reminder message generated when no information fed back by the partition server is received within a preset time period.

[0187] Optionally, the redirection information includes a next partition identifier corresponding to the high load state or a previous partition identifier corresponding to the low load state; the loop module 701 includes any of the following units:

[0188] A first sending unit, configured to resend a target service request based on a next partition identifier;

[0189] The second sending unit is used to resend the target service request based on the previous partition identifier.

[0190] The load balancing device of the embodiment of the present application can execute a load balancing method provided by the embodiment of the present application, and the implementation principle is similar. The actions performed by each module in the load balancing device in each embodiment of the present application correspond to the steps in the load balancing method in each embodiment of the present application. For the detailed functional description of each module of the load balancing device, please refer to the description in the corresponding load balancing method shown in the previous text, which will not be repeated here.

[0191] In an alternative embodiment, an electronic device is provided, such as Figure 8 As shown, Figure 8 The electronic device 800 shown includes: a processor 801 and a memory 803. The processor 801 and the memory 803 are connected, such as through a bus 802. Optionally, the electronic device 800 may also include a transceiver 804. It should be noted that in actual applications, the transceiver 804 is not limited to one, and the structure of the electronic device 800 does not constitute a limitation on the embodiments of the present application.

[0192] The processor 801 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor 801 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0193] The bus 802 may include a path to transmit information between the above components. The bus 802 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 802 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0194] The memory 803 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.

[0195] The memory 803 is used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 801. The processor 801 is used to execute the application code stored in the memory 803 to implement the content shown in the above method embodiment.

[0196] Among them, electronic devices include but are not limited to: mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0197] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the load balancing method provided in the above-mentioned various optional implementations.

[0198] The embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer can execute the corresponding content of the aforementioned method embodiment. Compared with the prior art, the method provided by the present application processes the target service request or redirects the partition server based on the HTTP protocol based on the current load state when receiving a target service request sent by a user device based on the HTTP protocol; if the partition server is redirected based on the HTTP protocol, the corresponding redirection information is fed back so that the user device sends the target service request based on the redirection information. The implementation of the present application achieves the effect of automatically balancing the server load by partitioning the user group and serving the service by utilizing the load capacity of its service that the server can obtain and the redirection capability of HTTP. This reduces the complexity of implementation and improves the stability of operation without requiring the user to select a partition.

[0199] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0200] It should be noted that the computer-readable medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with 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 application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may 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 may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0201] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0202] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.

[0203] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0204] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0205] The modules involved in the embodiments of the present application may be implemented by software or hardware. The name of the module does not limit the module itself in some cases. For example, the receiving module may also be described as "a module for receiving a target service request sent by a user device based on the HTTP protocol".

[0206] The above mainly introduces that the execution subject is hardware. In the device, please briefly explain that the execution subject can be software. In some embodiments, the load balancing device provided by the embodiment of the present invention can be implemented in a combination of software and hardware. As an example, the load balancing device provided by the embodiment of the present invention can be a processor in the form of a hardware decoding processor, which is programmed to execute the load balancing method provided by the embodiment of the present invention. For example, the processor in the form of a hardware decoding processor can use one or more application-specific integrated circuits (ASIC, Application Specific Integrated Circuit), DSP, programmable logic device (PLD, Programmable Logic Device), complex programmable logic device (CPLD, Complex Programmable Logic Device), field programmable gate array (FPGA, Field-Programmable Gate Array) or other electronic components.

[0207] In other embodiments, the load balancing device provided by the embodiment of the present invention can be implemented in software. Figure 6 and Figure 7 The load balancing devices 600 and 700 stored in the memory are shown respectively, which can be software in the form of programs and plug-ins, and include a series of modules. The device 600 includes a receiving module 601, a processing module 602 and a feedback module 603; the device 700 includes a loop module 701; which is used to implement the load balancing method provided in the embodiment of the present application.

[0208] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.

Claims

1. A load balancing method, applied to a current partition server, characterized in that: include: Receiving a target service request sent by a user device based on the HTTP protocol; Based on the current load status, process the target service request or redirect the partition server based on the HTTP protocol; If the partition server is redirected based on the HTTP protocol, corresponding redirection information is fed back, so that the user equipment sends the target service request based on the redirection information; Wherein, redirecting the partition server based on the HTTP protocol includes: when the load state is low load, executing the task of merging the current partition server with other partition servers, and redirecting to the previous partition server based on the HTTP protocol; The merging with other partition servers includes at least one of the following: Setting a virtual identifier; the virtual identifier is used to redirect to the previous partition server based on the virtual identifier when receiving a service request after merging with other partition servers; When merging with other partition servers, if it is determined that the current load reaches a preset threshold, if no service request is received within a preset time period, the task of destroying the current partition server is executed; When merging with other partition servers or after executing the task of destroying the current partition server, when receiving a service request sent based on the redirection information, redirecting the partition server corresponding to the service request to the previous partition server; When merging with other partition servers, the merge is stopped when receiving the task of extending the partition server; After executing the task of destroying the current partition server, when receiving the task of extending the partition server, the task of rebuilding the partition server is executed to continue processing service requests or redirecting the partition server.

2. The method according to claim 1, characterized in that The processing of the target service request based on the current load status or redirecting the partition server based on the HTTP protocol includes any of the following: Acquire current information related to the load, and when determining that the load state is a medium load based on the information, process the target service request; The current information related to the load is obtained, and when the load state is determined to be low load or high load based on the information, the partition server is redirected based on the HTTP protocol.

3. The method according to claim 2, characterized in that The redirection partition server based on HTTP protocol also includes: When the load status is high, the task of expanding the partition server is initiated and redirected to the next partition server based on the HTTP protocol.

4. The method according to claim 1, characterized in that: Also includes: If the target service request is processed, corresponding request success information is fed back to receive the next service request sent by the user equipment.

5. A load balancing method, applied to a user device, characterized in that: include: For the target service request sent based on the HTTP protocol, repeat the following steps until the request success information is obtained: Receiving response information fed back by the partition server based on the current load status; the response information includes request success information corresponding to processing the target service request or redirection information corresponding to redirecting the partition server based on the HTTP protocol; When receiving the redirection information, sending the target service request based on the redirection information; Wherein, the redirection of the partition server based on the HTTP protocol includes: when the load state of the partition server is low load, the partition server performs the task of merging the current partition server with other partition servers, and redirects to the previous partition server based on the HTTP protocol; The merging with other partition servers includes at least one of the following: Setting a virtual identifier; the virtual identifier is used to redirect to the previous partition server based on the virtual identifier when receiving a service request after merging with other partition servers; When merging with other partition servers, if it is determined that the current load reaches a preset threshold, if no service request is received within a preset time period, the task of destroying the current partition server is executed; When merging with other partition servers or after executing the task of destroying the current partition server, when receiving a service request sent based on the redirection information, redirecting the partition server corresponding to the service request to the previous partition server; When merging with other partition servers, the merge is stopped when receiving the task of extending the partition server; After executing the task of destroying the current partition server, when receiving the task of extending the partition server, the task of rebuilding the partition server is executed to continue processing service requests or redirecting the partition server.

6. The method according to claim 5, characterized in that The target service request carries a preset partition identifier or a partition identifier corresponding to a partition server that successfully responded to a previous service request; the method further includes: Upon receiving the request success information, storing the partition identifier corresponding to the partition server that processes the target service request; The request success information includes a status code fed back by the partition server when processing the target service request or a reminder message generated when no information fed back by the partition server is received within a preset time period.

7. The method according to claim 5, characterized in that The redirection information includes a next partition identifier corresponding to a high load state or a previous partition identifier corresponding to a low load state; and resending the target service request based on the redirection information includes any one of the following: resending the target service request based on the next partition identifier; The target service request is resent based on the previous partition identifier.

8. A load balancing device, applied to the current partition server, characterized in that: include: A receiving module, used to receive a target service request sent by a user device based on the HTTP protocol; A processing module, used for processing the target service request based on the current load status or redirecting the partition server based on the HTTP protocol; A feedback module, configured to feedback corresponding redirection information if the partition server is redirected based on the HTTP protocol, so that the user equipment sends the target service request based on the redirection information; Wherein, when the processing module is used to redirect the partition server based on the HTTP protocol, it is also used to: when the load state is low load, perform the task of merging the current partition server with other partition servers, and redirect to the previous partition server based on the HTTP protocol; Wherein, when the processing module is used to merge with other partition servers, it is also used for at least one of the following: Setting a virtual identifier; the virtual identifier is used to redirect to the previous partition server based on the virtual identifier when receiving a service request after merging with other partition servers; When merging with other partition servers, if it is determined that the current load reaches a preset threshold, if no service request is received within a preset time period, the task of destroying the current partition server is executed; When merging with other partition servers or after executing the task of destroying the current partition server, when receiving a service request sent based on the redirection information, redirecting the partition server corresponding to the service request to the previous partition server; When merging with other partition servers, the merge is stopped when receiving the task of extending the partition server; After executing the task of destroying the current partition server, when receiving the task of extending the partition server, the task of rebuilding the partition server is executed to continue processing service requests or redirecting the partition server.

9. A load balancing device, applied to a user device, characterized in that: include: The loop module is used to repeatedly execute the following steps for the target service request sent based on the HTTP protocol until the request success information is obtained: Receiving response information fed back by the partition server based on the current load status; the response information includes request success information corresponding to processing the target service request or redirection information corresponding to redirecting the partition server based on the HTTP protocol; When receiving the redirection information, sending the target service request based on the redirection information; Wherein, the redirection of the partition server based on the HTTP protocol includes: when the load state of the partition server is low load, the partition server performs the task of merging the current partition server with other partition servers, and redirects to the previous partition server based on the HTTP protocol; The merging with other partition servers includes at least one of the following: Setting a virtual identifier; the virtual identifier is used to redirect to the previous partition server based on the virtual identifier when receiving a service request after merging with other partition servers; When merging with other partition servers, if it is determined that the current load reaches a preset threshold, if no service request is received within a preset time period, the task of destroying the current partition server is executed; When merging with other partition servers or after executing the task of destroying the current partition server, when receiving a service request sent based on the redirection information, redirecting the partition server corresponding to the service request to the previous partition server; When merging with other partition servers, the merge is stopped when receiving the task of extending the partition server; After executing the task of destroying the current partition server, when receiving the task of extending the partition server, the task of rebuilding the partition server is executed to continue processing service requests or redirecting the partition server.

10. An electronic device, characterized in that: It includes: one or more processors; Memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to: execute the load balancing method according to any one of claims 1 to 4 or 5 to 7.

11. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the load balancing method as described in any one of claims 1 to 4 or 5 to 7.

12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 or 5 to 7 are implemented.

Citation Information

Patent Citations

  • Access method, device and system of server

    CN101808118A

  • Distributed type dynamic cache expanding method and system supporting load balancing

    CN102244685A

  • Request transmission system, method and apparatus, and storage medium

    CN107948324A