In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Background
When a website grows from small to large, the number of visits increases gradually and the existing server can no longer support it. The general solutions are caching, adding servers, database read-write separation, load balancing distribution, and so on. I have not practiced these technical solutions in the project.
But I have always heard from my colleagues that I use my spare time to learn about myself.
Load balancing
What is load balancing, that is, when you are about to be overwhelmed, you will be given another server to share the pressure, and the request will be assigned to two servers, and deploying the same content on the two servers is equivalent to a separate person who can handle the same thing.
Nginx as a load balancing server, the user request arrives at nginx first, and then nginx forwards the request to different Web servers according to the load configuration.
Nginx profile
1) download http://nginx.org/en/download.html from Nginx's official website
2) install Nginx and locate the nginx.conf file (C:\ nginx\ conf\ nginx.conf)
Add configuration to http:
Weighted polling, which is weighted according to the performance of the server, in this case at 1:2
Upstream www.woizuqiu.com {server 192.168.1.1:8080 weight=1; server 192.168.1.1:8090 weight=2;}
Ip_hash polling method, which cannot give weight to the server. Nginx will make the same client ip request the same server.
Upstream www.woizuqiu.com {server 192.168.1.1 max_fails=3 fail_timeout=30s 8080; server 192.168.1.1 max_fails=3 fail_timeout=30s; ip_hash;}
According to the performance differences and functions of the server itself, different parameter controls can be set.
Down indicates overload or does not participate in the load.
If the weight of weight is too high, the greater the load will be.
The backup server is requested only when backup other servers or down
If max_fails fails more than the specified number of times, it will pause or request transfer to another server.
Pause time when fail_timeout fails more than a specified number of times
The server configuration is as follows:
Server {listen 80; server_name www.woizuqiu.com; # charset koi8-r; # access_log logs/host.access.log main; location / {add_header backendIP $upstream_addr;# is forwarded to the upstream server address add_header backendCode $upstream_status;# status code proxy_pass http://www.woizuqiu.com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr Proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}
1. View the Nginx version:
C:\ nginx > nginx-v
two。 Start Nginx:
C:\ nginx > start nginx
Port 80 is required to start Nginx. Common error: bind () to 0.0.0.0 to 8080 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions), port 80 of the system needs to be turned off
Check port: netstat-aon | findstr: 80
3. Determine if Nginx is started:
Tasklist / fi "imagename eq nginx.exe"
4. Stop:
C:\ nginx > nginx.exe-s stop
5. Reload Nginx:
C:\ nginx > nginx.exe-s reload
Summary
The above is the simple configuration method of Nginx load balance configuration introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply you in time. Thank you very much for your support to the website!
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.