CN108718335A - A kind of load-balancing method, device, Web server and storage medium - Google Patents
A kind of load-balancing method, device, Web server and storage medium Download PDFInfo
- Publication number
- CN108718335A CN108718335A CN201810455244.7A CN201810455244A CN108718335A CN 108718335 A CN108718335 A CN 108718335A CN 201810455244 A CN201810455244 A CN 201810455244A CN 108718335 A CN108718335 A CN 108718335A
- Authority
- CN
- China
- Prior art keywords
- web server
- service
- business
- type
- service logic
- 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.)
- Pending
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
- H04L67/1004—Server selection for load balancing
- H04L67/1008—Server selection for load balancing based on parameters of servers, e.g. available memory or workload
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
- H04L67/1004—Server selection for load balancing
- H04L67/1014—Server selection for load balancing based on the content of a request
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
- H04L67/1004—Server selection for load balancing
- H04L67/1017—Server selection for load balancing based on a round robin mechanism
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/133—Protocols for remote procedure calls [RPC]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
Abstract
A kind of load-balancing method of offer of the embodiment of the present invention, device, Web server and storage medium, wherein method are applied to the first Web server in Web server cluster, and method includes:The HTTP request that Nginx servers are sent is received, and obtains the type of service of HTTP request institute requested service;When detecting that the first Web server the first service logic plugging value corresponding with type of service is greater than or equal to default blocking threshold, determine that service logic plugging value corresponding with type of service is the second Web server of minimum value in Web server cluster;RPC message is sent to the second Web server, wherein RPC message carries the business information of requested service, so that the second Web server carries out business processing according to business information to institute's requested service.The embodiment of the present invention realizes the business forwarding between Web server in Web server cluster, improves request response efficiency.
Description
Technical field
The present embodiments relate to Web cluster load balances technical field more particularly to a kind of load-balancing method, dresses
It sets, Web server and storage medium.
Background technology
In large-scale internet application, load balancing is an essential node, and load balancing is to refer to handle
Request, which is uniformly shared on multiple servers, to be handled.Wherein, Web load-balancing techniques are a kind of common load balancing skill
Art.Existing Web load balancing mainstream is the transfer as request forwarding using Nginx, and request is distributed according to configuration rule
Onto the wherein platform in cluster loaded server, responded by a server.
Nginx includes five kinds of poll, weight poll, IP-hash, fair and URL-hash load balancings.Wherein, exist
In polling schemas, request is allocated on each application server in turn successively, if asking of receiving of some server at this time
It asks more, i.e. the server node service block, then can cause the request that the server node newly receives that can not obtain effectively
Response needs overtime break link so as to cause client.
In conclusion the prior art, when using poll as load balancing, presence server node serve blocks,
The problem of causing the request that server node newly receives that can not obtain significant response.
Invention content
A kind of load-balancing method of offer of the embodiment of the present invention, device, Web server and storage medium, it is existing to solve
For technology when using poll as load balancing, existing server node service block causes server node newly to connect
The request received can not obtain the problem of significant response.
In view of the above-mentioned problems, in a first aspect, the embodiment of the present invention provides a kind of load-balancing method, applied to Web service
The first Web server in device cluster, the Web server cluster further include other in addition to first Web server
Web server, the method includes:
The HTTP request that Nginx servers are sent is received, and obtains the HTTP request and is asked
The type of service of business;
When detect first Web server the first service logic plugging value corresponding with the type of service be more than or
When equal to default blocking threshold, service logic plugging value corresponding with the type of service in the Web server cluster is determined
For the second Web server of minimum value;
Send remote procedure call message to second Web server, wherein the RPC message carry it is described
The business information of institute's requested service so that second Web server according to the business information to institute's requested service into
Row business processing.
Second aspect, the embodiment of the present invention provide a kind of load balancing apparatus, first be applied in Web server cluster
Web server, the Web server cluster further includes other Web servers in addition to first Web server, described
Device includes:
First receiving module, the HTTP request for receiving the transmission of Nginx servers, and obtain institute
State the type of service of HTTP request institute requested service;
Determining module detects that first Web server the first business corresponding with the type of service is patrolled for working as
When collecting plugging value more than or equal to default blocking threshold, determine corresponding with the type of service in the Web server cluster
Service logic plugging value is the second Web server of minimum value;
Sending module, for sending remote procedure call message to second Web server, wherein the RPC disappears
Breath carries the business information of institute's requested service so that second Web server according to the business information to described
Institute's requested service carries out business processing.
The third aspect, the embodiment of the present invention also provide a kind of Web server, including memory, processor and are stored in
On reservoir and the computer program that can run on a processor, the processor are realized described when executing the computer program
The step of load-balancing method.
Fourth aspect, the embodiment of the present invention also provide a kind of non-transient computer readable storage medium, are stored thereon with meter
Calculation machine program, the step of load-balancing method is realized when which is executed by processor.
Load-balancing method, device, Web server and storage medium provided in an embodiment of the present invention, by receiving
The HTTP request that Nginx servers are sent, and when getting the type of service of HTTP request institute requested service, if detecting first
Web server the first service logic plugging value corresponding with type of service is greater than or equal to default blocking threshold, it is determined that Web takes
Service logic plugging value corresponding with type of service is the second Web server of minimum value in business device cluster, and is taken to the 2nd Web
Business device sends the RPC message for carrying the business information of requested service so that the second Web server can be according to business information
Business processing is carried out to institute's requested service, when realizing the first Web Server Service obstruction in Web server cluster, energy
The second Web server of service logic plugging value minimum provides same services in enough called Web service device clusters, avoids and is adopting
When using poll as load balancing, if a server node service block, can not effectively ring the request newly received
Answer, client can only overtime break link the case where, alleviate the service block of each Web server in Web server cluster
Situation improves the business processing efficiency of Web server cluster.
Description of the drawings
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below
There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is this hair
Some bright embodiments for those of ordinary skill in the art without creative efforts, can be with root
Other attached drawings are obtained according to these attached drawings.
Fig. 1 shows the step flow charts of load-balancing method in the embodiment of the present invention;
Fig. 2 indicates the module frame chart of load balancing apparatus in the embodiment of the present invention;
Fig. 3 indicates the structure diagram of Web server in the embodiment of the present invention.
Specific implementation mode
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is
A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art
The every other embodiment obtained without creative efforts, shall fall within the protection scope of the present invention.
As shown in Figure 1, for the step flow chart of load-balancing method in the embodiment of the present invention, the load-balancing method application
The first Web server in Web server cluster, and Web server cluster further includes its except the first Web server of place
His Web server, this method include:
Step 101:The HTTP request that Nginx servers are sent is received, and obtains the business of HTTP request institute requested service
Type.
In this step, specifically, Nginx servers are transfer server, when client needs to send to Web server
When request, request can be forwarded by Nginx servers.At this point, the first Web server receives Nginx servers hair
Hypertext transfer protocol (abbreviation HTTP) request sent, and the type of service of HTTP request institute requested service is obtained, so that
First Web server can obtain the first Web server for the type of service according to the type of service of the requested service
Service block situation.
In addition, specifically, the first Web server can be solved when obtaining the type of service of HTTP request institute requested service
The HTTP request is analysed, the type of service of institute's requested service is obtained.
Certainly, it should be noted that the first Web server can be any server in Web server cluster,
The first Web server is not specifically designated herein.
In addition, specifically, in the present embodiment, load balancing used by Nginx servers is poll.
Step 102:When detect the first Web server the first service logic plugging value corresponding with type of service be more than or
When equal to default blocking threshold, determine that service logic plugging value corresponding with type of service is minimum value in Web server cluster
The second Web server.
In this step, specifically, after the type of service for getting HTTP request institute requested service, if detecting
One Web server the first service logic plugging value corresponding with type of service is greater than or equal to default blocking threshold, then can be true
Determine the second Web server in Web server cluster, wherein second Web server service logic corresponding with type of service
Plugging value be in Web server cluster all Web servers respectively in service logic plugging value corresponding with type of service most
Small value.In this way by determining the second Web server of service logic value minimum corresponding with type of service, to call corresponding industry
The Web server processing identical services of business logical value minimum provide the foundation.
Certainly, it should be noted that the second Web server in the present embodiment is different from the first Web server.
For example, it is assumed that Web server cluster includes Web server A, Web server B, Web server C and Web server
D, Web server A are the first Web server, and Web server A the first service logic plugging values corresponding with type of service are big
In or equal to default blocking threshold, if Web server B service logic plugging values corresponding with type of service are b at this time, Web takes
Business device C service logic plugging values corresponding with type of service are c, Web server D service logic obstructions corresponding with type of service
Value is d, and b is less than c, and c is less than d, it is determined that the Web server B of service logic plugging value minimum is the second Web server.
In addition, specifically, if the first Web server the first service logic plugging value corresponding with type of service takes for Web
The minimum value being engaged in device cluster in all service logic plugging values corresponding with type of service then continues directly to wait for the first Web
Server handles institute's requested service.
In addition, specifically, different service types are correspondingly arranged default blocking threshold, i.e., what each type of service was correspondingly arranged
Default blocking threshold may be identical, it is also possible to which different, the corresponding default blocking threshold of different service types can be according to practical feelings
Condition is set, so that the default blocking threshold that different service types are correspondingly arranged being capable of effecting reaction Web server pair
The congestion situations of the business of the type of service.
Step 103:RPC message is sent to the second Web server.
In this step, specifically, RPC message carries the business information of requested service, specifically, the business information
May include business identification code (abbreviation ID) and/or traffic sequence number.
In this way so that the first Web server to the second Web server send remote procedure call (abbreviation RPC) message it
Afterwards, the second Web server can carry out business processing according to the business information entrained by RPC message to institute's requested service, to
So that in the case where the first Web Server Service blocks, the second Web server can be called to carry out business to the requested service
Processing, realizes the business forward process between multiple Web servers in Web server cluster, avoids in service request wheel
Ask to the first Web server, and when the first Web Server Service blocks, client can only overtime break link the case where.
When the type of service of requested service getting of the embodiment of the present invention, if detecting the first Web server and industry
The corresponding first service logic plugging value of service type is greater than or equal to default blocking threshold, it is determined that in Web server cluster with
The corresponding service logic plugging value of type of service is the second Web server of minimum value, and sends and carry to the second Web server
The RPC message of the business information of requested service so that the second Web server can be according to business information to institute's requested service
Business processing is carried out, it, being capable of called Web service when realizing the first Web Server Service obstruction in Web server cluster
The second Web server of service logic plugging value minimum provides same services in device cluster, realizes more in Web server cluster
Business forward process between a Web server avoids when using poll as load balancing, if a server section
Point service block, then to the request newly received can not significant response, client can only overtime break link the case where, alleviate
The service block situation of each Web server, improves the business processing efficiency of Web server cluster in Web server cluster.
Further, each Web server is both provided with the HTTP with Nginx server communications in Web server cluster
Interface, such first Web server can be received when receiving the HTTP request that Nginx servers are sent by HTTP interface
The HTTP request that Nginx servers are sent.In this way, by the way that HTTP interface is arranged for each Web server, Nginx clothes are realized
The request being engaged between device and Web server forwards.
In addition, further, detecting the first Web server the first service logic plugging value corresponding with type of service
Before default blocking threshold, it is also necessary to obtain the first service logic plugging value, and detect the resistance of the first service logic
Whether plug value is greater than or equal to default blocking threshold.At this point, if the first service logic plugging value is greater than or equal to default obstruction threshold
Value then illustrates that the first Web Server Service blocks, then can determine that service logic plugging value corresponding with type of service is minimum
Second Web server of value to realize the calling of Web server avoids that request significant response cannot be carried out.Certainly, if
One service logic plugging value is less than default blocking threshold, then illustrates that the first Web server handles the ability abundance of the type of service,
The first Web server can be continued waiting at this time to handle institute's requested service.
It wherein, can be according to business in the memory queue of the first Web server when obtaining the first service logic plugging value
Type corresponds to the pending amount of business, determines the first service logic plugging value;Alternatively, according to the first Web server and service class
Type corresponds to average treatment duration of the business in preset period of time, determines the first service logic plugging value.
Specifically, type of service corresponds to the pending amount of business in the memory queue according to the first Web server, determine
When the first service logic plugging value, pending amount can be determined directly as to the first service logic plugging value, it can also will be to this
Pending amount carries out the value after data conversion, is determined as the first service logic plugging value, not specific herein to limit according to first
Type of service corresponds to the pending amount of business in the memory queue of Web server, determines the specific of the first service logic plugging value
Mode.Certainly, the first service logic plugging value and pending amount are proportional, i.e., pending amount is bigger, the first service logic obstruction
Value is higher.In this way by according to pending amount, determining the first service logic plugging value so that the first service logic plugging value can
The service block situation of the first Web server of accurate response.
In addition, in the average treatment duration according to the first Web server business corresponding with type of service in preset period of time,
When determining the first service logic plugging value, equally directly obtained average treatment duration can be blocked as the first service logic
Value can also be determined as the first service logic plugging value, herein together by the value after average treatment duration progress data conversion
Sample does not limit the average treatment duration in preset period of time according to the first Web server business corresponding with type of service specifically, really
The concrete mode of fixed first service logic plugging value.Certainly, the first service logic plugging value and average treatment duration are proportional, i.e.,
Average treatment duration is bigger, and the first service logic plugging value is higher.In this way by according to average treatment duration, determining the first business
Logic plugging value so that the first service logic plugging value is capable of the service block situation of the first Web server of accurate response.
In addition, specifically, preset period of time can be set according to actual conditions, do not limit specifically herein this it is default when
The specific duration of section.For example, the preset period of time can be 30s, if at this time the first Web server handle in the preset period of time and
The quantity that type of service corresponds to business is N number of, then the first Web server business corresponding with type of service is flat in preset period of time
Equal handling duration is 30/N.
In this way, the pending amount of business is corresponded to by type of service in the memory queue according to the first Web server, or
Average treatment duration of the first Web server business corresponding with type of service in preset period of time determines that the first service logic hinders
Plug value so that identified first service logic plugging value can accurately react the first Web server to the type of service institute
The service block situation of corresponding business, ensure that the validity of identified first service logic plugging value.
In addition, further, in Web server cluster each Web server be both provided with for Web server cluster
In other Web servers communicate RPC interfaces.
At this point, service logic plugging value corresponding with the type of service is most in determining the Web server cluster
Before second Web server of small value, it can obtain other Web in the Web server cluster by the RPC interfaces and take
Business device the second service logic plugging value corresponding with the type of service;Then it determines in the second service logic plugging value
Minimal service logic plugging value, and the corresponding Web server of the minimal service logic plugging value is determined as the second Web service
Device.In this way, by the way that the corresponding Web server of minimal service logic plugging value is determined as the second Web server so that selected
Called processing institute requested service Web server be service state be in optimal server, asked to reduce
The processing delay of business.
Specifically, RPC interfaces are for the communication interface between Web server in Web server cluster.Certainly, Web service
Web server in device cluster is located in the same LAN.In this way, the first Web server is in determining Web server cluster
When service logic plugging value corresponding with type of service is the second Web server of minimum value, the first Web server can be passed through
RPC interfaces between other Web servers obtain the second service logic resistance corresponding with type of service of other Web servers
Then plug value picks out minimal service logic plugging value, and the Web server corresponding to the minimal service logic plugging value is true
It is set to the second Web server so that identified second Web server is that the type of service services shape in Web server cluster
The optimal Web server of state can reduce and be asked so that when calling the second Web server to handle institute's requested service
The processing delay of business.
In addition, specifically, the determination of other Web servers the second service logic plugging value corresponding with type of service and the
The one Web server method of determination of the first service logic plugging value corresponding with type of service is identical, i.e., passes through Web server
Memory queue in type of service correspond to business pending amount or Web server business corresponding with type of service default
Average treatment duration in period, determines service logic plugging value, be not specifically introduced herein.
In addition, further, it, can be by RPC interfaces, to second when sending RPC message to the second Web server
Web server sends RPC message;Wherein, the header packet information of RPC message includes:Wrap length, packet header size, method signature, business
ID, traffic sequence number, body matter length and body data.
In this way, by the RPC interfaces of the first Web server, RPC message is sent to the RPC interfaces of the second Web server
On, forwarding of the RPC message for carrying business information between the first Web server and the second Web server is realized, to
Realizing can call the second Web server to handle poll to institute's requested service of the first Web server, avoid first
When Web Server Service blocks, client can only overtime break link the case where generation.
Specifically, the RPC message is self-defined message.The packet header storage key (Key) of the RPC message=value (Value) shape
The header data of formula.The RPC message structures can be as follows:| _ _ packet length _ _ | _ _ packet header size _ _ | _ _ method signature _ _ industry
Business ID__ sequence numbers _ _ | _ _ body matter length _ _ | _ _ body data _ _ |.
In this way, by self-defined above-mentioned RPC message body, the extension message carried in RPC message bodies is avoided, is reduced superfluous
The transmission of remainder evidence, improves transmission performance;In addition, carrying traffic ID in the customized RPC message bodies so that Web takes
Being engaged in device can be according to the traffic ID automatic identification business of RPC message bodies carrying, so that can pass through in Web server cluster
RPC message body is transmitted, business forwarding is carried out, is turned to realize the business in Web server cluster between multiple Web servers
Hair processing.
In addition, further, after sending RPC message to the second Web server, can be connect by the RPC interfaces
Receive the handling result that second Web server carries out institute's requested service business processing.In this way, being taken by the first Web
The RPC interfaces of business device, receive the handling result for institute's requested service that the second Web server is sent so that the first Web server energy
It is enough that the handling result is fed back into client, the significant response that client sends request is realized, client is avoided and is being sent out
When sending request that cannot obtain significant response, can only overtime break link the case where generation.
In this way, the embodiment of the present invention is receiving the HTTP request of Nginx servers transmission, and gets HTTP request and asked
When seeking the type of service of business, if detecting, the first Web server the first service logic plugging value corresponding with type of service is big
In or equal to default blocking threshold, it is determined that service logic plugging value corresponding with type of service is most in Web server cluster
Second Web server of small value, and the RPC message for carrying the business information of requested service is sent to the second Web server,
Enable the second Web server to carry out business processing to institute's requested service according to business information, realizes in Web server collection
It, can service logic plugging value be minimum in called Web service device cluster second when the first Web Server Service obstruction in group
Web server provides same services, avoids when using poll as load balancing, if a server node service hinders
Plug, then to the request newly received can not significant response, client can only overtime break link the case where, alleviate Web service
The service block situation of each Web server, improves the business processing efficiency of Web server cluster in device cluster.
In addition, as shown in Fig. 2, being the module frame chart of load balancing apparatus in the embodiment of the present invention, the load balancing apparatus
Applied to the first Web server in Web server cluster, the Web server cluster further includes removing first Web service
Other Web servers except device, described device include:
First receiving module 201, the HTTP request for receiving the transmission of Nginx servers, and obtain
Take the type of service of HTTP request institute requested service;
Determining module 202 detects first Web server the first business corresponding with the type of service for working as
When logic plugging value is greater than or equal to default blocking threshold, determine corresponding with the type of service in the Web server cluster
Service logic plugging value be minimum value the second Web server;
Sending module 203, second Web server for being determined to determining module 202 send remote procedure call
RPC message, wherein the RPC message carries the business information of institute's requested service, so that the second Web server root
Business processing is carried out to institute's requested service according to the business information.
Load balancing apparatus provided in an embodiment of the present invention receives Nginx servers by the first receiving module 201 and sends
HTTP request, and obtain the type of service of HTTP request institute requested service, then detecting the first Web server and business
When the corresponding first service logic plugging value of type is greater than or equal to default blocking threshold, Web clothes are determined by determining module 202
Service logic plugging value corresponding with type of service is the second Web server of minimum value in business device cluster, finally by transmission
The RPC that the second Web server transmission that module 203 is determined to determining module 202 carries the business information of requested service disappears
Breath realizes so that the second Web server can carry out business processing according to business information to institute's requested service in Web
It, can service logic plugging value be most in called Web service device cluster when the first Web Server Service obstruction in server cluster
The second small Web server provides same services, avoids when using poll as load balancing, if a server section
Point service block, then to the request newly received can not significant response, client can only overtime break link the case where, alleviate
The service block situation of each Web server, improves the business processing efficiency of Web server cluster in Web server cluster.
Optionally, in the Web server cluster each Web server be both provided with for the Nginx servers
The HTTP interface of communication;First receiving module 201 is used for, and by the HTTP interface, receives the Nginx servers hair
The HTTP request sent.
Optionally, described device further includes:
Acquisition module for obtaining the first service logic plugging value, and detects the first service logic plugging value
Whether the default blocking threshold is greater than or equal to;Wherein, the acquisition module includes:
First determination unit corresponds to industry for type of service described in the memory queue according to first Web server
The pending amount of business, determines the first service logic plugging value;Alternatively,
Second determination unit is used for according to first Web server business corresponding with the type of service when default
Average treatment duration in section, determines the first service logic plugging value.
Optionally, in the Web server cluster each Web server be both provided with for in Web server cluster
The RPC interfaces of other Web servers communication;
The determining module 202 includes:
Acquiring unit, for by the RPC interfaces, obtaining other Web servers and institute in the Web server cluster
State the corresponding second service logic plugging value of type of service;
Third determination unit, for determining the minimal service logic plugging value in the second service logic plugging value, and
The corresponding Web server of the minimal service logic plugging value is determined as the second Web server.
Optionally, the sending module 20 is used for:By the RPC interfaces, described in second Web server transmission
RPC message;Wherein, the header packet information of the RPC message includes:Wrap length, packet header size, method signature, business identification code ID, industry
Business sequence number, body matter length and body data.
Optionally, described device further includes:
Second receiving module, for by the RPC interfaces, receiving second Web server to the asked industry
Business carries out the handling result of business processing.
In this way, load balancing apparatus provided in an embodiment of the present invention, in the HTTP request for receiving Nginx servers and sending,
And when getting the type of service of HTTP request institute requested service, if detecting, the first Web server is corresponding with type of service
First service logic plugging value is greater than or equal to default blocking threshold, it is determined that corresponding with type of service in Web server cluster
Service logic plugging value be the second Web server of minimum value, and sent to the second Web server and carry requested service
Business information RPC message so that the second Web server can carry out at business institute requested service according to business information
Reason being capable of industry in called Web service device cluster when realizing the first Web Server Service obstruction in Web server cluster
Second Web server of logic plugging value minimum of being engaged in provides same services, avoids in use poll as load balancing
When, if a server node service block, to the request newly received can not significant response, client can only time-out disconnect chain
The case where connecing alleviates the service block situation of each Web server in Web server cluster, improves Web server cluster
Business processing efficiency.
It should be noted that in the embodiment of the present invention hardware processor (hardware processor) can be passed through
It realizes related function module, and identical technique effect can be reached, do not repeated herein.
In another embodiment of the present invention, a kind of Web server is provided, as shown in figure 3, the Web server packet
It includes memory (memory) 301, processor (processor) 302 and is stored on memory 301 and can be in processor 302
The computer program of upper operation.Wherein, the memory 301, processor 302 complete mutual communication by bus 303.Institute
Processor 302 is stated for calling the program instruction in the memory 301, to execute following method:Receive Nginx servers hair
The HTTP request sent, and obtain the type of service of HTTP request institute requested service;When detecting
It states the first Web server the first service logic plugging value corresponding with the type of service and is greater than or equal to default blocking threshold
When, determine that service logic plugging value corresponding with the type of service is the 2nd Web of minimum value in the Web server cluster
Server;Remote procedure call message is sent to second Web server, wherein the RPC message carries the institute
The business information of requested service, so that second Web server carries out institute's requested service according to the business information
Business processing.
Web server provided in an embodiment of the present invention can perform the specific steps in load-balancing method, and can reach
Identical technique effect, is herein no longer specifically introduced this.
In addition, the program instruction in above-mentioned memory 301 can be realized and be used as by the form of SFU software functional unit
Independent product sale in use, can be stored in a computer read/write memory medium.Based on this understanding, originally
Substantially the part of the part that contributes to existing technology or the technical solution can be in other words for the technical solution of invention
The form of software product embodies, which is stored in a storage medium, including some instructions to
So that a computer equipment (can be personal computer, server or the network equipment etc.) executes each implementation of the present invention
The all or part of step of example the method.And storage medium above-mentioned includes:USB flash disk, mobile hard disk, read-only memory (ROM,
Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disc or CD etc. it is various
The medium of program code can be stored.
In another embodiment of the present invention, a kind of non-transient computer readable storage medium is provided, is stored thereon with
Computer program, to execute following method when which is executed by processor:Receive the super text that Nginx servers are sent
This transport protocol HTTP request, and obtain the type of service of HTTP request institute requested service;When detecting the first Web
When server the first service logic plugging value corresponding with the type of service is greater than or equal to default blocking threshold, described in determination
Service logic plugging value corresponding with the type of service is the second Web server of minimum value in Web server cluster;To institute
It states the second Web server and sends remote procedure call message, wherein the RPC message carries institute's requested service
Business information, so that second Web server carries out business processing according to the business information to institute's requested service.
Non-transient computer readable storage medium provided in an embodiment of the present invention can perform specific in load-balancing method
Step, and identical technique effect can be reached, no longer this is specifically introduced herein.
In another embodiment of the present invention, a kind of computer program product, the computer program product packet are provided
The computer program being stored in non-transient computer readable storage medium is included, the computer program includes program instruction, when
To execute following method when described program instruction is computer-executed:Receive the hypertext transfer protocol that Nginx servers are sent
HTTP request, and obtain the type of service of HTTP request institute requested service;When detecting first Web server and institute
When stating the corresponding first service logic plugging value of type of service more than or equal to default blocking threshold, the Web server is determined
Service logic plugging value corresponding with the type of service is the second Web server of minimum value in cluster;To the 2nd Web
Server sends remote procedure call message, wherein the RPC message carries the business information of institute's requested service,
So that second Web server carries out business processing according to the business information to institute's requested service.
Computer program product provided in an embodiment of the present invention can perform the specific steps in load-balancing method, and energy
Enough reach identical technique effect, no longer this is specifically introduced herein.
The apparatus embodiments described above are merely exemplary, wherein the unit illustrated as separating component can
It is physically separated with being or may not be, the component shown as unit may or may not be physics list
Member, you can be located at a place, or may be distributed over multiple network units.It can be selected according to the actual needs
In some or all of module achieve the purpose of the solution of this embodiment.Those of ordinary skill in the art are not paying creativeness
Labour in the case of, you can to understand and implement.
Through the above description of the embodiments, those skilled in the art can be understood that each embodiment can
It is realized by the mode of software plus required general hardware platform, naturally it is also possible to pass through hardware.Based on this understanding, on
Stating technical solution, substantially the part that contributes to existing technology can be expressed in the form of software products in other words, should
Computer software product can store in a computer-readable storage medium, such as ROM/RAM, magnetic disc, CD, including several fingers
It enables and using so that a computer equipment (can be personal computer, server or the network equipment etc.) executes each implementation
Method described in certain parts of example or embodiment.
Finally it should be noted that:The above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although
Present invention has been described in detail with reference to the aforementioned embodiments, it will be understood by those of ordinary skill in the art that:It still may be used
With technical scheme described in the above embodiments is modified or equivalent replacement of some of the technical features;
And these modifications or replacements, various embodiments of the present invention technical solution that it does not separate the essence of the corresponding technical solution spirit and
Range.
Claims (9)
1. a kind of load-balancing method, the first Web server being applied in Web server cluster, the Web server cluster
Further include other Web servers in addition to first Web server, which is characterized in that the method includes:
The HTTP request that Nginx servers are sent is received, and obtains HTTP request institute requested service
Type of service;
When detecting that first Web server the first service logic plugging value corresponding with the type of service is greater than or equal to
When default blocking threshold, determine that service logic plugging value corresponding with the type of service is most in the Web server cluster
Second Web server of small value;
Remote procedure call message is sent to second Web server, wherein the RPC message carries described asked
Seek the business information of business so that second Web server according to the business information to institute's requested service into industry
Business is handled.
2. according to the method described in claim 1, it is characterized in that, each Web server is all provided in the Web server cluster
It is equipped with for the HTTP interface with the Nginx server communications;
The HTTP request for receiving Nginx servers and sending, including:
By the HTTP interface, the HTTP request that the Nginx servers are sent is received.
3. according to the method described in claim 1, it is characterized in that, when detecting first Web server and the business
The corresponding first service logic plugging value of type is greater than or equal to before default blocking threshold, and the method further includes:
The first service logic plugging value is obtained, and whether detects the first service logic plugging value more than or equal to described
Default blocking threshold;Wherein,
Acquisition the first service logic plugging value, including:
Correspond to the pending amount of business according to type of service described in the memory queue of first Web server, determine described in
First service logic plugging value;Alternatively,
According to average treatment duration of first Web server business corresponding with the type of service in preset period of time, really
The fixed first service logic plugging value.
4. according to the method described in claim 1, it is characterized in that, each Web server is all provided in the Web server cluster
It is equipped with the RPC interfaces for being communicated with other Web servers in Web server cluster;
Service logic plugging value corresponding with the type of service is the of minimum value in the determination Web server cluster
Two Web servers, including:
By the RPC interfaces, it is corresponding with the type of service to obtain other Web servers in the Web server cluster
Second service logic plugging value;
It determines the minimal service logic plugging value in the second service logic plugging value, and the minimal service logic is blocked
It is worth corresponding Web server and is determined as the second Web server.
5. according to the method described in claim 4, it is characterized in that, described send remote process to second Web server
RPC message is called, including:
By the RPC interfaces, the RPC message is sent to second Web server;Wherein, the packet header of the RPC message
Information includes:Wrap length, packet header size, method signature, business identification code ID, traffic sequence number, body matter length and main body number
According to.
6. according to the method described in claim 4, it is characterized in that, described send remote process to second Web server
After calling RPC message, further include:
By the RPC interfaces, the processing knot that second Web server carries out institute's requested service business processing is received
Fruit.
7. a kind of load balancing apparatus, the first Web server being applied in Web server cluster, the Web server cluster
Further include other Web servers in addition to first Web server, which is characterized in that described device includes:
First receiving module, the HTTP request for receiving the transmission of Nginx servers, and described in acquisition
The type of service of HTTP request institute requested service;
Determining module detects first Web server the first service logic resistance corresponding with the type of service for working as
When plug value is greater than or equal to default blocking threshold, business corresponding with the type of service in the Web server cluster is determined
Logic plugging value is the second Web server of minimum value;
Sending module, for sending remote procedure call message to second Web server, wherein the RPC message is taken
Business information with institute's requested service, so that second Web server is asked according to the business information to described
Business is asked to carry out business processing.
8. a kind of Web server, including memory, processor and storage are on a memory and the calculating that can run on a processor
Machine program, which is characterized in that the processor is realized when executing the computer program such as any one of claim 1 to 6 institute
The step of load-balancing method stated.
9. a kind of non-transient computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer journey
It is realized such as the step of claim 1 to 6 any one of them load-balancing method when sequence is executed by processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810455244.7A CN108718335A (en) | 2018-05-14 | 2018-05-14 | A kind of load-balancing method, device, Web server and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810455244.7A CN108718335A (en) | 2018-05-14 | 2018-05-14 | A kind of load-balancing method, device, Web server and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108718335A true CN108718335A (en) | 2018-10-30 |
Family
ID=63899882
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810455244.7A Pending CN108718335A (en) | 2018-05-14 | 2018-05-14 | A kind of load-balancing method, device, Web server and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108718335A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110430275A (en) * | 2019-08-09 | 2019-11-08 | 中国工商银行股份有限公司 | Data processing method, system, calculates equipment and medium at device |
CN110597920A (en) * | 2019-09-26 | 2019-12-20 | 腾讯云计算(北京)有限责任公司 | Information processing method and device |
CN113242286A (en) * | 2021-05-06 | 2021-08-10 | 杭州复杂美科技有限公司 | Method, equipment and storage medium for flexibly improving transaction throughput |
CN113254207A (en) * | 2021-05-26 | 2021-08-13 | 北京达佳互联信息技术有限公司 | Identification code generation method and device, server and storage medium |
Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2003010907A1 (en) * | 2001-07-25 | 2003-02-06 | Atitania Ltd. | Load balancing a distributed processing system |
CN102056333A (en) * | 2009-11-05 | 2011-05-11 | 中国移动通信集团河南有限公司 | WAP (wireless application protocol) gateway, service processing method thereof and WAP proxy server |
CN102387529A (en) * | 2010-08-27 | 2012-03-21 | 中兴通讯股份有限公司 | Method and device for load balance under multi-mode controller mode |
CN103109564A (en) * | 2012-09-14 | 2013-05-15 | 华为技术有限公司 | Network switching method, device, base station, and base station controller |
CN103516744A (en) * | 2012-06-20 | 2014-01-15 | 阿里巴巴集团控股有限公司 | A data processing method, an application server and an application server cluster |
CN105516347A (en) * | 2015-12-31 | 2016-04-20 | 浙江大华系统工程有限公司 | Method and device for load balance allocation of streaming media server |
CN106385468A (en) * | 2016-12-07 | 2017-02-08 | 西安电子科技大学 | Method for balancing predictable dynamic load of Web clusters |
CN106385459A (en) * | 2016-10-20 | 2017-02-08 | 杭州迪普科技有限公司 | Method and device for distributing connection request message |
CN106649865A (en) * | 2016-12-31 | 2017-05-10 | 深圳市优必选科技有限公司 | Distributed server system and data processing method |
CN106657379A (en) * | 2017-01-06 | 2017-05-10 | 重庆邮电大学 | Implementation method and system for NGINX server load balancing |
-
2018
- 2018-05-14 CN CN201810455244.7A patent/CN108718335A/en active Pending
Patent Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2003010907A1 (en) * | 2001-07-25 | 2003-02-06 | Atitania Ltd. | Load balancing a distributed processing system |
CN102056333A (en) * | 2009-11-05 | 2011-05-11 | 中国移动通信集团河南有限公司 | WAP (wireless application protocol) gateway, service processing method thereof and WAP proxy server |
CN102387529A (en) * | 2010-08-27 | 2012-03-21 | 中兴通讯股份有限公司 | Method and device for load balance under multi-mode controller mode |
CN103516744A (en) * | 2012-06-20 | 2014-01-15 | 阿里巴巴集团控股有限公司 | A data processing method, an application server and an application server cluster |
CN103109564A (en) * | 2012-09-14 | 2013-05-15 | 华为技术有限公司 | Network switching method, device, base station, and base station controller |
CN105516347A (en) * | 2015-12-31 | 2016-04-20 | 浙江大华系统工程有限公司 | Method and device for load balance allocation of streaming media server |
CN106385459A (en) * | 2016-10-20 | 2017-02-08 | 杭州迪普科技有限公司 | Method and device for distributing connection request message |
CN106385468A (en) * | 2016-12-07 | 2017-02-08 | 西安电子科技大学 | Method for balancing predictable dynamic load of Web clusters |
CN106649865A (en) * | 2016-12-31 | 2017-05-10 | 深圳市优必选科技有限公司 | Distributed server system and data processing method |
CN106657379A (en) * | 2017-01-06 | 2017-05-10 | 重庆邮电大学 | Implementation method and system for NGINX server load balancing |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110430275A (en) * | 2019-08-09 | 2019-11-08 | 中国工商银行股份有限公司 | Data processing method, system, calculates equipment and medium at device |
CN110430275B (en) * | 2019-08-09 | 2022-07-08 | 中国工商银行股份有限公司 | Data processing method, device, system, computing equipment and medium |
CN110597920A (en) * | 2019-09-26 | 2019-12-20 | 腾讯云计算(北京)有限责任公司 | Information processing method and device |
CN110597920B (en) * | 2019-09-26 | 2024-02-23 | 腾讯云计算(北京)有限责任公司 | Information processing method and device |
CN113242286A (en) * | 2021-05-06 | 2021-08-10 | 杭州复杂美科技有限公司 | Method, equipment and storage medium for flexibly improving transaction throughput |
CN113242286B (en) * | 2021-05-06 | 2022-05-24 | 杭州复杂美科技有限公司 | Method, equipment and storage medium for flexibly improving transaction throughput |
CN113254207A (en) * | 2021-05-26 | 2021-08-13 | 北京达佳互联信息技术有限公司 | Identification code generation method and device, server and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108718335A (en) | A kind of load-balancing method, device, Web server and storage medium | |
CN106549878B (en) | Service distribution method and device | |
CN107800756A (en) | A kind of load-balancing method and load equalizer | |
CN104932932B (en) | A kind of business asynchronous processing method, device and system | |
CN107634915A (en) | Data transmission method, device and storage medium | |
CN105025080B (en) | A kind of overload protection method and server of distributed system | |
US11249826B2 (en) | Link optimization for callout request messages | |
CN107295048A (en) | Load-balancing method and device | |
CN108134830A (en) | Load-balancing method, system, device and storage medium based on message queue | |
CN106878197A (en) | A kind of management system and method for the transmission of cloud platform message | |
CN107666474B (en) | Network message processing method and device and network server | |
CN105897615A (en) | Data transmission method and device | |
CN110855741B (en) | Service self-adaptive access method and device, storage medium and electronic device | |
CN114513467B (en) | Network traffic load balancing method and device of data center | |
CN111385328B (en) | Service request processing method, system and electronic equipment | |
CN104301241B (en) | A kind of SOA dynamic load distributing methods and system | |
CN106570011B (en) | Distributed crawler URL seed distribution method, scheduling node and capturing node | |
CN110597631B (en) | Resource management method, monitoring server, proxy server, and storage medium | |
CN107343037A (en) | The data transmission method and device of a kind of distributed memory system | |
US10972356B2 (en) | Method for selecting negotiation counterpart, method for responding to discovery message, and related apparatus | |
CN103078720B (en) | Message processing method and device | |
US20150304202A1 (en) | Methods, systems, and computer readable media for sustaining active control over concurrent session connections | |
CN109347894A (en) | Manage method, manager, equipment and the medium of FastCGI process | |
US10623319B1 (en) | Load rebalancing in a network-based system | |
CN107659511A (en) | A kind of overload controlling method, main frame and storage medium and program product |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20181030 |
|
RJ01 | Rejection of invention patent application after publication |