CN108696554A - Load-balancing method and device - Google Patents

Load-balancing method and device Download PDF

Info

Publication number
CN108696554A
CN108696554A CN201710227853.2A CN201710227853A CN108696554A CN 108696554 A CN108696554 A CN 108696554A CN 201710227853 A CN201710227853 A CN 201710227853A CN 108696554 A CN108696554 A CN 108696554A
Authority
CN
China
Prior art keywords
server
execute server
task
execute
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201710227853.2A
Other languages
Chinese (zh)
Other versions
CN108696554B (en
Inventor
黎方
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201710227853.2A priority Critical patent/CN108696554B/en
Publication of CN108696554A publication Critical patent/CN108696554A/en
Application granted granted Critical
Publication of CN108696554B publication Critical patent/CN108696554B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

This application discloses load-balancing methods and device.One specific implementation mode of this method includes:The enabled instruction to goal task is received, which includes server identification;Determine the quantity for the task that each execute server in multiple execute server is currently assigned to and the maximum executing tasks parallelly quantity that preset, each execute server is supported;The quantity of not being assigned to currently for the execute server indicated by sky and the server identification in response to determining the server identification for task is not less than the maximum executing tasks parallelly quantity that the execute server indicated by the server identification is supported, the task quantity and identified each maximum executing tasks parallelly quantity being currently assigned to based on each execute server, it determines the target execute server in multiple execute server, and the goal task is sent to the target execute server.This embodiment improves the effects of load balancing, improve resource utilization.

Description

Load-balancing method and device
Technical field
This application involves field of computer technology, and in particular to Internet technical field more particularly to load-balancing method And device.
Background technology
With the development of computer technology, need to build the server being made of multiple servers in more and more scenes Cluster is to realize that task is handled.It is often necessary to rational task distribution be carried out to the server in server cluster, to reach negative Carry balanced purpose.
Existing load-balancing method is usually to determine the loading condition of each server every fixed duration, and then be based on institute Determining loading condition carries out task distribution.However, each server that existing mode is determined in task assignment procedure Loading condition be not current real time load situation, it is existing thus in the case where task quantity is more, concurrency is big Mode has that the effect of load balancing is poor.
Invention content
The purpose of the embodiment of the present application is to propose a kind of improved load-balancing method and device, to solve background above The technical issues of technology segment is mentioned.
In a first aspect, the embodiment of the present application provides a kind of load-balancing method, load-balanced server and multiple execution Server communication connects, and this method includes:The enabled instruction to goal task is received, enabled instruction includes being used to indicate multiple hold The server identification of in row server, performance objective task execute server;It determines each in multiple execute servers Parallel execute of maximum that the quantity for the task that execute server is currently assigned to and preset, each execute server are supported is appointed Business quantity;In response to determining what server identification was not assigned to currently for the execute server indicated by empty and server identification The quantity of task is based on institute not less than the maximum executing tasks parallelly quantity that the execute server indicated by server identification is supported The task quantity and identified each maximum executing tasks parallelly quantity that determining each execute server is currently assigned to, It determines the target execute server in multiple execute servers, and goal task is sent to target execute server.
In some embodiments, this method further includes:In response to determining that server identification is sky, by multiple execute servers In, the execute server of the quantity minimum of task that is currently assigned to is determined as target execute server, and target appointed Business is sent to target execute server.
In some embodiments, this method further includes:In response to determining that the execute server indicated by server identification is worked as Before the quantity of task that is assigned to be less than the maximum executing tasks parallelly that the execute server indicated by server identification is supported Execute server indicated by server identification is determined as target execute server, and goal task is sent to mesh by quantity Mark execute server.
In some embodiments, the task quantity that is currently assigned to based on each execute server and identified each Maximum executing tasks parallelly quantity determines the target execute server in multiple execute servers, including:Clothes are executed for multiple Each execute server being engaged in device determines quantity and the execution service of the task that the execute server is currently assigned to The ratio of the maximum executing tasks parallelly quantity of device;Execute server with minimum ratio is determined as target and executes service Device.
In some embodiments, after goal task is sent to target execute server, this method further includes:By mesh The quantity for the task that mark execute server is currently assigned to increases default value and is stored.
In some embodiments, after goal task is sent to target execute server, this method further includes:Response In execution completion message that receive the transmission of target execute server, to be used to indicate goal task executed completion, by target The quantity for the task that execute server is currently assigned to subtracts default value and is stored..
Second aspect, the embodiment of the present application provide a kind of load balancing apparatus, load-balanced server and multiple execution Server communication connects, which includes:Receiving unit is configured to receive the enabled instruction to goal task, enabled instruction Server identification including being used to indicate in multiple execute servers, performance objective task execute server;Determination unit, Be configured to determine the quantity of task that each execute server in multiple execute servers is currently assigned to and it is preset, The maximum executing tasks parallelly quantity that each execute server is supported;First transmission unit is configured to service in response to determining Device mark is not the quantity for the task that the execute server indicated by empty and server identification is currently assigned to not less than service The maximum executing tasks parallelly quantity that the indicated execute server of device mark is supported, based on identified each execute server The task quantity and identified each maximum executing tasks parallelly quantity being currently assigned to, determine in multiple execute servers Target execute server, and goal task is sent to target execute server.
In some embodiments, which further includes:Second transmission unit is configured in response to determining server identification For sky, the execute server of the quantity minimum of task in multiple execute servers, being currently assigned to is determined as target Execute server, and goal task is sent to target execute server.
In some embodiments, which further includes:Third transmission unit is configured in response to determining server identification The quantity for the task that indicated execute server is currently assigned to is less than the execute server branch indicated by server identification The maximum executing tasks parallelly quantity held, is determined as target execute server by the execute server indicated by server identification, And goal task is sent to target execute server.
In some embodiments, the first transmission unit is further configured to:For each in multiple execute servers The maximum of a execute server, the quantity for determining the task that the execute server is currently assigned to and the execute server is parallel The ratio of execution task quantity;Execute server with minimum ratio is determined as target execute server.
In some embodiments, device further includes:First storage unit is configured to the current quilt of target execute server The quantity of being assigned to for task increases default value and is stored.
In some embodiments, device further includes:Second storage unit is configured to execute clothes in response to receiving target Message is completed in execution that business device is sent, being used to indicate goal task executed completion, and target execute server is currently divided The quantity of being fitted on for task subtracts default value and is stored.
The third aspect, the embodiment of the present application provide a kind of load-balanced server, including:One or more processors; Storage device, for storing one or more programs, when one or more of programs are held by one or more of processors Row so that one or more of processors realize the method as described in any embodiment in above-mentioned load-balancing method.
Load-balancing method and device provided by the embodiments of the present application, by reception comprising server identification, to target The enabled instruction of task, the maximum for then determining the quantity for the task that each execute server is currently assigned to and supporting are parallel Execution task quantity, finally in response to determining that server identification is current not for the execute server indicated by empty and server identification The quantity of being assigned to for task is not less than the maximum executing tasks parallelly that the execute server indicated by server identification is supported Quantity, the task quantity being currently assigned to based on each execute server and identified each maximum executing tasks parallelly number Amount, determines target execute server, so that goal task is sent to target execute server, so as to be based on each executing clothes Be engaged in device real-time task situation carry out task distribution, ensure that the loading condition of obtained execute server accuracy and Real-time, and then the effect of load balancing is improved, it improves resource utilization.
Description of the drawings
By reading a detailed description of non-restrictive embodiments in the light of the attached drawings below, the application's is other Feature, objects and advantages will become more apparent upon:
Fig. 1 is that this application can be applied to exemplary system architecture figures therein;
Fig. 2 is the flow chart according to one embodiment of the load-balancing method of the application;
Fig. 3 is the schematic diagram according to an application scenarios of the load-balancing method of the application;
Fig. 4 is the flow chart according to another embodiment of the load-balancing method of the application;
Fig. 5 is the structural schematic diagram according to one embodiment of the load balancing apparatus of the application;
Fig. 6 is adapted for the structural schematic diagram of the computer system of the server for realizing the embodiment of the present application.
Specific implementation mode
The application is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to Convenient for description, is illustrated only in attached drawing and invent relevant part with related.
It should be noted that in the absence of conflict, the features in the embodiments and the embodiments of the present application can phase Mutually combination.The application is described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Fig. 1 shows the exemplary system architecture of the load-balancing method or load balancing apparatus that can apply the application 100。
As shown in Figure 1, system architecture 100 may include load-balanced server 101, network 102 and execute server 103,104,105.Network 102 between load-balanced server 101 and execute server 103,104,105 providing communication The medium of link.Network 102 may include various connection types, such as wired, wireless communication link or fiber optic cables etc..
Load-balanced server 101 can receive the enabled instruction of various tasks, can also obtain execute server 103, 104,105 current task situations (such as the quantity of being currently assigned to for task, the maximum executing tasks parallelly quantity of support Deng), acquired task situation can also be carried out the processing such as to analyze, and send out task by network 102 based on handling result It send to the respective server in execute server 103,104,105.
In addition, system architecture 100 can also include database 106, database 106 can be for managing various data , various types of databases, such as the database for storing the current task situation of execute server 103,104,105 (such as redis etc.).At this point, load-balanced server 101 can in real time from database 106 obtain execute server 103, 104,105 task situation.
Execute server 103,104,105 can be performed in parallel from 101 received task of load-balanced server.Separately Outside, execute server 103,104,105 can also be performed in parallel received task, and each execute server 103, 104,105 it can be configured with task queue, for storing having distributed and having had not carried out for task.
It should be noted that the load-balancing method that the embodiment of the present application is provided is generally by load-balanced server 101 It executes, correspondingly, load balancing apparatus is generally positioned in load-balanced server 101.
It should be understood that the number of the terminal device, network and server in Fig. 1 is only schematical.According to realization need It wants, can have any number of load-balanced server, network and execute server.
With continued reference to Fig. 2, the flow 200 of one embodiment of the load-balancing method according to the application is shown.It is described Load-balancing method, include the following steps:
Step 201, the enabled instruction to goal task is received.
In the present embodiment, load-balancing method operation thereon electronic equipment (such as load balancing shown in FIG. 1 clothes Business device 101) enabled instruction to goal task can be received, wherein above-mentioned enabled instruction may include be used to indicate with it is above-mentioned In multiple execute servers (such as execute server shown in FIG. 1 103,104,105) of electronic equipment communication connection, execution The server identification of the execute server of above-mentioned goal task.It should be pointed out that each in above-mentioned multiple execute servers A execute server corresponds to a server identification, and server identification can serve to indicate that and distinguish each execute server.This Outside, server identification can be the title of server, the IP address of server and/or by any character (such as number, letter, Symbol etc.) character string etc. that constitutes.It should be noted that above-mentioned goal task can be arbitrary pending task, and should Task can be performed performed by server.
In practice, above-mentioned electronic equipment can connect with above-mentioned multiple execute servers by wired connection mode or wirelessly The mode of connecing establishes connection.It should be pointed out that above-mentioned radio connection can include but is not limited to 3G/4G connections, WiFi connects Connect, bluetooth connection, WiMAX connections, Zigbee connections, UWB (ultra wideband) connections and other it is currently known or will Come the radio connection developed.
It should be noted that above-mentioned enabled instruction, which can be automatic trigger or manual triggering mode, is sent to above-mentioned electronics Equipment does not limit herein.Wherein, automatic trigger can be that each pre-set preset duration sends enabled instruction, on It can be that staff sends enabled instruction manually to state triggering manually.
Step 202, the quantity for the task that each execute server in multiple execute servers is currently assigned to is determined The maximum executing tasks parallelly quantity supported with preset, each execute server.
In the present embodiment, above-mentioned electronic equipment is after receiving above-mentioned enabled instruction, can from above-mentioned electronic equipment Each execution service in above-mentioned multiple execute servers is obtained in connected database (such as database 106 shown in FIG. 1) The maximum executing tasks parallelly quantity that the quantity for the task that device is currently assigned to and preset, each execute server are supported. Herein, the quantity of being currently assigned to for each execute server, the execute server for task can be it is current The sum of the quantity of task stored in the quantity of the task of execution and the task queue of the execute server.Each executes clothes Business device can correspond to a preset maximum executing tasks parallelly quantity, which can be based on being somebody's turn to do Being pre-configured with for execute server and determine.It should be noted that above-mentioned electronic equipment directly can execute service from each The quantity of being currently assigned to for task and maximum executing tasks parallelly quantity are obtained in device.
In practice, above-mentioned database can be stored with and the relevant various data of each execute server.It is right as signal In each execute server, above-mentioned database, which can be stored with, to be held using the server identification of the execute server as key, with this The quantity for the task that row server is currently assigned to is the data of the key-value pair form of value.Meanwhile may be used also in above-mentioned database To be stored with using the server identification of the execute server as key, with maximum executing tasks parallelly corresponding with the execute server Quantity is the data of the key-value pair form of value.It should be noted that for newly deployed execute server, above-mentioned database is deposited The initial value of the quantity of task store up, that the newly deployed execute server is assigned to is zero.
Step 203, in response to determining that server identification is current not for the execute server indicated by empty and server identification The quantity of being assigned to for task is not less than the maximum executing tasks parallelly that the execute server indicated by server identification is supported Quantity is held parallel based on the task quantity and identified each maximum that identified each execute server is currently assigned to Row task quantity determines the target execute server in multiple execute servers, and goal task is sent to target and executes clothes Business device.
In the present embodiment, above-mentioned electronic equipment can determine first server identification that step 201 receives whether be It is empty.Then, it is not sky in response to the above-mentioned server identification of determination, above-mentioned electronic equipment can will be indicated by above-mentioned server identification The quantity of task that is currently assigned to of execute server determines the maximum of each execute server support with step 202 Parallel number of executions is compared.Later, the quantity of being currently assigned in response to the determining execute server for task is not small In the parallel number of executions of maximum that the execute server is supported, above-mentioned electronic equipment can be each based on determined by step 202 The task quantity and identified each maximum executing tasks parallelly quantity that execute server is currently assigned to, determine above-mentioned more Target execute server in a execute server.Finally, goal task is sent to target execute server.
In the present embodiment, above-mentioned electronic equipment by the task quantity that is currently assigned to each execute server and Identified each maximum executing tasks parallelly quantity carries out the mode of numerical computations, determines in above-mentioned multiple execute servers Target execute server.
In some optional realization methods of the present embodiment, for each execution in above-mentioned multiple execute servers Server, above-mentioned electronic equipment can determine that the quantity for the task that the execute server is currently assigned to executes clothes with this first The ratio of the maximum executing tasks parallelly quantity of business device;Later, the execute server with minimum ratio is determined as target to hold Row server.
In some optional realization methods of the present embodiment, for each execution in above-mentioned multiple execute servers Server, above-mentioned electronic equipment can determine maximum executing tasks parallelly quantity and the execution service of the execute server first The difference of the quantity for the task that device is currently assigned to;Later, the execute server of had minimal difference is determined as target Execute server.
In some optional realization methods of the present embodiment, for each execution in above-mentioned multiple execute servers Server, above-mentioned electronic equipment can determine maximum executing tasks parallelly quantity and the execution service of the execute server first The difference of the quantity for the task that device is currently assigned to;Later, maximum parallel execution of the difference with the execute server is determined The ratio of task quantity;Finally, the execute server with minimum ratio is determined as target execute server.
It should be noted that above-mentioned electronic equipment, which is also based on other numerical operations defaulted to, determines above-mentioned multiple hold Target execute server in row server, details are not described herein.
It is a schematic diagram according to the application scenarios of the load-balancing method of the present embodiment with continued reference to Fig. 3, Fig. 3. In the application scenarios of Fig. 3, load-balanced server 301 receives the enabled instruction with server identification and starts execution 302 first; Then, load-balanced server 301 determines the task that each execute server in multiple execute servers is currently assigned to Quantity 303 and preset, each execute server support maximum executing tasks parallelly quantity 304;Bear determine it is above-mentioned The quantity for the task that server identification is not assigned to currently for the execute server indicated by empty and above-mentioned server identification is not After the maximum executing tasks parallelly quantity supported less than the execute server indicated by above-mentioned server identification, it is based on each execution The task quantity 303 and identified each maximum executing tasks parallelly quantity 304 that server is currently assigned to, determine above-mentioned Target execute server 305 in multiple execute servers, and goal task 306 is sent to target execute server 305.
The method that above-described embodiment of the application provides is by receiving startup comprising server identification, to goal task Instruction then determines the maximum executing tasks parallelly number of the quantity and support of the task that each execute server is currently assigned to Amount is not finally execute server indicated by empty and above-mentioned server identification currently quilt in response to the above-mentioned server identification of determination Execute parallel not less than the maximum that the execute server indicated by above-mentioned server identification is supported of the quantity of being assigned to for task is appointed Business quantity, the task quantity being currently assigned to based on each execute server and identified each maximum executing tasks parallelly Quantity determines target execute server, each so as to be based on so that above-mentioned goal task is sent to target execute server The real-time task situation of execute server carries out the distribution of task, ensure that the standard of the loading condition of obtained execute server True property and real-time, and then the effect of load balancing is improved, it improves resource utilization.
With further reference to Fig. 4, it illustrates the flows 400 of another embodiment of load-balancing method.The load balancing The flow 400 of method, includes the following steps:
Step 401, the enabled instruction to goal task is received.
In the present embodiment, load-balancing method operation thereon electronic equipment (such as load balancing shown in FIG. 1 clothes Business device 101) enabled instruction to goal task can be received, wherein above-mentioned enabled instruction may include be used to indicate with it is above-mentioned In multiple execute servers (such as execute server shown in FIG. 1 103,104,105) of electronic equipment communication connection, execution The server identification of the execute server of above-mentioned goal task.
Step 402, the quantity for the task that each execute server in multiple execute servers is currently assigned to is determined The maximum executing tasks parallelly quantity supported with preset, each execute server.
In the present embodiment, above-mentioned electronic equipment is after receiving above-mentioned enabled instruction, can from above-mentioned electronic equipment Each execution service in above-mentioned multiple execute servers is obtained in connected database (such as database 106 shown in FIG. 1) The maximum executing tasks parallelly quantity that the quantity for the task that device is currently assigned to and preset, each execute server are supported. Herein, the quantity of being currently assigned to for each execute server, the execute server for task can be it is current The sum of the quantity of task stored in the quantity of the task of execution and the task queue of the execute server.
Step 403, in response to determining that server identification is current not for the execute server indicated by empty and server identification The quantity of being assigned to for task is not less than the maximum executing tasks parallelly that the execute server indicated by server identification is supported Quantity determines the ratio of the quantity and maximum executing tasks parallelly quantity of the task that each execute server is currently assigned to, Execute server corresponding to minimum ratio in identified ratio is determined as target execute server, and by goal task It is sent to target execute server.
In the present embodiment, above-mentioned electronic equipment can determine first server identification that step 401 receives whether be It is empty.It is sky in response to the above-mentioned server identification of determination, step 405 can be executed;It is not in response to the above-mentioned server identification of determination Sky, the quantity for the task that the execute server indicated by above-mentioned server identification can be currently assigned to by above-mentioned electronic equipment The parallel number of executions of maximum supported with the execute server is compared.In response to determining that the execute server is currently assigned The quantity of arriving for task is less than the parallel number of executions of maximum that the execute server is supported, can execute step 406.In response to true The quantity for the task that the fixed execute server is currently assigned to is parallel not less than the maximum that the execute server is supported to execute number Amount, above-mentioned electronic equipment can determine that each execute server in above-mentioned multiple execute servers is currently assigned to first Task quantity and the execute server maximum executing tasks parallelly quantity ratio;It later, will be in identified ratio Minimum ratio corresponding to execute server be determined as target execute server, and above-mentioned goal task is sent to target and is held Row server.
Step 404, in response to determining that server identification is sky, by it is in multiple execute servers, be currently assigned to The execute server of the quantity minimum of task is determined as target execute server, and goal task is sent to target and executes service Device.
In the present embodiment, in response to determining that the server identification received by step 401 is sky, above-mentioned electronic equipment can The execute server of the quantity minimum of task in above-mentioned multiple execute servers, being currently assigned to is determined as target Execute server, and above-mentioned goal task is sent to the target execute server.
Step 405, the number of being currently assigned in response to the execute server indicated by determining server identification for task Amount is less than the maximum executing tasks parallelly quantity that the execute server indicated by server identification is supported, by server identification meaning The execute server shown is determined as target execute server, and goal task is sent to the target execute server.
In the present embodiment, it is currently assigned in response to the execute server indicated by the above-mentioned server identification of determination The quantity of task is less than the maximum executing tasks parallelly quantity that the execute server indicated by above-mentioned server identification is supported, above-mentioned Execute server indicated by above-mentioned server identification directly can be determined as target execute server by electronic equipment, and by mesh Mark task is sent to the target execute server.
Step 406, the quantity for the task that target execute server is currently assigned to is increased into default value and deposited Storage.
In the present embodiment, after the completion of step 404 or step 405 or step 406 execute, above-mentioned electronic equipment can carry The quantity of being currently assigned to for the task corresponding to the server identification for the destination server that above-mentioned database stored is taken, and It is stored into above-mentioned database after the quantity is increased default value, in practice, which can be 1.
Step 407, in response to receive target execute server transmission, be used to indicate goal task executed completion It executes and completes message, the quantity for the task that target execute server is currently assigned to is subtracted into default value and is stored.
In the present embodiment, in response to receive target execute server transmission, be used to indicate goal task executed Message is completed in the execution of completion, and above-mentioned electronic equipment can extract the server mark for the destination server that above-mentioned database is stored The quantity for knowing corresponding being currently assigned to for task, stores after the quantity extracted is subtracted default value to above-mentioned database In, in practice, which can be 1.
Figure 4, it is seen that compared with the corresponding embodiments of Fig. 2, the flow of the load-balancing method in the present embodiment 400 highlight processing step, the execute server of server identification instruction to the situation that the server identification received is sky The quantity of being currently assigned to for task is less than parallel execute of maximum that the execute server indicated by server identification is supported and appoints The processing step of the case where quantity of being engaged in, and send the more new task related data after goal task to target execute server The step of.As a result, the scheme of the present embodiment description may be implemented it is a variety of in the case of task distribution, it is equal to further improve load The effect of weighing apparatus, and further improve resource utilization
With further reference to Fig. 5, as the realization to method shown in above-mentioned each figure, this application provides a kind of load balancing dresses The one embodiment set, the device embodiment is corresponding with embodiment of the method shown in Fig. 2, which specifically can be applied to respectively In kind electronic equipment.
As shown in figure 5, the load balancing apparatus 500 described in the present embodiment includes:Receiving unit 501 is configured to receive Enabled instruction to goal task, above-mentioned enabled instruction include be used to indicate it is in above-mentioned multiple execute servers, execute it is above-mentioned The server identification of the execute server of goal task;Determination unit 502 is configured to determine in above-mentioned multiple execute servers The quantity of task that is currently assigned to of each execute server and the maximum supported of preset, each execute server it is parallel Execution task quantity;First transmission unit 503 is configured to not be empty and above-mentioned service in response to the above-mentioned server identification of determination The quantity for the task that the indicated execute server of device mark is currently assigned to is not less than indicated by above-mentioned server identification The maximum executing tasks parallelly quantity that execute server is supported, the task quantity being currently assigned to based on each execute server With identified each maximum executing tasks parallelly quantity, the target execute server in above-mentioned multiple execute servers is determined, And above-mentioned goal task is sent to above-mentioned target execute server.
In the present embodiment, the startup that can be received to goal task of 500 receiving unit 501 of above-mentioned load balancing apparatus Instruction, wherein above-mentioned enabled instruction may include being used to indicate the multiple execution communicated to connect with above-mentioned load balancing apparatus 500 Execute server in server (such as execute server shown in FIG. 1 103,104,105), executing above-mentioned goal task Server identification.
In the present embodiment, above-mentioned determination unit 502 is after receiving above-mentioned enabled instruction, can be from equal with above-mentioned load It is each in the middle above-mentioned multiple execute servers of acquisition of the connected database (such as database 106 shown in FIG. 1) of device 500 that weighs Parallel execute of maximum that the quantity for the task that execute server is currently assigned to and preset, each execute server are supported is appointed Business quantity.Herein, the quantity of being currently assigned to for each execute server, the execute server for task can be worked as Before the quantity of task that is carrying out and the sum of the quantity of task stored in the task queue of the execute server.
In the present embodiment, above-mentioned first transmission unit 503 can determine first the server identification received whether be It is empty.Then, it is not sky in response to the above-mentioned server identification of determination, above-mentioned first transmission unit 503 can be by above-mentioned server mark The maximum of the quantity and execute server support of knowing the task that indicated execute server is currently assigned to is parallel to be executed Quantity is compared.Later, the quantity of being currently assigned in response to the determining execute server for task is not less than the execution The parallel number of executions of maximum that server is supported, above-mentioned first transmission unit 503 can be based on each execute server currently quilt The task quantity and identified each maximum executing tasks parallelly quantity being assigned to, determine in above-mentioned multiple execute servers Target execute server.Finally, goal task is sent to target execute server.Herein, above-mentioned first transmission unit 503 is logical Cross the task quantity that each execute server is currently assigned to and identified each maximum executing tasks parallelly quantity into The mode of row numerical computations determines the target execute server in above-mentioned multiple execute servers.
In some optional realization methods of the present embodiment, above-mentioned first transmission unit 503 can further configure use In for each execute server in above-mentioned multiple execute servers, times that the execute server is currently assigned to is determined The ratio of the quantity of business and the maximum executing tasks parallelly quantity of the execute server;By the minimum ratio in identified ratio Corresponding execute server is determined as target execute server.
In some optional realization methods of the present embodiment, above-mentioned load balancing apparatus 500 can also include the second hair Send unit (not shown).Wherein, above-mentioned second transmission unit may be configured in response to the above-mentioned server identification of determination For sky, the execute server of the quantity minimum of task in above-mentioned multiple execute servers, being currently assigned to is determined as Target execute server, and above-mentioned goal task is sent to above-mentioned target execute server.
In some optional realization methods of the present embodiment, above-mentioned load balancing apparatus 500 can also include that third is sent out Send unit (not shown).Wherein, above-mentioned third transmission unit may be configured in response to the above-mentioned server identification of determination The quantity for the task that indicated execute server is currently assigned to is less than the execution service indicated by above-mentioned server identification Execute server indicated by above-mentioned server identification is determined as target and executed by the maximum executing tasks parallelly quantity that device is supported Server, and above-mentioned goal task is sent to above-mentioned target execute server.
In some optional realization methods of the present embodiment, above-mentioned load balancing apparatus 500 can also be deposited including first Storage unit (not shown).Wherein, above-mentioned first storage unit may be configured to above-mentioned target execute server is current The quantity of being assigned to for task increases default value and is stored.
In some optional realization methods of the present embodiment, above-mentioned load balancing apparatus 500 can also be deposited including second Storage unit (not shown).Wherein, above-mentioned second storage unit may be configured to execute in response to receiving above-mentioned target Message is completed in execution that server is sent, being used to indicate above-mentioned goal task executed completion, and above-mentioned target is executed service The quantity for the task that device is currently assigned to subtracts above-mentioned default value and is stored.
The device that above-described embodiment of the application provides, by receiving unit 501 receive it is comprising server identification, to mesh The enabled instruction of mark task, then determination unit 502 determine the task that each execute server is currently assigned to quantity and The maximum executing tasks parallelly quantity of support, last first transmission unit 503 are not sky in response to the above-mentioned server identification of determination And the quantity of task that the execute server indicated by above-mentioned server identification is currently assigned to is not less than above-mentioned server mark Know the maximum executing tasks parallelly quantity that indicated execute server is supported, is currently assigned to based on each execute server Task quantity and identified each maximum executing tasks parallelly quantity, target execute server is determined, so as to by above-mentioned mesh Mark task is sent to target execute server, and point of task is carried out so as to the real-time task situation based on each execute server Hair, ensure that the accuracy and real-time of the loading condition of obtained execute server, and then improve the effect of load balancing Fruit improves resource utilization.
Below with reference to Fig. 6, it illustrates the computer systems 600 suitable for the server for realizing the embodiment of the present application Structural schematic diagram.Server shown in Fig. 6 is only an example, should not be to the function and use scope band of the embodiment of the present application Carry out any restrictions.
As shown in fig. 6, computer system 600 includes central processing unit (CPU) 601, it can be read-only according to being stored in Program in memory (ROM) 602 or be loaded into the program in random access storage device (RAM) 603 from storage section 608 and Execute various actions appropriate and processing.In RAM 603, also it is stored with system 600 and operates required various programs and data. CPU 601, ROM 602 and RAM 603 are connected with each other by bus 604.Input/output (I/O) interface 605 is also connected to always Line 604.
It is connected to I/O interfaces 605 with lower component:Importation 606 including keyboard, mouse etc.;It is penetrated including such as cathode The output par, c 607 of spool (CRT), liquid crystal display (LCD) etc. and loud speaker etc.;Storage section 608 including hard disk etc.; And the communications portion 609 of the network interface card including LAN card, modem etc..Communications portion 609 via such as because The network of spy's net executes communication process.Driver 610 is also according to needing to be connected to I/O interfaces 605.Detachable media 611, such as Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on driver 610, as needed in order to be read from thereon Computer program be mounted into storage section 608 as needed.
Particularly, in accordance with an embodiment of the present disclosure, it may be implemented as computer above with reference to the process of flow chart description Software program.For example, embodiment of the disclosure includes a kind of computer program product comprising be carried on computer-readable medium On computer program, which includes the program code for method shown in execution flow chart.In such reality It applies in example, which can be downloaded and installed by communications portion 609 from network, and/or from detachable media 611 are mounted.When the computer program is executed by central processing unit (CPU) 601, limited in execution the present processes Above-mentioned function.It should be noted that computer-readable medium described herein can be computer-readable signal media or Computer readable storage medium either the two arbitrarily combines.Computer readable storage medium for example can be --- but Be not limited to --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or arbitrary above combination. The more specific example of computer readable storage medium can include but is not limited to:Electrical connection with one or more conducting wires, Portable computer diskette, hard disk, random access storage device (RAM), read-only memory (ROM), erasable type may be programmed read-only deposit Reservoir (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory Part or above-mentioned any appropriate combination.In this application, computer readable storage medium can any be included or store The tangible medium of program, the program can be commanded the either device use or in connection of execution system, device.And In the application, computer-readable signal media may include the data letter propagated in a base band or as a carrier wave part Number, wherein carrying computer-readable program code.Diversified forms may be used in the data-signal of this propagation, including but not It is limited to electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be computer Any computer-readable medium other than readable storage medium storing program for executing, the computer-readable medium can send, propagate or transmit use In by instruction execution system, device either device use or program in connection.Include on computer-readable medium Program code can transmit with any suitable medium, including but not limited to:Wirelessly, electric wire, optical cable, RF etc., Huo Zheshang Any appropriate combination stated.
Flow chart in attached drawing and block diagram, it is illustrated that according to the system of the various embodiments of the application, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part for a part for one module, program segment, or code of table, the module, program segment, or code includes one or more uses The executable instruction of the logic function as defined in realization.It should also be noted that in some implementations as replacements, being marked in box The function of note can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are actually It can be basically executed in parallel, they can also be executed in the opposite order sometimes, this is depended on the functions involved.Also it to note Meaning, the combination of each box in block diagram and or flow chart and the box in block diagram and or flow chart can be with holding The dedicated hardware based system of functions or operations as defined in row is realized, or can use specialized hardware and computer instruction Combination realize.
Being described in unit involved in the embodiment of the present application can be realized by way of software, can also be by hard The mode of part is realized.Described unit can also be arranged in the processor, for example, can be described as:A kind of processor packet Include receiving unit, determination unit and the first transmission unit.Wherein, the title of these units is not constituted to this under certain conditions The restriction of unit itself, for example, receiving unit is also described as " receiving the unit of the enabled instruction to goal task ".
As on the other hand, present invention also provides a kind of computer-readable medium, which can be Included in device described in above-described embodiment;Can also be individualism, and without be incorporated the device in.Above-mentioned calculating Machine readable medium carries one or more program, when said one or multiple programs are executed by the device so that should Device:The enabled instruction to goal task is received, which includes server identification;It determines in multiple execute server The quantity of task that is currently assigned to of each execute server and the maximum supported of preset, each execute server it is parallel Execution task quantity;In response to determining that the server identification is current not for the execute server indicated by the empty and server identification Execute parallel not less than the maximum that the execute server indicated by the server identification is supported of the quantity of being assigned to for task is appointed Business quantity, the task quantity being currently assigned to based on each execute server and identified each maximum executing tasks parallelly Quantity determines the target execute server in multiple execute server, and the goal task is sent to the target and executes clothes Business device.
Above description is only the preferred embodiment of the application and the explanation to institute's application technology principle.People in the art Member should be appreciated that invention scope involved in the application, however it is not limited to technology made of the specific combination of above-mentioned technical characteristic Scheme, while should also cover in the case where not departing from foregoing invention design, it is carried out by above-mentioned technical characteristic or its equivalent feature Other technical solutions of arbitrary combination and formation.Such as features described above has similar work(with (but not limited to) disclosed herein Can technical characteristic replaced mutually and the technical solution that is formed.

Claims (14)

1. a kind of load-balancing method for load-balanced server, which is characterized in that the load-balanced server with it is more A execute server communication connection, the method includes:
Receive enabled instruction to goal task, the enabled instruction include be used to indicate it is in the multiple execute server, Execute the server identification of the execute server of the goal task;
Determine the task that each execute server in the multiple execute server is currently assigned to quantity and it is preset, The maximum executing tasks parallelly quantity that each execute server is supported;
Do not divided currently for the execute server indicated by the empty and described server identification in response to the determination server identification The quantity of being fitted on for task is not less than the maximum executing tasks parallelly that the execute server indicated by the server identification is supported Quantity is held parallel based on the task quantity and identified each maximum that identified each execute server is currently assigned to Row task quantity determines the target execute server in the multiple execute server, and the goal task is sent to institute State target execute server.
2. load-balancing method according to claim 1, which is characterized in that the method further includes:
It is sky in response to the determination server identification, by task in the multiple execute server, being currently assigned to The execute server of quantity minimum be determined as target execute server, and the goal task is sent to the target and is executed Server.
3. load-balancing method according to claim 1, which is characterized in that the method further includes:
The quantity of being currently assigned in response to the execute server indicated by the determination server identification for task is less than institute The maximum executing tasks parallelly quantity that the execute server indicated by server identification is supported is stated, by server identification meaning The execute server shown is determined as target execute server, and the goal task is sent to the target execute server.
4. load-balancing method according to claim 1, which is characterized in that described to be based on each execute server currently quilt The task quantity and identified each maximum executing tasks parallelly quantity being assigned to, determine in the multiple execute server Target execute server, including:
For each execute server in the multiple execute server, determine what the execute server was currently assigned to The ratio of the quantity of task and the maximum executing tasks parallelly quantity of the execute server;
Execute server with minimum ratio is determined as target execute server.
5. according to the load-balancing method described in one of claim 1-4, which is characterized in that send out the goal task described It send to the target execute server, the method further includes:
The quantity for the task that the target execute server is currently assigned to is increased into default value and is stored.
6. load-balancing method according to claim 5, which is characterized in that the goal task is sent to institute described After stating target execute server, the method further includes:
In response to receiving execution that the target execute server is sent, being used to indicate the goal task executed completion Message is completed, the quantity for the task that the target execute server is currently assigned to is subtracted into the default value and is deposited Storage.
7. a kind of load balancing apparatus for load-balanced server, which is characterized in that the load-balanced server with it is more A execute server communication connection, described device include:
Receiving unit is configured to receive the enabled instruction to goal task, and the enabled instruction is described more including being used to indicate The server identification of execute server in a execute server, executing the goal task;
Determination unit is configured to determine times that each execute server in the multiple execute server is currently assigned to The maximum executing tasks parallelly quantity that the quantity of business and preset, each execute server are supported;
First transmission unit is configured to not be indicated by the empty and described server identification in response to the determination server identification The quantity of task that is currently assigned to of execute server not less than the execute server branch indicated by the server identification The maximum executing tasks parallelly quantity held, the task quantity being currently assigned to based on identified each execute server and institute Determining each maximum executing tasks parallelly quantity, determines the target execute server in the multiple execute server, and will The goal task is sent to the target execute server.
8. load balancing apparatus according to claim 7, which is characterized in that described device further includes:
Second transmission unit is configured in response to the determination server identification be sky, will be in the multiple execute server , the execute server of the quantity minimum of being currently assigned to for task be determined as target execute server, and by the target Task is sent to the target execute server.
9. load balancing apparatus according to claim 7, which is characterized in that described device further includes:
Third transmission unit is configured to currently be assigned in response to the execute server indicated by the determination server identification The quantity of arriving for task is less than the maximum executing tasks parallelly quantity that the execute server indicated by the server identification is supported, Execute server indicated by the server identification is determined as target execute server, and the goal task is sent to The target execute server.
10. load balancing apparatus according to claim 7, which is characterized in that first transmission unit further configures For:
For each execute server in the multiple execute server, determine what the execute server was currently assigned to The ratio of the quantity of task and the maximum executing tasks parallelly quantity of the execute server;By the execution service with minimum ratio Device is determined as target execute server.
11. according to the load balancing apparatus described in one of claim 7-10, which is characterized in that described device further includes:
First storage unit, the quantity increase for being configured to currently being assigned to the target execute server of the task are default Numerical value is simultaneously stored.
12. load balancing apparatus according to claim 11, which is characterized in that described device further includes:
Second storage unit, be configured in response to receive it is that the target execute server is sent, be used to indicate the mesh Message is completed in the execution that mark task executed is completed, and the quantity for the task that the target execute server is currently assigned to is subtracted The default value is simultaneously stored.
13. a kind of load-balanced server, including:
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors so that one or more of processors are real The now method as described in any in claim 1-6.
14. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the program is by processor The method as described in any in claim 1-6 is realized when execution.
CN201710227853.2A 2017-04-10 2017-04-10 Load balancing method and device Active CN108696554B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710227853.2A CN108696554B (en) 2017-04-10 2017-04-10 Load balancing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710227853.2A CN108696554B (en) 2017-04-10 2017-04-10 Load balancing method and device

Publications (2)

Publication Number Publication Date
CN108696554A true CN108696554A (en) 2018-10-23
CN108696554B CN108696554B (en) 2021-11-30

Family

ID=63843190

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710227853.2A Active CN108696554B (en) 2017-04-10 2017-04-10 Load balancing method and device

Country Status (1)

Country Link
CN (1) CN108696554B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109885404A (en) * 2019-02-01 2019-06-14 新华三技术有限公司 A kind of command processing method and device
CN110618899A (en) * 2019-09-25 2019-12-27 浙江中控技术股份有限公司 Data storage method and device
CN112540796A (en) * 2019-09-23 2021-03-23 阿里巴巴集团控股有限公司 Instruction processing device, processor and processing method thereof

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102685237A (en) * 2012-05-16 2012-09-19 东南大学 Method for requesting session maintaining and dispatching in cluster environment
CN102710615A (en) * 2012-05-15 2012-10-03 北京像素软件科技股份有限公司 Method for equalizing dynamic load of network game
CN103188277A (en) * 2011-12-27 2013-07-03 中国电信股份有限公司 Load energy consumption management system, method and server
CN103457869A (en) * 2013-08-28 2013-12-18 北京星网锐捷网络技术有限公司 Conversation maintaining method and device
CN104780184A (en) * 2014-01-09 2015-07-15 华耀(中国)科技有限公司 Method of using geographical location information for load balancing
CN104811488A (en) * 2015-04-13 2015-07-29 深信服网络科技(深圳)有限公司 Load balancing equipment-based session keeping method and system and load balancing equipment
CN105072182A (en) * 2015-08-10 2015-11-18 北京佳讯飞鸿电气股份有限公司 Load balancing method, load balancer and user terminal
CN105871985A (en) * 2015-12-10 2016-08-17 乐视网信息技术(北京)股份有限公司 Data access request processing method and apparatus, server, client and system
CN106453116A (en) * 2016-11-03 2017-02-22 上海斐讯数据通信技术有限公司 SDN (Software Defined Network) based least connection load balancing method and system

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103188277A (en) * 2011-12-27 2013-07-03 中国电信股份有限公司 Load energy consumption management system, method and server
CN102710615A (en) * 2012-05-15 2012-10-03 北京像素软件科技股份有限公司 Method for equalizing dynamic load of network game
CN102685237A (en) * 2012-05-16 2012-09-19 东南大学 Method for requesting session maintaining and dispatching in cluster environment
CN103457869A (en) * 2013-08-28 2013-12-18 北京星网锐捷网络技术有限公司 Conversation maintaining method and device
CN104780184A (en) * 2014-01-09 2015-07-15 华耀(中国)科技有限公司 Method of using geographical location information for load balancing
CN104811488A (en) * 2015-04-13 2015-07-29 深信服网络科技(深圳)有限公司 Load balancing equipment-based session keeping method and system and load balancing equipment
CN105072182A (en) * 2015-08-10 2015-11-18 北京佳讯飞鸿电气股份有限公司 Load balancing method, load balancer and user terminal
CN105871985A (en) * 2015-12-10 2016-08-17 乐视网信息技术(北京)股份有限公司 Data access request processing method and apparatus, server, client and system
CN106453116A (en) * 2016-11-03 2017-02-22 上海斐讯数据通信技术有限公司 SDN (Software Defined Network) based least connection load balancing method and system

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109885404A (en) * 2019-02-01 2019-06-14 新华三技术有限公司 A kind of command processing method and device
CN109885404B (en) * 2019-02-01 2021-07-20 新华三技术有限公司 Instruction processing method and device
CN112540796A (en) * 2019-09-23 2021-03-23 阿里巴巴集团控股有限公司 Instruction processing device, processor and processing method thereof
CN112540796B (en) * 2019-09-23 2024-05-07 阿里巴巴集团控股有限公司 Instruction processing device, processor and processing method thereof
CN110618899A (en) * 2019-09-25 2019-12-27 浙江中控技术股份有限公司 Data storage method and device
CN110618899B (en) * 2019-09-25 2022-02-22 浙江中控技术股份有限公司 Data storage method and device

Also Published As

Publication number Publication date
CN108696554B (en) 2021-11-30

Similar Documents

Publication Publication Date Title
CN108182111A (en) Task scheduling system, method and apparatus
CN109697075A (en) File updating method, system and device
CN108337314B (en) Distributed system, information processing method and device for primary server
CN109647719A (en) Method and apparatus for sorting cargo
CN109408205A (en) Method for scheduling task and device based on hadoop cluster
CN108874528A (en) Distributed task scheduling storage system and distributed task scheduling storage/read method
CN107845011B (en) Method and apparatus for handling order
CN108933822B (en) Method and apparatus for handling information
CN110391938B (en) Method and apparatus for deploying services
CN108846753A (en) Method and apparatus for handling data
CN108696554A (en) Load-balancing method and device
CN109783197A (en) Dispatching method and device for program runtime environment
CN111444077A (en) Method and device for generating flow node test data
CN108933695A (en) Method and apparatus for handling information
CN109240802A (en) request processing method and device
CN108733527A (en) System, method and apparatus for test server function
CN108399046A (en) File operation requests treating method and apparatus
CN109614549B (en) Method and apparatus for pushed information
CN109873731A (en) Test method, device and system
CN110472900A (en) Method and apparatus for determining article storage location
CN110113176A (en) Information synchronization method and device for configuration server
CN105657063B (en) Data download method and device
CN109684059A (en) Method and device for monitoring data
CN110493291A (en) A kind of method and apparatus handling HTTP request
CN109145591A (en) The plug-in loading method of application program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant