Server cluster resource scheduling method
Technical Field
The invention relates to a resource scheduling method for a server cluster based on a group evolution algorithm.
Background
In recent years, the server data response volume and the storage volume of some large internet companies are increased in a geometric series, and the traditional single or multiple server response mode cannot meet the business requirements, which is mainly represented by the following aspects:
(1) the access amount is large: taking a Web server as an example, the daily access volume of a large website can reach ten million levels, the concurrency volume can reach hundred thousand levels, a server resource is held by a demand response interaction mode and a long thread, and under the application scene, the server system is greatly impacted by the response speed and the storage capacity respectively, and a single server is difficult to meet the service demand.
(2) The data volume is large: taking a game server as an example, a large-scale network game is to prevent data modification of a client, generally, server-side data verification is adopted, when multiple players play cooperatively at the same time (for example, 8:00-10:00pm after work at night is used for centrally swiping copies), the data volume uploaded by the client of the multiple players reaches a peak value in a short time, the efficiency of the whole game system becomes low, the game experience is reduced, and the phenomena that the server response speed becomes slow, the client is jammed and falls frames, and network interaction loses packets are shown.
(3) The load capacity of the servers varies greatly: servers of a large internet company are not purchased in batch, the phenomenon that old servers and servers with large difference in performance level provide services together is common, and the response speed of a system is inconsistent when the servers are respectively provided by the single server.
Server clustering provides solutions to several of the above problems, i.e., aggregating multiple servers together to provide the same class of service. From the client perspective, the cluster behaves like a single server. The cluster utilizes a plurality of computers to perform parallel computation, thereby obtaining fast computation speed, and can also be used for a plurality of computers to perform backup, so that the whole system can also normally run under the condition that any one machine is broken.
On the basis, how to schedule cluster resources to enable the performance of the server to be optimal becomes a new problem which troubles cluster users. The process is the minimum unit of resources allocated by an operating system, and therefore, the resource scheduling problem of a server cluster is essentially how to allocate CPUs, storage spaces and network traffic on a plurality of servers, so that the response speed, efficiency and storage spaces of the plurality of processes are maximized within a certain planning time.
At present, common operating systems for providing Server cluster resource scheduling services include Windows Server, Linux, Unix, etc., Server containers include Tomcat, WebLogic, JBoss, etc., open source software includes LVS, Nginx, haprox, etc., and these products can provide scheduling services of multiple Server resources.
The scheduling method of server cluster resources can be divided into the following methods in principle:
(1) static resource scheduling: including Round-robin (Round Pick) and Random (Random) methods. Wherein the polling includes conventional polling, weighted polling, and dynamic polling. The traditional polling is that requests from users are distributed to internal servers in turn, the requests are polled from the first server to the Nth server, and then the polling is circulated again; the weighted polling is to distribute different weights to each server according to different processing capacities of the servers; the dynamic polling is to dynamically allocate the weight of each server according to the running state of the current server. The random is to select one of the servers at random for access according to the list size value of the back-end server through a random algorithm, and the probability statistics theory can know that as the times of calling the server by the client increases, the actual effect is closer to the average distribution of the calling amount to each server at the back end.
(2) Dynamic resource scheduling: including the fastest algorithm and the least-connected method. Wherein the fastest algorithm is to allocate connections based on the fastest response time among all servers; the minimum connection is to dynamically select one server with the minimum number of current backlogged connections according to the current connection condition of the back-end server to process the current request, so as to improve the utilization efficiency of the back-end service as much as possible and reasonably distribute the current request to each server.
The existing scheduling method has obvious effect when the processing quantity is small, and the effect is obviously reduced when the processing quantity is large.
Disclosure of Invention
In view of the problems in the prior art, the invention aims to provide a scheduling method for server cluster resources with large data volume, which has completely different application scenarios and static and dynamic resource scheduling implementation methods.
1. A method for scheduling server cluster resources is provided, wherein the server cluster comprises N servers, and each server comprises: CPU (C)a) And a memory (M)b) Hard disk (H)c) Network traffic (I)d) M processes need to allocate resources, each process being Pi(i is more than 0 and less than m), and the scheduling method is characterized by comprising the following steps:
A. defining a set of four-dimensional particles Sj k={Ca,Mb,Hc,Id}(0<j<E) Wherein, in the step (A),
j is the number of cycles, E is the total number of cycles, k is the id of the particles within the four-dimensional particle groups, each of the four-dimensional particle groups contains G particles (0< k < G), and each of the four-dimensional particle groups represents the input data of one cycle j;
B. defining an initial state of the four-dimensional particle group as S0Initializing parameters of a particle swarm algorithm as follows: inertia weight w, local search random coefficient c1, global search random coefficient c 2; the optimal solution of the primary loop j is a local optimal solution pj localGlobal optimal solution is pj globalThe initial values of the local optimal solution and the global optimal solution are both + ∞;
C. a fitness function is defined, wherein,
in the j-th cycle Sj kIn (2), the response time of the kth server is tj kA load factor of lj k;
Fitness function f
1(S
j k) Comprises the following steps: average response time of system
Fitness function f
2(S
j k) Comprises the following steps: maximum response time of system
Fitness function f
3(S
j k) Comprises the following steps: average load rate of system
Fitness function f
4(S
j k) Comprises the following steps: maximum load rate of system
D. Calculating the fitness function f1(Sj k)、f2(Sj k)、f3(Sj k)、f4(Sj k) Updating the set of four-dimensional particles S after each of the cyclesj kThe position and speed of (c); wherein, 0<j<E-1,0<k<G-1;
F. And outputting the result.
As a preferred embodiment of the present invention, the initial state of the four-dimensional particle group is defined using a random algorithm.
Further, p isj local>f1(Sj k) When is, pj local=f1(Sj k);pj global>f1(Sj k) When is, pj global=f1(Sj k)。
Further, p isj local>f2(Sj k) When is, pj local=f2(Sj k);pj global>f2(Sj k) When is, pj global=f2(Sj k)。
Further, p isj local>f3(Sj k) When is, pj local=f3(Sj k);pj global>f3(Sj k) When is, pj global=f3(Sj k)。
Further, p isj local>f4(Sj k) When is, pj local=f4(Sj k);pj global>f4(Sj k) When is, pj global=f4(Sj k)。
Further, obtaining data from the server cluster and calculating to obtain the fitness function f1(Sj k)、f2(Sj k)、f3(Sj k)、f4(Sj k)。
As a preferred embodiment of the present invention, the four-dimensional particle group Sj kThe location update equation of (1) is:
f in the location update equation when calculating the fitness function differently1(Sj k) Is correspondingly replaced by f2(Sj k) Or f3(Sj k) Or f4(Sj k)。
As a preferred embodiment of the present invention, the four-dimensional particle group S
j kThe velocity update equation of (a) is:
in a preferred embodiment of the present invention, in step D, when the speed is out of range, a speed is randomly generated.
In the prior art, methods for scheduling server cluster resources are mainly a static resource scheduling method and a dynamic resource scheduling method, but are not suitable for resource scheduling scenes with large data volumes.
Drawings
Fig. 1 is a schematic flow chart of a server cluster resource scheduling method provided by the present invention.
Fig. 2 is a variation trend of the CPU occupancy of the method provided by the embodiment of the present invention compared with other methods.
Detailed Description
The following detailed description of the present invention, taken in conjunction with the accompanying drawings and examples, is provided to enable the invention and its various aspects and advantages to be better understood. However, the specific embodiments and examples described below are for illustrative purposes only and are not limiting of the invention.
The server cluster resource scheduling method provided by the invention is carried out based on a Particle Swarm Optimization (PSO). Specifically, the method comprises the following steps:
the server cluster comprises N servers, and each server comprises the following resources: CPU (C)a) And a memory (M)b) Hard disk (H)c) Network traffic (I)d). In the scheduling process, m processes need to be allocated with resources, and each process is represented as Pi(0<i<m)。
In the invention, in the server cluster, the performance of the server is calculated by the average response time t of the systemavgMaximum response time tmaxAverage load factor lavgMaximum load factor lmaxAnd (4) showing.
As shown in fig. 1, the method of the present invention is implemented by the following steps:
A. defining a set of four-dimensional particles Sj k={Ca,Mb,Hc,Id}(0<j<E) Wherein j is the number of cycles, E is the total number of cycles, and k is the id of the particle in the four-dimensional particle group. Each four-dimensional particle group Sj kContains G particles (0)<k<G) And, each four-dimensional particle group Sj kThe input data representing one cycle j, i.e. the states of the G particles. The fitness of the G particles is calculated during each cycle.
For example, one particle S0 3Representing the resource state of the 0 th round of the server with id 3 (i.e. at the beginning of the cycle). Each dimension of the four-dimensional set of particles of the present invention represents a resource, e.g., dimension CaRepresenting the CPU. In order to clearly and briefly describe the technical scheme of the present invention, the following only takes the computing CPU resource as an example, and other resources: memory (M)b) Hard disk (H)c) Network traffic (I)d) The calculation method of (3) is similar to that of the CPU resource.
B. Defining the initial state of the four-dimensional particle group as S through a random algorithm or a system resource state0. The parameters for initializing the particle swarm algorithm are as follows: inertia weight w, local search random coefficient c1, and global search random coefficient c 2. Wherein the random coefficients are generated by a random algorithm.
In the invention, the optimal solution of the primary loop j is defined as the local optimal solution pj localGlobal optimal solution is pj global. Moreover, the initial values of the local optimal solution and the global optimal solution are both + ∞;
C. in the j-th cycle Sj kIn (2), the response time of the kth server is tj kA load factor of lj k. The fitness calculation formula of the four-dimensional particle group is as follows:
1. fitness function f
1(S
j k) Comprises the following steps: average response time of system
2. Fitness function f
2(S
j k) Comprises the following steps: maximum response time of system
3. Fitness function f
3(S
j k) Comprises the following steps: average load rate of system
4. Fitness function f
4(S
j k) Comprises the following steps: maximum load rate of system
Further, each fitness function may also obtain data from a plurality of servers of a server cluster to perform direct calculation, instead of performing calculation by using the method of the present invention.
D. The cycle of j is: cycles of 0 to (E-1), k are: 0 to (G-1).
Calculating a fitness function f1(Sj k)、f2(Sj k)、f3(Sj k)、f4(Sj k)。
The following is expressed by f1(Sj k) As an example:
if p isj local>f1(Sj k),pj local=f1(Sj k);
If p isj global>f1(Sj k),pj global=f1(Sj k)。
Further, if pj local>f2(Sj k),pj local=f2(Sj k);
If p isj global>f2(Sj k),pj global=f2(Sj k)。
Further, if pj local>f3(Sj k),pj local=f3(Sj k);
If p isj global>f3(Sj k),pj global=f3(Sj k)。
Further, if pj local>f4(Sj k),pj local=f4(Sj k);
If p isj global>f4(Sj k),pj global=f4(Sj k)。
Updating the four-dimensional set of particles S after each cyclej kThe position and speed of the vehicle.
Wherein, the four-dimensional particle group Sj kThe location update equation of (1) is:
when calculating different fitness functions, f in the location update equation1(Sj k) Is correspondingly replaced by f2(Sj k) Or f3(Sj k) Or f4(Sj k)。
Four-dimensional particle set S
j kThe velocity update equation of (a) is:
F. if the speed is out of range, a speed is randomly generated.
G. And outputting the result.
Examples
In this embodiment, it is assumed that the performance of the servers in the server cluster is consistent, and a single variable is strictly controlled.
The server cluster of the embodiment has 64 servers, each server has 2 CPUs, each CPU has 16 cores, and each core can not be subdivided by sequentially executing program instructions. The memory of each server is 128GB, and the hard disk is 4 TB. The cluster interacts with the network at a transmission speed of 100Mb/s, and 4 servers are networked via a switch. All servers in the initial state have 2 long processes, which are respectively arranged in 8 cores with 1 CPU, and the load rate is 50%. Assuming that the system response speed in this case is 0.1s, the system response speed becomes slower by 0.1s for every 1 more core.
In the system of this embodiment, 2000 concurrent requests need to be processed, and each request generates one process.
Fig. 2 shows the variation trend of the CPU occupancy when the method, polling method, and random method of the present invention are respectively used to schedule server cluster resources. As can be seen from fig. 1, compared with the conventional method, the CPU occupancy of the method of the present invention is increased relatively faster and converged earlier, which indicates that the server cluster responds to the request faster and the load within the server cluster is more balanced, compared with the CPU occupancy of the conventional algorithm.
Finally, it should be noted that: it should be understood that the above examples are only for clearly illustrating the present invention and are not intended to limit the embodiments. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. And obvious variations or modifications of the invention may be made without departing from the scope of the invention.