CN107426332B - A kind of load-balancing method and system of web server cluster - Google Patents

A kind of load-balancing method and system of web server cluster Download PDF

Info

Publication number
CN107426332B
CN107426332B CN201710680742.7A CN201710680742A CN107426332B CN 107426332 B CN107426332 B CN 107426332B CN 201710680742 A CN201710680742 A CN 201710680742A CN 107426332 B CN107426332 B CN 107426332B
Authority
CN
China
Prior art keywords
server
period
moment
page
load
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.)
Active
Application number
CN201710680742.7A
Other languages
Chinese (zh)
Other versions
CN107426332A (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.)
South China University of Technology SCUT
Original Assignee
South China University of Technology SCUT
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 South China University of Technology SCUT filed Critical South China University of Technology SCUT
Priority to CN201710680742.7A priority Critical patent/CN107426332B/en
Publication of CN107426332A publication Critical patent/CN107426332A/en
Application granted granted Critical
Publication of CN107426332B publication Critical patent/CN107426332B/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
    • H04L67/1008Server selection for load balancing based on parameters of servers, e.g. available memory or workload
    • 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer And Data Communications (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a kind of load-balancing method of web server cluster and systems, its server to be distributed is respectively specified that first for the access of each type static page, load balancing objective function is constructed simultaneously, when receiving page method request, classify, when for static page access request, assigned it in corresponding server according to its affiliated type;When for dynamic page access request, the optimum allocation weight accessed according to each Java Server Page of current period accessed by a upper period is allocated the dynamic page access at current period each moment;When the time reaching last moment of current period, the optimum allocation weight of each Java Server Page of next period access is obtained by equalization target function;The present invention proposes different processing modes for static page and dynamic page respectively, can make full use of server resource in this way, still can achieve the effect of load balancing under complicated access situation.

Description

A kind of load-balancing method and system of web server cluster
Technical field
The present invention relates to computer server cluster field, in particular to a kind of load balancing side of web server cluster Method and system.
Background technique
With the high speed development of internet, disparate networks information system scale is increasing, and flowing of access is in geometry grade Number increases, this proposes requirements at the higher level to the working performance of server.Single Web server is handling a large amount of service request Shi Huicun Excessive in workload, the service request response time is long, and the big problem of feedback delay will appear Single Point of Faliure, user when serious Experience performance is poor.Therefore system response efficiency and reliability are improved using server cluster technology, provides for user and concurrently takes Business.The structure and performance of individual server have differences in server cluster, and client access has randomness and sudden, because This existing system generally understands configuration load balanced device.Load balancer is according to the maximum processing capability of individual server and current Load state distributes loading commissions according to load dispatch strategy, rationally avoids the occurrence of overload using the resource of every server Situation improves the stability and response speed of server cluster.
Load balancing research for Web server cluster, from model, method with application realize it is several in terms of have it is more Achievement.Load-balancing method is divided into static and dynamic two major classes.Static load balancing method includes the side Random random (RAN) Method, Round-Robin poll (RR) method and static weight poll (SWRR) method.Randomized is i.e. at random from server cluster One server response service of middle selection is asked;Polling method will be new poll of access request be dealt on each server;It is quiet State weighted polling method is not have to processing capacity according to every server, and different weights is distributed to every server, makes it It can receive the service request of corresponding weight value number.Static load balancing method is using the task allocation proportion of each server as system Parameter is stored in load balancer, does not consider the real-time change situation of server load.Static load balancing method belongs to out Ring load regulation mode, it is difficult to meet the performance requirement of server cluster of new generation.Dynamic load balancing method includes at least connecting Connect (LC) method, minimum connection (WLC) method of weighting and changeable weight poll (DWRR) method.Load balancer periodic harvest The load information of every server distributes weight distribution task according to the real time load level calculation task of server, is requesting In the case that task type difference and workload differ greatly, dynamic load leveling calculates performance and is better than static load balancing side Method, but dynamic load balancing method needs additional data processing and transmission.There is offices for traditional dynamic load balancing method Sex-limited, for example, minimum connection method measures the current loading condition of server to connect quantity because server performance it is different, The server resource that dynamic page accesses task consumption is different, the identical load capacity phase for being not equal to server receiving of connection number Together, therefore traditional dynamic load balancing method can not accurately measure server current load situation.
Summary of the invention
The first object of the present invention is the shortcomings that overcoming the prior art and insufficient, provides a kind of web server cluster Load-balancing method, this method can realize the load balancing of server cluster under mixing request service, bear compared to traditional Equalization methods are carried, this method can make full use of server resource, and it is equal still to can achieve load under complicated access situation The effect of weighing apparatus.
Second mesh of the invention is to provide a kind of bearing for web server cluster for realizing above-mentioned load-balancing method Carry equal balance system.
The first object of the present invention is achieved through the following technical solutions: a kind of load-balancing method of web server cluster, Include the following steps:
S1, first for each type static page access respectively specify that its server to be distributed;Meanwhile with next week The load factor of each server of phase at last moment is corresponding negative closest to last moment server consensus forecast of next period Load rate is that target constructs load balancing objective function, solves each Java Server Page access of next period by objective function Optimum allocation weight;And construct load balancing bound for objective function, comprising: each of last moment in next period It is 1 that server load rate, which is less than the sum of each Java Server Page access distribution weight of certain value and next period,;
It is directed to the accessing page request that the client of each reception of current period is proposed, is handled as follows:
S2, in the accessing page request that each reception of current period is proposed to client, first to requesting access to The page classify, if dynamic page, then carry out the processing of step S4;If static page, then the place of step S3 is carried out Reason;Meanwhile when the time reaching last moment of current period, the load of each server of last moment of current period is acquired Rate, and the optimum allocation weight of each Java Server Page of next period access is calculated, detailed process is as follows: basis first The current period that the load factor of each server of last moment of current period and upper last moment in a period are predicted The prediction load factor of each server of last moment predicts the prediction load factor of each server of last moment in next period, Then it averages to obtain last moment server consensus forecast load factor of next period, finally by last moment in next period Optimal solution is sought in the load balancing objective function constructed in server consensus forecast load factor input step S1, to obtain down The optimum allocation weight of each Java Server Page of one period access;When next period arrives, this step is returned;
The static page of S3, the static page access request for being directed to current period each moment, first acquisition request access Type, then search the specified server to be distributed of this type static page access, and judge that the server is worked as It is preceding whether to provide service to page access, if so, by static page access distribution to the server;If it is not, then will be quiet State page access was distributed into web server cluster in last the smallest server of moment load factor of a upper period, and will It is the server that this type static page, which accesses the specified server update to be distributed,;
S4, the dynamic page access request for being directed to current period each moment were obtained according to upper last moment in a period Dynamic page of the optimum allocation weight of each Java Server Page of the current period got access to current period each moment Access is allocated.
Preferably, its server to be distributed is respectively specified that for the access of each type static page in step S1, and It is recorded in Hash table;The static page access request at current period each moment is directed in the step S3, acquisition request is visited After the type for the static page asked, the specified service to be distributed of this type static page access is searched by Hash table Device.
Preferably, step S2, the load factor calculation formula of each server of current period each moment are as follows:
Wherein RiIt (t) is the load factor of i-th server of current period t moment,It is current period t moment i-th Server static page load capacity to be processed,For i-th server dynamic page to be processed of current period t moment Load capacity, CiFor the maximum processing capability of i-th server;Wherein when t takes (k-1) T, current week is calculated by above formula The load factor of last moment (k-1) i-th server of T moment of phase i.e. (k-1) a period, k=2,3 ...;
Wherein each server of current period each moment static page load capacity calculation formula to be processed are as follows:
Wherein ci,1(t), ci,2(t) ... ci,j(t) held for i-th server of current period t moment is respectively corresponded 1,2 ..., j class static file access number;It is the load for accessing jth class static page and generating, SjFor jth class static page Size, λ be read static page file and processing send resource utilization coefficient, T is cycle length;When t takes (k-1) T When, last i-th server of moment (k-1) T moment of current period i.e. (k-1) a period, which is calculated, by above formula to locate The static page load capacity of reasonK=2,3 ...;
Wherein each server of current period each moment dynamic page load capacity calculation formula to be processed are as follows:
WhereinDynamic page load capacity, M are not completed for i-th server before current period t momentiIt is taken for i-th Business device generates the performance parameters of dynamic page, wiIt (k-1) was current period i.e. (k-1) a period accessed by a upper period The optimum allocation weight of i-th Java Server Page access;It needs to buffer for current period t moment and is forwarded to i-th The dynamic page access number of platform server,It is corresponding for current period t momentA dynamic page access number exists The load capacity that i-th server generates;When t takes (k-1) T, current period i.e. (k-1) a period is calculated by above formula Last moment (k-1) T moment i-th server dynamic page load capacity to be processedK=2,3 ...;
The load factor of each server of last moment of current period are as follows:
Wherein Ri((k-1) T) is last moment (k-1) T moment in current period i.e. (k-1) a period i-th service The load factor of device.
Further, the resource utilization coefficient lambda value for reading static page file and processing transmission is as follows:
When server reads static page file and processing from disk, λ=λ is taken1, λ1It is read from disk for server quiet The resource utilization coefficient that state page file and processing are sent,
When server reads static page file and processing from caching, λ=λ is taken2;λ2It is read from caching for server quiet The resource utilization coefficient that state page file and processing are sent;
Wherein λ12
Further, the maximum processing capability C of i-th serveriAre as follows:
Wherein k1~k4Influence coefficient of each index to server maximum processing capability;μiFor i-th server CPU quantity, fiI-th server cpu frequency, GiFor the memory size of i-th server, DiFor the I/O rate of i-th server, NiIt is The network throughput of i platform server.
Preferably, in step S2, according to the load factor of each server of last moment of current period and period thereon The prediction load factor of each server of last moment of the current period that last moment is predicted, passes through index smoothing forecasting method Predict the prediction load factor of each server of last moment in next period:
Wherein Ri((k-1) T) is last moment (k-1) T moment in current period i.e. (k-1) a period i-th service The load factor of device,For a current period i.e. upper period, that is, period of kth -2 in (k-1) a period last when Carve predict current period i.e. (k-1) a period last each server of moment (k-1) T moment prediction load Rate,For the prediction load factor of i-th server of i.e. k-th of kT moment at last moment in period in next period;α is smooth Coefficient;
Last moment in next period clothes are sought according to the prediction load factor of each server of last moment in next period Business device consensus forecast load factor:
WhereinFor next period i.e. k-th of period last moment kT moment server consensus forecast load factor;n For total number of units of server in web server cluster.
Preferably, the load balancing objective function constructed in step S1 are as follows:
The load balancing bound for objective function constructed in step S1 are as follows:
Ri(kT)≤0.9, i=1,2,3 ... n;
Wherein RiIt (kT) is the load factor of each server of i.e. k-th last moment in period kT of next period, For next period i.e. k-th the period last moment server consensus forecast load factor, n is web server cluster server Total number of units;wi(k) being is the optimum allocation weight that k-th of period, i-th Java Server Page accesses in next week, wherein i= 1,2,...n;T is cycle length.
Further, it in step S2, is acquired in load balancing objective function most by Cauchy inequality and the method for exhaustion Excellent solution, i.e. optimum allocation weight.
Preferably, whether server is cached with the static page when receiving static page access first in step S3, If it is not, then being read from disk;
In step S2, it is directed to the dynamic page access request at period 1 at each moment, each server of the period is set The optimum allocation weight of dynamic page access is identical.
The second object of the present invention is achieved through the following technical solutions: a kind of for realizing above-mentioned load-balancing method The SiteServer LBS of web server cluster, including client and web server cluster, the web server cluster include more Platform server;It is characterized in that, further including load balancer, the load balancer is arranged in client and WEB server collection Between group;
The client, for sending accessing page request to load balancer by internet;
The load balancer, for respectively specifying that its server to be distributed for the access of each type static page; For constructing load balancing objective function and constraint condition;Last moment is each with next period for the load balancing objective function It is target that the load factor of platform server, which is corresponded to closest to last moment server consensus forecast load factor of next period, described Constraint condition includes that each server load rate of last moment in next period is less than certain value and next period each service The sum of device dynamic page access distribution weight is 1;
The accessing page request proposed for receiving each moment client of current period, is receiving accessing page request Afterwards, classify first to the page requested access to;If static page, the first class of the static page of acquisition request access Then type searches the specified server to be distributed of this type static page access, and judges that the server is currently It is no to provide service to page access, if so, by static page access distribution to the server;If it is not, then by static page Interview asked distribution into web server cluster in last the smallest server of moment load factor of a upper period, and by this kind It is the server that type static page access, which specifies the server update to be distributed,;If dynamic page, according to a upper period The optimum allocation weight of each Java Server Page of current period accessed by last moment access is each to current period The dynamic page access at moment is allocated;
For when the time reach last moment of current period when, acquire web server cluster in current period last The load factor of each server of moment;
For when the time reaching last moment of current period, calculating each Java Server Page access of next period Optimum allocation weight, detailed process is as follows: first according to the load factor of each server of last moment of current period and on The prediction load factor of each server of last moment of current period that last moment in one period is predicted is predicted next Then it is flat to average to obtain last moment server of next period for the prediction load factor of each server of last moment in period Load factor is predicted, finally by last moment server consensus forecast load factor input load equalization target function of next period In seek optimal solution, thus obtain each Java Server Page of next period access optimum allocation weight;
Each server in the web server cluster, for counting when the time reaching last moment of current period Wherein load factor is calculated, is periodically acquired for load balancer;It distributes for balancing received load device to static state therein Page access and dynamic page access;For according to being assigned to, static page therein to be accessed and dynamic page is accessed to client The corresponding service of response.
The present invention has the following advantages and effects with respect to the prior art:
(1) in the present invention, its server to be distributed is respectively specified that for the access of each type static page first, simultaneously It is corresponding flat closest to last moment server of next period with the load factor of each server of last moment in next period Prediction load factor is that target constructs load balancing objective function, and sets constraint condition;It is requested when receiving page method When, classify first, when for static page access request, the type of the static page of acquisition request access then will be quiet State page access distributes the server to be distributed specified to this type static page access that can also provide access service, If the server cannot provide service again, it is the smallest to distribute static page access to supreme last moment load factor of a period In server, and it is the server that this type static page, which is accessed the specified server update to be distributed,;When being dynamic When state accessing page request, according to the most optimal sorting of the access of each Java Server Page of current period accessed by a upper period The dynamic page access at current period each moment is allocated with weight;When the time reaching last moment of current period, Last moment server consensus forecast load factor of next period is input in load balancing objective function and seeks optimal solution, from And obtain the optimum allocation weight of each Java Server Page of next period access;It can be seen from the above, the present invention is for static state The page and dynamic page propose different processing modes respectively, can make full use of server resource in this way, in complicated visit Ask the effect that still can achieve load balancing under situation.
(2) in the present invention, its server to be distributed is respectively specified that first against in the access of each type static page, When receiving static page access request, the type of the static page of acquisition request access, then by static page access point The server to be distributed that this type static page access of access service is specified can also be provided by being assigned to, if the server is not Service can be provided again, then distributed static page access in supreme last the smallest server of moment load factor of a period, and And it is the server that this type static page, which is accessed the specified server update to be distributed,.The present invention makes full use of service Device meeting this feature of the caching static page respectively specifies that its clothes to be distributed first against in the access of each type static page Business device, and carry out real-time update;When receiving static page access request, it is to look for out the type static page interview first Its specified server to be assigned to is asked, in the case where the server can also provide service, by the static page of request Interview asks distribution to the server, and the server is due to the server to be distributed specified for the access of the type static page, So its access for being likely to the received mistake static page, therefore it is likely to also cache the last static page interview Provided static page when asking, can greatly improve response speed in this way, promote the experience of user.
(3) in the present invention, the access of each type static page respectively specifies that its server to be distributed, and is recorded in In Hash table;The static page access request at moment each for current period, the static page of the method for the present invention acquisition request access After the type in face, the specified server to be distributed of this type static page access is searched by Hash table.By above-mentioned gram System, the method for the present invention can search the specified server to be distributed of certain type static page access by Hash table, mention High lookup rate.
(4) in the present invention, the load factor of each server of last moment of current period is by dynamic page load capacity and quiet The server current load situation that state page load capacity summation finds out, therefore can more accurately measure, substantially increases load Balanced effect.
(5) in the present invention, it is only necessary to collect the load factor and acquisition of each server of last moment of current period The prediction load factor of each server of last moment of current period can predict last moment in next period each service Then last moment server consensus forecast load factor of next period is passed through load balancing target letter by the prediction load factor of device The optimum allocation weight of each Java Server Page of next period access can be obtained in number, it is seen then that load balancing mistake of the present invention The load factor for acquiring each server in real time is not needed in journey, greatly reduces the calculation amount of each server load rate.Separately Outside, the present invention predicts the prediction load factor of each server of last moment in next period by index smoothing forecasting method;As it can be seen that The case where present invention considers load parameter in a short time and might have larger fluctuation, is locating compared to conventional load equalization methods The mode only judged according to real-time server loading condition merely when reason load distribution, the present invention are pre- by exponential smoothing Survey method predicts the mode of each server load rate of last moment in next period, can further improve the effect of load balancing Fruit.
(6) in the present invention, load balancer is provided between client and web server cluster, load balancer exists Last moment of current period respectively corresponds each server of acquisition in the load factor at last moment in period, i.e. load balancing The load factor of each server in device periodically acquisition web server cluster;And according to the current period of acquisition last when It is final to carve the load factor of each server, the prediction load factor of each server of last moment of current period and objective function The optimum allocation weight of each Java Server Page of next period access can be calculated, be the task of a kind of dynamical feedback Allocation strategy can effectively improve load balancing effect.
Detailed description of the invention
Fig. 1 is the load-balancing method flow chart of web server cluster of the present invention.
Fig. 2 is the SiteServer LBS structural block diagram of web server cluster of the present invention.
Specific embodiment
Present invention will now be described in further detail with reference to the embodiments and the accompanying drawings, but embodiments of the present invention are unlimited In this.
Embodiment
Present embodiment discloses a kind of load-balancing methods of web server cluster, and detailed process is as follows:
S1, it for the access of each type static page respectively specifies that its server to be distributed first, and is recorded in negative The Kazakhstan for carrying balanced device is in table;Wherein static page is classified according to file size, by the static page of a certain size range It is defined as a seed type;In the present embodiment, according to static page file size, static page is classified 4 seed types, wherein the A kind of file size of the type static page is 0~50KB, and the file size of second of type static page is 51~75KB, the The file size of three types static page is 76~100KB;The file size of 4th seed type static page be greater than 100KB。
Meanwhile with the load factor of each server of last moment in next period it is corresponding closest to next period last Moment server consensus forecast load factor is that target constructs load balancing objective function, and it is each to solve next period by objective function The optimum allocation weight of platform Java Server Page access;And construct load balancing bound for objective function, comprising: under Each server load rate of last moment in one period is less than each Java Server Page access of certain value and next period Distributing the sum of weight is 1;
Wherein next period of the present embodiment refers to the next cycle of current period;
It is directed to the accessing page request that the client of each reception of current period is proposed, is handled as follows:
S2, in the accessing page request that each reception of current period is proposed to client, first to requesting access to The page classify, if dynamic page, then carry out the processing of step S4;If static page, then the place of step S3 is carried out Reason;In the present embodiment simultaneously, when the time reaching last moment of current period, each of last moment of current period is acquired The load factor of server, and calculate the optimum allocation weight of each Java Server Page of next period access, detailed process It is as follows: to be measured in advance according to the load factor of each server of last moment of current period and upper last moment in a period first The prediction load factor of each server of last moment of the current period arrived predicts next each server of last moment in period Prediction load factor, then average to obtain last moment server consensus forecast load factor of next period, finally will be next It is sought most in the load balancing objective function constructed in last moment in period server consensus forecast load factor input step S1 Excellent solution, to obtain the optimum allocation weight of each Java Server Page of next period access;When next period arrives, return Return this step;In the present embodiment, it is directed to the dynamic page access request at a cycle each moment, is arranged the period each The optimum allocation weight of Java Server Page access is identical.That is w1(1)=w2..., (1) ,=wn(1)。
Wherein the load factor at each server last moment of current period is calculated by each server itself, this reality The load factor that example periodically acquires each server is applied, i.e., is acquired respectively at last moment in each period in the present embodiment The load factor of each server.The page file that current request accesses in the present embodiment is ended up with .html, then by the page It is defined as static page, the page file of current request access is ended up with .jsp, then the page is defined as dynamic page.
The static page of S3, the static page access request for being directed to current period each moment, first acquisition request access Type, then search the specified server to be distributed of this type static page access, and judge that the server is worked as It is preceding whether to provide service to page access, if so, by static page access distribution to the server;If it is not, then will be quiet State page access was distributed into web server cluster in last the smallest server of moment load factor of a upper period, and will It is the server that this type static page, which accesses the specified server update to be distributed,;Wherein by comparing a upper period most The load factor of each server of later moment in time can get the wherein the smallest server of load factor;In addition server is receiving To when static page access, it whether is cached with the static page first, if it is not, then reading from disk.Pass through in the present embodiment Whether the load that detection service device is born solves its maximum processing capability to judge whether server can also be to page access Service is provided.
S4, the dynamic page access request for being directed to current period each moment were obtained according to upper last moment in a period Dynamic page of the optimum allocation weight of each Java Server Page of the current period got access to current period each moment Access is allocated.
In the present embodiment above-mentioned steps S2, the load factor calculation formula of each server of current period each moment are as follows:
Wherein RiIt (t) is the load factor of i-th server of current period t moment,It is current period t moment i-th Server static page load capacity to be processed,For i-th server dynamic page to be processed of current period t moment Load capacity, CiFor the maximum processing capability of i-th server;Wherein when t takes (k-1) T, current week is calculated by above formula The load factor of last moment (k-1) i-th server of T moment of phase i.e. (k-1) a period, k=2,3 ...;
Wherein each server of current period each moment static page load capacity calculation formula to be processed are as follows:
Wherein ci,1(t), ci,2(t) ... ci,j(t) held for i-th server of current period t moment is respectively corresponded 1,2 ..., j class static file access number;It is the load for accessing jth class static page and generating, SjFor jth class static page Size, λ be read static page file and processing send resource utilization coefficient, T is cycle length;When t takes (k-1) T When, last i-th server of moment (k-1) T moment of current period i.e. (k-1) a period, which is calculated, by above formula to locate The static page load capacity of reasonK=2,3 ...;
The resource utilization coefficient lambda value for wherein reading static page file and processing transmission is as follows:
When server reads static page file and processing from disk, λ=λ is taken1, λ1It is read from disk for server quiet The resource utilization coefficient that state page file and processing are sent,
When server reads static page file and processing from caching, λ=λ is taken2;λ2It is read from caching for server quiet The resource utilization coefficient that state page file and processing are sent;
Wherein λ12
Current period each moment each server dynamic page load capacity calculation formula to be processed are as follows:
WhereinDynamic page load capacity, M are not completed for i-th server before current period t momentiIt is taken for i-th Business device generates the performance parameters of dynamic page, wiIt (k-1) was current period i.e. (k-1) a period accessed by a upper period The optimum allocation weight of i-th Java Server Page access;It needs to buffer for current period t moment and is forwarded to i-th The dynamic page access number of platform server,It is corresponding for current period t momentA dynamic page access number exists The load capacity that i-th server generates;When t takes (k-1) T, current period i.e. (k-1) a period is calculated by above formula Last moment (k-1) T moment i-th server dynamic page load capacity to be processedK=2,3 .... That is:
Obtain the load factor of each server of last moment of current period are as follows:
Wherein Ri((k-1) T) is last moment (k-1) T moment in current period i.e. (k-1) a period i-th service The load factor of device;
In the present embodiment, the maximum processing capability C of i-th serveriAre as follows:
Wherein k1~k4Influence coefficient of each index to server maximum processing capability, in the present embodiment k1~k4Value Respectively 0.2,0.3,0,0.5;μiFor i-th server CPU quantity, fiI-th server cpu frequency, GiIt is serviced for i-th The memory size of device, DiFor the I/O rate of i-th server, NiFor the network throughput of i-th server.
In the present embodiment above-mentioned steps S2, according to the load factor of each server of last moment of current period and thereon one The prediction load factor of each server of last moment of current period that last moment in period is predicted, it is pre- by exponential smoothing Survey method predicts the prediction load factor of each server of last moment in next period:
Wherein Ri((k-1) T) is last moment (k-1) T moment in current period i.e. (k-1) a period i-th service The load factor of device,For a current period i.e. upper period, that is, period of kth -2 in (k-1) a period last when Carve predict current period i.e. (k-1) a period last each server of moment (k-1) T moment prediction load Rate,For the prediction load factor of i-th server of i.e. k-th of kT moment at last moment in period in next period;α is smooth Coefficient, wherein α is smaller, and smoothing effect is stronger, and α is 0.2 in this embodiment;When wherein current period is a cycle, due to There is no the prediction load factors of each server of period 1 at last moment, therefore by last moment of a cycle each Prediction load factor of the load factor of server as each server of second round at last moment, i.e., as k=2,
Last moment in next period clothes are sought according to the prediction load factor of each server of last moment in next period Business device consensus forecast load factor:
WhereinFor next period i.e. k-th of period last moment kT moment server consensus forecast load factor;n For total number of units of server in web server cluster.
The load balancing objective function constructed in the present embodiment above-mentioned steps S1 are as follows:
The load balancing bound for objective function of building are as follows:
Ri(kT)≤0.9, i=1,2,3 ... n;
Wherein RiIt (kT) is the load factor of each server of i.e. k-th last moment in period kT of next period, For next period i.e. k-th the period last moment server consensus forecast load factor, n is web server cluster server Total number of units;wi(k) being is the optimum allocation weight that k-th of period, i-th Java Server Page accesses in next week, wherein i= 1,2,...n;T is cycle length.Wherein the load factor at each each moment in server each period should be lower than 0.9, if more than 0.9, Illustrate the close saturation of load capacity that server is born, it should not be to the server relocation request task.
The optimal solution in load balancing objective function is acquired by Cauchy inequality and the method for exhaustion in the present embodiment step S2, That is optimum allocation weight.It is specific as follows:
For above-mentioned load balancing objective function, can be obtained according to Cauchy inequality:
And if only if I.e. when k-th of last moment in period of next period, each server load rate was equal, equal sign is set up, at this time f (w1 (kT),…,wn(kT)) minimum value is obtained, equation group can be obtained:
The optimum allocation weight w of period i-th in k-th of next period server can be found out using above formulai(k);It is not present Qualified solution need to find suitable w by experimenti(k) make objective function as small as possible.
The present embodiment also discloses a kind of load balancing of web server cluster for realizing above-mentioned load-balancing method System, as shown in Fig. 2, including client, load balancer and web server cluster, web server cluster includes more services Device, respectively server 1, server 2 ..., server n, i.e. the 1st server to n-th server;Load balancer setting Between client and web server cluster;Wherein:
Client, for sending accessing page request to load balancer by internet;
Load balancer, for respectively specifying that its server to be distributed for the access of each type static page;For Construct load balancing objective function and constraint condition;The load balancing objective function is taken with last moment in next period each It is target, the constraint that the load factor of business device, which is corresponded to closest to last moment server consensus forecast load factor of next period, Condition includes that each server load rate of last moment in next period is dynamic less than each server of certain value and next period It is 1 that state page access, which distributes the sum of weight,;
The accessing page request proposed for receiving each moment client of current period, is receiving accessing page request Afterwards, classify first to the page requested access to;If static page, the first class of the static page of acquisition request access Then type searches the specified server to be distributed of this type static page access, and judges that the server is currently It is no to provide service to page access, if so, by static page access distribution to the server;If it is not, then by static page Interview asked distribution into web server cluster in last the smallest server of moment load factor of a upper period, and by this kind It is the server that type static page access, which specifies the server update to be distributed,;If dynamic page, according to a upper period The optimum allocation weight of each Java Server Page of current period accessed by last moment access is each to current period The dynamic page access at moment is allocated;
For when the time reach last moment of current period when, acquire web server cluster in current period last The load factor of each server of moment;That is the load factor of load balancer periodically each server of acquisition, bears in the present embodiment The load factor of balanced device each server in last moment acquisition web server cluster in each period is carried, acquisition is The load factor of each server of last moment in each period;
For when the time reaching last moment of current period, calculating each Java Server Page access of next period Optimum allocation weight, detailed process is as follows: first according to the load factor of each server of last moment of current period and on Last moment in one period last moment of pre- current period each server of last moment of current period for measuring It predicts load factor, predicts the prediction load factor of each server of last moment in next period, then average to obtain next week Last moment server consensus forecast load factor of phase, finally by last moment server consensus forecast load factor of next period Optimal solution is sought in input load equalization target function, to obtain the optimal of each Java Server Page access of next period Distribute weight;
Each server in web server cluster, it is corresponding to calculate for reaching last moment of current period when the time The load factor of each server is periodically acquired for load balancer;It distributes for balancing received load device to wherein Static page access and dynamic page access;For according to be assigned to static page therein access and dynamic page access to Client end response services accordingly.
The above embodiment is a preferred embodiment of the present invention, but embodiments of the present invention are not by above-described embodiment Limitation, other any changes, modifications, substitutions, combinations, simplifications made without departing from the spirit and principles of the present invention, It should be equivalent substitute mode, be included within the scope of the present invention.

Claims (9)

1. a kind of load-balancing method of web server cluster, which comprises the steps of:
S1, first for each type static page access respectively specify that its server to be distributed;Meanwhile most with next period The load factor of each server of later moment in time is corresponding closest to last moment server consensus forecast load factor of next period Load balancing objective function is constructed for target, each Java Server Page access of next period is solved most by objective function Optimal sorting matches weight;And construct load balancing bound for objective function, comprising: last moment in next period each service It is 1 that device load factor, which is less than the sum of each Java Server Page access distribution weight of certain value and next period,;
It is directed to the accessing page request that the client of each reception of current period is proposed, is handled as follows:
S2, in the accessing page request that each reception of current period is proposed to client, first to the page requested access to Face is classified, and if dynamic page, then carries out the processing of step S4;If static page, then the processing of step S3 is carried out;Together When, when the time reaching last moment of current period, the load factor of each server of last moment of current period is acquired, and And the optimum allocation weight of next each Java Server Page of period access is calculated, detailed process is as follows: first according to current The current period that the load factor of each server of last moment in period and upper last moment in a period are predicted is last The prediction load factor of each server of one moment predicts the prediction load factor of each server of last moment in next period, then It averages to obtain last moment server consensus forecast load factor of next period, finally services last moment in next period Optimal solution is sought in the load balancing objective function constructed in device consensus forecast load factor input step S1, to obtain next week The optimum allocation weight of each Java Server Page of phase access;When next period arrives, this step is returned;
The class of the static page of S3, the static page access request for being directed to current period each moment, first acquisition request access Then type searches the specified server to be distributed of this type static page access, and judges that the server is currently It is no to provide service to page access, if so, by static page access distribution to the server;If it is not, then by static page Interview asked distribution into web server cluster in last the smallest server of moment load factor of a upper period, and by this kind It is the server that type static page access, which specifies the server update to be distributed,;
S4, the dynamic page access request for being directed to current period each moment, according to accessed by upper last moment in a period The optimum allocation weight of each Java Server Page of current period access the dynamic page at current period each moment is accessed It is allocated;
The load balancing objective function constructed in step S1 are as follows:
The load balancing bound for objective function constructed in step S1 are as follows:
Ri(kT)≤0.9, i=1,2,3 ... n;
Wherein RiIt (kT) is the load factor of each server at i.e. k-th kT moment at last moment in period of next period, For next period i.e. k-th of period last moment kT moment server consensus forecast load factor, n is web server cluster clothes Total number of units of business device;wiIt (k) is the next week i.e. optimum allocation weight of k-th of period, i-th Java Server Page access, Middle i=1,2 ... n;T is cycle length.
2. the load-balancing method of web server cluster according to claim 1, which is characterized in that be every in step S1 The access of seed type static page respectively specifies that its server to be distributed, and is recorded in Hash table;In the step S3 It is directed to the static page access request at current period each moment, after the type of the static page of acquisition request access, passes through Kazakhstan Uncommon table searches the specified server to be distributed of this type static page access.
3. the load-balancing method of web server cluster according to claim 1, which is characterized in that step S2, current week The load factor calculation formula of each server of phase at each moment are as follows:
Wherein RiIt (t) is the load factor of i-th server of current period t moment,It is serviced for current period t moment i-th Device static page load capacity to be processed,For the dynamic page load to be processed of i-th server of current period t moment Amount, CiFor the maximum processing capability of i-th server;Wherein when t takes (k-1) T, current period is calculated i.e. by above formula The load factor of last moment (k-1) i-th server of T moment of (k-1) a period, k=2,3 ...;
Wherein each server of current period each moment static page load capacity calculation formula to be processed are as follows:
Wherein ci,1(t), ci,2(t) ... ci,j(t) the 1st held for i-th server of current period t moment is respectively corresponded, 2 ..., j class static file access number;It is the load for accessing jth class static page and generating, SjFor jth class static page Size, l are the resource utilization coefficients for reading static page file and processing transmission, and T is cycle length;When t takes (k-1) T, Last i-th server of moment (k-1) T moment of current period i.e. (k-1) a period, which is calculated, by above formula to be handled Static page load capacityK=2,3 ...;
Wherein each server of current period each moment dynamic page load capacity calculation formula to be processed are as follows:
WhereinDynamic page load capacity, M are not completed for i-th server before current period t momentiFor i-th server Generate the performance parameters of dynamic page, wiIt (k-1) was current period i.e. (k-1) a period i-th accessed by a upper period The optimum allocation weight of platform Java Server Page access;It needs to buffer for current period t moment and is forwarded to i-th The dynamic page access number of server,It is corresponding for current period t momentA dynamic page access number is i-th The load capacity that platform server generates;When t takes (k-1) T, current period i.e. (k-1) a period is calculated most by above formula Later moment in time (k-1) T moment i-th server dynamic page load capacity to be processedK=2,3 ...;
The load factor of each server of last moment of current period are as follows:
Wherein Ri((k-1) T) is the negative of last i-th server of moment (k-1) T moment of current period i.e. (k-1) a period Load rate.
4. the load-balancing method of web server cluster according to claim 3, which is characterized in that read static page The resource utilization coefficient l value that file and processing are sent is as follows:
When server reads static page file and processing from disk, l=l is taken1, l1Static page is read from disk for server The resource utilization coefficient that face file and processing are sent,
When server reads static page file and processing from caching, l=l is taken2;l2Static page is read from caching for server The resource utilization coefficient that face file and processing are sent;
Wherein λ1> λ2
5. the load-balancing method of web server cluster according to claim 3, which is characterized in that i-th server Maximum processing capability CiAre as follows:
Wherein k1~k4Influence coefficient of each index to server maximum processing capability;μiFor i-th server CPU quantity, fiI-th The cpu frequency of platform server, GiFor the memory size of i-th server, DiFor the I/O rate of i-th server, NiIt is i-th The network throughput of server.
6. the load-balancing method of web server cluster according to claim 1, which is characterized in that in step S2, according to The load factor of each server of last moment of current period and last moment in a period is predicted thereon current period are most The prediction load factor of each server of later moment in time predicts last moment in next period each clothes by index smoothing forecasting method The prediction load factor of business device:
Wherein Ri((k-1) T) is the negative of last i-th server of moment (k-1) T moment of current period i.e. (k-1) a period Load rate,It is pre- for last moment in a upper period, that is, period of kth -2 institute in current period i.e. (k-1) a period The prediction load factor of last each server of moment (k-1) T moment of the current period measured i.e. (k-1) a period,For the prediction load factor of i-th server of i.e. k-th of kT moment at last moment in period in next period;α is smooth system Number;
Last moment server of next period is sought according to the prediction load factor of each server of last moment in next period Consensus forecast load factor:
WhereinFor next period i.e. k-th of period last moment kT moment server consensus forecast load factor;N is WEB Total number of units of server in server cluster.
7. the load-balancing method of web server cluster according to claim 1, which is characterized in that in step S2, pass through Cauchy inequality and the method for exhaustion acquire the optimal solution in load balancing objective function, i.e. optimum allocation weight.
8. the load-balancing method of web server cluster according to claim 1, which is characterized in that server in step S3 When receiving static page access, it whether is cached with the static page first, if it is not, then reading from disk;
In step S2, it is directed to the dynamic page access request at period 1 at each moment, each server dynamic of the period is set The optimum allocation weight of page access is identical.
9. a kind of load of the web server cluster for realizing load-balancing method described in any one of claims 1 to 8 is equal Balance system, including client and web server cluster, the web server cluster include multiple servers;It is characterized in that, It further include load balancer, the load balancer is arranged between client and web server cluster;
The client, for sending accessing page request to load balancer by internet;
The load balancer, for respectively specifying that its server to be distributed for the access of each type static page;For Construct load balancing objective function and constraint condition;The load balancing objective function is taken with last moment in next period each It is target, the constraint that the load factor of business device, which is corresponded to closest to last moment server consensus forecast load factor of next period, Condition includes that each server load rate of last moment in next period is dynamic less than each server of certain value and next period It is 1 that state page access, which distributes the sum of weight,;
The accessing page request proposed for receiving each moment client of current period, after receiving accessing page request, Classify first to the page requested access to;If static page, the first type of the static page of acquisition request access, so The specified server to be distributed of this type static page access is searched afterwards, and judges that the server currently whether can also Service is provided to page access, if so, by static page access distribution to the server;If it is not, then static page is accessed It distributed into web server cluster in last the smallest server of moment load factor of a upper period, and this type is quiet It is the server that state page access, which specifies the server update to be distributed,;If dynamic page, according to a upper period last The optimum allocation weight of each Java Server Page of current period accessed by moment access is to current period each moment Dynamic page access is allocated;
For when the time reaching last moment of current period, acquiring last moment of current period in web server cluster The load factor of each server;
For when the time reaching last moment of current period, calculating each Java Server Page access of next period most Optimal sorting matches weight, and detailed process is as follows: first according to the load factor of each server of last moment of current period and one week upper The prediction load factor of each server of last moment of current period that phase at last moment is predicted, predicts next period Then it is average pre- to average to obtain last moment server of next period for the prediction load factor of each server of last moment Load factor is surveyed, will finally be asked in last moment server consensus forecast load factor input load equalization target function of next period Optimal solution is taken, to obtain the optimum allocation weight of each Java Server Page of next period access;
Wherein, the load balancing objective function of the load balancer building are as follows:
The load balancing bound for objective function of the load balancer building are as follows:
Ri(kT)≤0.9, i=1,2,3 ... n;
Wherein RiIt (kT) is the load factor of each server at i.e. k-th kT moment at last moment in period of next period, For next period i.e. k-th of period last moment kT moment server consensus forecast load factor, n is web server cluster clothes Total number of units of business device;wiIt (k) is the next week i.e. optimum allocation weight of k-th of period, i-th Java Server Page access, Middle i=1,2 ... n;T is cycle length;
Each server in the web server cluster, for calculating it when the time reaching last moment of current period Middle load factor is periodically acquired for load balancer;It distributes for balancing received load device to static page therein Access and dynamic page access;For according to being assigned to, static page therein to be accessed and dynamic page is accessed to client end response Corresponding service.
CN201710680742.7A 2017-08-10 2017-08-10 A kind of load-balancing method and system of web server cluster Active CN107426332B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710680742.7A CN107426332B (en) 2017-08-10 2017-08-10 A kind of load-balancing method and system of web server cluster

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710680742.7A CN107426332B (en) 2017-08-10 2017-08-10 A kind of load-balancing method and system of web server cluster

Publications (2)

Publication Number Publication Date
CN107426332A CN107426332A (en) 2017-12-01
CN107426332B true CN107426332B (en) 2019-08-20

Family

ID=60437790

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710680742.7A Active CN107426332B (en) 2017-08-10 2017-08-10 A kind of load-balancing method and system of web server cluster

Country Status (1)

Country Link
CN (1) CN107426332B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108173937A (en) * 2017-12-28 2018-06-15 北京中电普华信息技术有限公司 Access control method and device
CN108632384A (en) * 2018-05-15 2018-10-09 西安电子科技大学 Load-balancing method based on the prediction of video request number
CN110020061B (en) * 2018-08-21 2021-06-01 广州市城市规划勘测设计研究院 Smart city space-time information cloud platform service engine
CN109388657B (en) * 2018-09-10 2023-08-08 平安科技(深圳)有限公司 Data processing method, device, computer equipment and storage medium
CN109446088A (en) * 2018-10-29 2019-03-08 新华三技术有限公司 A kind of method and device for business processing
CN111182011B (en) * 2018-11-09 2022-06-10 中移(杭州)信息技术有限公司 Service set distribution method and device
CN111611067B (en) * 2019-02-22 2024-06-14 顺丰科技有限公司 Load balancing method, device and blockchain system
CN109831524B (en) * 2019-03-11 2023-04-18 平安科技(深圳)有限公司 Load balancing processing method and device
CN111984868A (en) * 2020-08-21 2020-11-24 上海二三四五网络科技有限公司 Method and device for controlling webpage browsing in browser
CN112835698A (en) * 2021-02-09 2021-05-25 北京工业大学 Heterogeneous cluster-based dynamic load balancing method for request classification processing

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104102952A (en) * 2014-06-17 2014-10-15 国家电网公司 Load optimal configuration method based on power grid operation efficiency
CN104994156A (en) * 2015-07-01 2015-10-21 北京京东尚科信息技术有限公司 Load balancing method and system for cluster
CN106210019A (en) * 2016-07-04 2016-12-07 安徽天达网络科技有限公司 A kind of large-scale height concurrent WEB application system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080222267A1 (en) * 2007-03-09 2008-09-11 Horn Ray C Method and system for web cluster server

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104102952A (en) * 2014-06-17 2014-10-15 国家电网公司 Load optimal configuration method based on power grid operation efficiency
CN104994156A (en) * 2015-07-01 2015-10-21 北京京东尚科信息技术有限公司 Load balancing method and system for cluster
CN106210019A (en) * 2016-07-04 2016-12-07 安徽天达网络科技有限公司 A kind of large-scale height concurrent WEB application system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
web集群负载均衡系统的设计与实现;黄倩;《万方学术论文数据库》;20140917;第1~88页
基于LVS的数据库集群负载均衡性能测试与分析;王超,等;《微型机与应用》;20170430;第36卷(第4期);第10~13页

Also Published As

Publication number Publication date
CN107426332A (en) 2017-12-01

Similar Documents

Publication Publication Date Title
CN107426332B (en) A kind of load-balancing method and system of web server cluster
CN109120715A (en) Dynamic load balancing method under a kind of cloud environment
CN111027736B (en) Micro-service combined deployment and scheduling method under multi-objective optimization
CN110933139A (en) System and method for solving high concurrency of Web server
US20170142177A1 (en) Method and system for network dispatching
CN101116056B (en) Systems and methods for content-aware load balancing
CN108667878A (en) Server load balancing method and device, storage medium, electronic equipment
CN111277648A (en) Nginx-based dynamic weight load balancing system and method
CN102523158A (en) Metadata server cluster load balancing method based on weight
CN104994156A (en) Load balancing method and system for cluster
CN101557344A (en) Dynamic load balancing method based on spatial geographical locations
CN111752678A (en) Low-power-consumption container placement method for distributed collaborative learning in edge computing
CN112835698A (en) Heterogeneous cluster-based dynamic load balancing method for request classification processing
CN107566535B (en) Self-adaptive load balancing method based on concurrent access timing sequence rule of Web map service
CN109783235A (en) A kind of load equilibration scheduling method based on principle of maximum entropy
CN108900626A (en) Date storage method, apparatus and system under a kind of cloud environment
CN107645520A (en) A kind of load-balancing method, device and system
CN109634746A (en) A kind of the utilization system and optimization method of web cluster caching
CN117155942A (en) Micro-service dynamic self-adaptive client load balancing method and system
CN108255427A (en) A kind of data storage and dynamic migration method and device
Li et al. Dynamic load balancing algorithm based on FCFS
CN102081624B (en) Data inquiring method and data inquiring device
CN110471761A (en) Control method, user equipment, storage medium and the device of server
CN106020732A (en) Node disk space determining method and system
CN109040283A (en) A kind of modified load-balancing algorithm based on difference reaction type

Legal Events

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