Movatterモバイル変換


[0]ホーム

URL:


CN109951566A - A kind of Nginx load-balancing method, device, equipment and readable storage medium storing program for executing - Google Patents

A kind of Nginx load-balancing method, device, equipment and readable storage medium storing program for executing
Download PDF

Info

Publication number
CN109951566A
CN109951566ACN201910260598.0ACN201910260598ACN109951566ACN 109951566 ACN109951566 ACN 109951566ACN 201910260598 ACN201910260598 ACN 201910260598ACN 109951566 ACN109951566 ACN 109951566A
Authority
CN
China
Prior art keywords
access request
end server
weight value
load balancing
nginx 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.)
Pending
Application number
CN201910260598.0A
Other languages
Chinese (zh)
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.)
SHENZHEN ZHONGBO KECHUANG INFORMATION TECHNOLOGY Co Ltd
Original Assignee
SHENZHEN ZHONGBO KECHUANG INFORMATION TECHNOLOGY Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SHENZHEN ZHONGBO KECHUANG INFORMATION TECHNOLOGY Co LtdfiledCriticalSHENZHEN ZHONGBO KECHUANG INFORMATION TECHNOLOGY Co Ltd
Priority to CN201910260598.0ApriorityCriticalpatent/CN109951566A/en
Publication of CN109951566ApublicationCriticalpatent/CN109951566A/en
Pendinglegal-statusCriticalCurrent

Links

Landscapes

Abstract

The invention discloses a kind of Nginx load-balancing method, device, equipment and readable storage medium storing program for executing.Method is comprising steps of be arranged weighted value to each back-end server;Receive the access request that client is initiated;Distribute access request to each back-end server according to the weighted value.The present invention is by being arranged weighted value to each back-end server, when receiving a large amount of concurrent access request that client is initiated, distribute access request to each back-end server according to weighted value, efficiently avoid the excessive problem of individual server data flow, alleviate the pressure of individual server, while the use that the resource of each back-end server can be made to be equalized.

Description

Nginx load balancing method, device, equipment and readable storage medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method, an apparatus, a device, and a readable storage medium for Nginx load balancing.
Background
Nginx: is a free, open source and high-performance HTTP server and reverse proxy server, and is also an IMAP, POP3 and SMTP proxy server.
With the continuous development of network technology, the number of network users increases sharply, and the demand for network access increases day by day, which puts a great pressure on the website server. The straight line increase of the number of concurrent services is a severe examination on the working performance of the server. In the prior art, a multi-server clustering technology is generally adopted to solve the problems, and load balancing is a core problem of the clustering technology. The Nginx can be used as a reverse proxy server for realizing load balancing. The reverse proxy is that a proxy server receives a connection request on the Internet, distributes the request to a server cluster on an internal network according to a certain rule method, and returns a result obtained from the server cluster to a client sending the connection request on the Internet. Therefore, it is crucial to research a method for load balancing of the Nginx, and the method has positive significance for the server to process high-concurrency requests.
Disclosure of Invention
The present invention is directed to solving, at least to some extent, one of the technical problems in the related art. To this end, it is an object of the present invention to provide a method of Nginx load balancing, thereby relieving the stress of individual servers.
The technical scheme adopted by the invention is as follows: an Nginx load balancing method, comprising the steps of:
setting a weight value for each back-end server;
receiving an access request initiated by a client;
and distributing an access request to each back-end server according to the weight value.
Further, the step of setting a weight value for each backend server specifically includes:
and setting a weight value according to the hardware configuration of each back-end server, wherein the higher the hardware configuration is, the larger the set weight value is, and the lower the hardware configuration is, the smaller the set weight value is.
Further, an Nginx load balancing method further includes the steps of:
and distributing the access request to each back-end server according to the hash value of the IP of the client initiating the access request.
Further, an Nginx load balancing method further includes the steps of:
and distributing the access request to each back-end server according to the response time of each back-end server to the access request.
Further, an Nginx load balancing method further includes the steps of:
and distributing the access request to each back-end server according to the hash value of the URL of the access request.
An Nginx load balancing apparatus, comprising:
a setting unit configured to set a weight value to each backend server;
the receiving unit is used for receiving an access request initiated by a client;
and the distribution unit is used for distributing the access request to each back-end server according to the weight value.
An Nginx load balancing apparatus comprising:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform one of the Nginx load balancing methods described above.
A computer-readable storage medium having stored thereon computer-executable instructions for causing a computer to perform a method of Nginx load balancing as described above.
The invention has the beneficial effects that:
according to the invention, the weighted value is set for each back-end server, and when a large number of concurrent access requests initiated by the client are received, the access requests are distributed to each back-end server according to the weighted values, so that the problem of overlarge data flow of a single server is effectively avoided, the pressure of the single server is reduced, and simultaneously, the resources of each back-end server can be used in a balanced manner.
Drawings
Fig. 1 is a flowchart of an exemplary method for Nginx load balancing according to the present invention.
Detailed Description
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
The invention provides a Nginx load balancing method, as shown in FIG. 1, comprising the following steps:
setting a weight value for each back-end server;
receiving an access request initiated by a client;
and distributing the access request to each back-end server according to the weight value.
As an improvement of the technical scheme, the step of setting a weight value for each backend server specifically includes:
the weight value of each back-end server is set according to the hardware configuration of each back-end server, the higher the hardware configuration is, the larger the set weight value is, and the lower the hardware configuration is, the smaller the set weight value is. The configuration is as follows:
where weight is a weighted value, then Nginx distributes twice as many access requests to the 192.168.1.11 server as to the 192.168.1.10 server.
Of course, the weight value may be set according to other indicators of the backend server.
If a certain back-end server is down, Nginx will automatically remove the back-end server from the queue, and no access request is distributed to the back-end server.
As an improvement of the technical scheme, the method for balancing the Nginx load further comprises the following steps:
and distributing the access request to each back-end server according to the hash value of the IP of the client initiating the access request. The configuration is as follows:
in this way, a client with a fixed IP address always accesses the same backend server, which also solves the problem of session (session control) sharing in a cluster deployment environment to a certain extent.
As an improvement of the technical scheme, the method for balancing the Nginx load further comprises the following steps:
and distributing the access request to each back-end server according to the response time of each back-end server to the access request.
The performance of each backend server is different, and the response time to the access request is long or short. Generally, an access request is preferentially distributed to a server having a short response time and high processing efficiency. Since Nginx by default does not support this algorithm, if this scheduling algorithm is to be used, the upstream _ fair module is installed. The configuration is as follows:
as an improvement of the technical scheme, the method for balancing the Nginx load further comprises the following steps:
and distributing the access request to each back-end server according to the hash value of the URL of the access request.
The URL of each access request points to a certain fixed back-end server, and the back-end server is effective when being a cache server, so that the cache efficiency can be improved under the condition that the Nginx is used as a static server. Since nginnx by default does not support this algorithm, if this scheduling algorithm is to be used, a hash package of nginnx is installed. The configuration is as follows: url (url)
The present invention also provides an Nginx load balancing apparatus, comprising:
a setting unit configured to set a weight value to each backend server;
the receiving unit is used for receiving an access request initiated by a client;
and the distribution unit is used for distributing the access request to each back-end server according to the weight value.
The present invention also provides a nginnx load balancing apparatus, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a method of Nginx load balancing as described above.
The present invention also provides a computer-readable storage medium having stored thereon computer-executable instructions for causing a computer to perform a method for Nginx load balancing as described above.
While the preferred embodiments of the present invention have been illustrated and described, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (8)

CN201910260598.0A2019-04-022019-04-02A kind of Nginx load-balancing method, device, equipment and readable storage medium storing program for executingPendingCN109951566A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201910260598.0ACN109951566A (en)2019-04-022019-04-02A kind of Nginx load-balancing method, device, equipment and readable storage medium storing program for executing

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201910260598.0ACN109951566A (en)2019-04-022019-04-02A kind of Nginx load-balancing method, device, equipment and readable storage medium storing program for executing

Publications (1)

Publication NumberPublication Date
CN109951566Atrue CN109951566A (en)2019-06-28

Family

ID=67013408

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201910260598.0APendingCN109951566A (en)2019-04-022019-04-02A kind of Nginx load-balancing method, device, equipment and readable storage medium storing program for executing

Country Status (1)

CountryLink
CN (1)CN109951566A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN110839086A (en)*2019-12-232020-02-25吉林省民航机场集团公司High-concurrency load balancing processing method
CN111913732A (en)*2020-08-282020-11-10平安国际智慧城市科技股份有限公司Service updating method and device, management server and storage medium
CN112911009A (en)*2021-02-032021-06-04叮当快药科技集团有限公司Access load balancing system and method
CN112995265A (en)*2019-12-182021-06-18中国移动通信集团四川有限公司Request distribution method and device and electronic equipment
CN113608751A (en)*2021-08-042021-11-05北京百度网讯科技有限公司 Operation method, device, device and storage medium of reasoning service platform
CN113746933A (en)*2021-09-142021-12-03京东科技信息技术有限公司Method and device for displaying information
CN114465767A (en)*2021-12-272022-05-10天翼云科技有限公司Data scheduling method and equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102118433A (en)*2010-12-272011-07-06网宿科技股份有限公司Multiple-tier distributed cluster system
CN102882939A (en)*2012-09-102013-01-16北京蓝汛通信技术有限责任公司Load balancing method, load balancing equipment and extensive domain acceleration access system
WO2015035816A1 (en)*2013-09-122015-03-19中兴通讯股份有限公司Nginx server configuration maintenance method and system
CN105554160A (en)*2016-01-292016-05-04四川长虹电器股份有限公司Dubbo distributed cluster system architecture method based on nginx load balancing
CN106209666A (en)*2015-05-072016-12-07中兴通讯股份有限公司A kind of link multiplexing method based on load equalizer and system
CN109308221A (en)*2018-08-022019-02-05南京邮电大学 A Nginx dynamic load balancing method based on WebSocket long connection

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102118433A (en)*2010-12-272011-07-06网宿科技股份有限公司Multiple-tier distributed cluster system
CN102882939A (en)*2012-09-102013-01-16北京蓝汛通信技术有限责任公司Load balancing method, load balancing equipment and extensive domain acceleration access system
WO2015035816A1 (en)*2013-09-122015-03-19中兴通讯股份有限公司Nginx server configuration maintenance method and system
CN106209666A (en)*2015-05-072016-12-07中兴通讯股份有限公司A kind of link multiplexing method based on load equalizer and system
CN105554160A (en)*2016-01-292016-05-04四川长虹电器股份有限公司Dubbo distributed cluster system architecture method based on nginx load balancing
CN109308221A (en)*2018-08-022019-02-05南京邮电大学 A Nginx dynamic load balancing method based on WebSocket long connection

Cited By (7)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN112995265A (en)*2019-12-182021-06-18中国移动通信集团四川有限公司Request distribution method and device and electronic equipment
CN110839086A (en)*2019-12-232020-02-25吉林省民航机场集团公司High-concurrency load balancing processing method
CN111913732A (en)*2020-08-282020-11-10平安国际智慧城市科技股份有限公司Service updating method and device, management server and storage medium
CN112911009A (en)*2021-02-032021-06-04叮当快药科技集团有限公司Access load balancing system and method
CN113608751A (en)*2021-08-042021-11-05北京百度网讯科技有限公司 Operation method, device, device and storage medium of reasoning service platform
CN113746933A (en)*2021-09-142021-12-03京东科技信息技术有限公司Method and device for displaying information
CN114465767A (en)*2021-12-272022-05-10天翼云科技有限公司Data scheduling method and equipment

Similar Documents

PublicationPublication DateTitle
CN109951566A (en)A kind of Nginx load-balancing method, device, equipment and readable storage medium storing program for executing
US20210144423A1 (en)Dynamic binding for use in content distribution
US9456056B2 (en)Load balancing utilizing adaptive thresholding
CN104580538B (en)A kind of method of raising Nginx server load balancing efficiency
US10044797B2 (en)Load balancing of distributed services
US9116752B1 (en)Systems, methods, devices and arrangements for server load distribution
CN113037869A (en)Method and apparatus for back-sourcing of content distribution network system
CN110430274A (en)A kind of document down loading method and system based on cloud storage
CN103731487A (en)Download method, device, system and router for resource file
CN108494868A (en)A kind of load-balancing method under the operation system based on cloud and system
US10097616B2 (en)Methods for optimizing service of content requests and devices thereof
CN105516360A (en)Method and device for load balance of computer
CN102394929A (en) A session-oriented cloud computing load balancing system and method thereof
CN112491066B (en)Load balancing method, device, system, target load balancing equipment and medium
CN102932434A (en)Method and device for carrying out load balancing on server
JP4394710B2 (en) Load control apparatus, method, and program
US10341454B2 (en)Video and media content delivery network storage in elastic clouds
Nakai et al.Improving the QoS of web services via client-based load distribution
WO2024138821A1 (en)Method and apparatus for refreshing cdn cache
Abukari et al.AnEnhancedLoad Balancing Algorithm for Cloud Enterprise Resource Planning (ERP) DatainaMulti-CloudEnvironment
CN107888633A (en)Document distribution method and device
CN106657277A (en)Http proxy service method and server and system
TWI439872B (en)Interactive cloud communication system
CN113132133B (en)Method, device, computing equipment and storage medium for distributing user configuration data
JP2013222407A (en)System having flow rate control function

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
RJ01Rejection of invention patent application after publication
RJ01Rejection of invention patent application after publication

Application publication date:20190628


[8]ページ先頭

©2009-2025 Movatter.jp