In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
The purpose of this article is to share with you the content of an example of nginx load balancing under linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
First of all, let's take a look at load balancing. Suppose a scenario where 1000 customers access your server at the same time, and you have only one server's Nginx and only one MySQL server, then these requests
It may be higher than your server can bear, and then down will be dropped.
Solution:
1. Vertical upgrade: increase the configuration of the server, CPU, memory, etc.
two。 Horizontal upgrade: add multiple servers to share the server pressure
Common load balancers
According to the protocol layer in which you work, it can be divided into:
Layer-4 load balancing: scheduling according to the destination address and port in the request message
Layer 7 load balancer: schedule according to the content of the request message, which belongs to the "agent" mode
Divided according to hardware and software:
Hardware load balancing: BIG-IP of ◦ F5
NetScaler of Citrix
This kind of hardware load balancer usually provides both layer 4 and layer 7 load balancers, but it is also expensive.
Software load balancing: ◦ TCP layer: LVS,HaProxy,Nginx
Based on HTTP protocol: Haproxy,Nginx,ATS (Apache Traffic Server), squid,varnish
Based on MySQL protocol: mysql-proxy
[1. What can Nginx do]
1. Http server. Nginx is a http service that can provide http services independently. Can be used as a web static server.
2. Virtual host. It is possible to virtualize multiple websites on one server. For example, virtual hosts used in personal networks.
3. Reverse proxy, load balancing. When the visit volume of the website reaches a certain degree, when a single server can not meet the user's request, multiple server clusters can be used as a reverse proxy using nginx. And multiple servers can share the load equally, not because of a server.
4. Solve the cross-domain problem.
[II. Installation]
1. Yum install nginx, prompt No package nginx available. Because nginx is located in a third-party yum source, but not in the official centos yum source, yum install epel-release first, and then yum install nginx after epel installation.
2. Service nginx start starts nginx. Enter the ip address in the browser to access the interface of nginx. If you can't, check the access status of the firewall and add port 80 access.
[3. Load balancing configuration]
After nginx starts, we need to modify the configuration file as needed. We can first use ps-ef | grep nginx to view the currently used configuration file.
Add the following configuration to the http module
Upstream servers {server 192.168.80.1:8010 weight=10; server 192.168.80.10:8010 weight=10;}
Change server to
Server {listen 80; server_name test.nginx.com; location / {proxy_pass http://servers;} location / buy {proxy_pass http://172.18.144.23:5789/;} error_page 500502 503 504 / 50x.htl; location = / 50x.html {root html;}}
Finally restart service nginx reload
In addition, it is important to keep in mind that the firewall access port can only be accessed normally.
Thank you for reading! This is the end of this article on "examples of nginx load balancing under linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.