In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
In large websites, load balancing is necessary. Especially for large websites with relatively large visits at the same time, such as online shopping malls, news and other CMS systems, in order to reduce the processing pressure of a single server, we introduced the concept of load balancing, sharing the pressure of one server among several servers, on the one hand, reducing the probability of downtime, on the other hand, other servers can continue to run stably after downtime, thus improving the robustness of the system.
[implement function]
The main contents of this article are as follows:
1. Configure three servers
2. Deploy the same service code on three servers
3. Use Nginx to achieve load balancing
[realization idea]
Our Nginx load balancer will be deployed on an interactive server, configure connections to the other two servers, all requests directly access the Nginx service interface, and then the Nginx load balancer will choose the actual server port to call.
[development and deployment environment]
Development environment: Windows 7 x64 sp1 English version
VisualStudio 2017
Deployment environment: Ali Cloud ECS instance windows server 2012 x64
IIS 7.0
[required technology]
ASP.NET WebApi2
[implementation process]
Use ASP.NET webapi2 to write an interface that simply returns json. To show that we are calling interfaces on different servers, we generate three interface services digitally and deploy them to the iis of the three servers.
Public IHttpActionResult GetTest () {/ / throw new Exception_DG_Internationalization (1001); string ip = Request.GetIpAddressFromRequest (); return OK ("Test Api. Client IpAddress is->" + ip+ "The Server is = 333 =");}
The number behind the three servers I deployed is 111222333.
Note: return OK is a custom return format. You can directly return Json () the simple code.
Request.GetIpAddressFromRequest (); is my extended method to obtain the ip address. Please implement it according to your own situation.
[system testing]
We generate three background codes and deploy them to three servers.
In order to keep the server information confidential, all of my ip addresses below will be identified by ip_A,ip_B,ip_C.
The third is the server on which we will deploy Nginx:
After deployment, we configure Nginx:
Download Nginx: http://nginx.org/en/download.html
Then extract it to the ip_C server and open nginx.conf under the conf folder
The editing content is as follows
Then we start the service:
The cmd command changes to the root directory of nginx
In this way, the service is started. Complain, why not prompt a service to start successfully.. Hey, it's not human!
Then we open any interface test tool and execute the same request three times:
Request 1.
Request 2.
Request 3.
It can be found that each time we call the backend service interface is not the same, which ensures that when a large number of customers visit the same server address, the pressure of one server can be shared among several servers, thus achieving the goal of load balancing.
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
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.