WebApi deploy a multi-server load balancing configuration Nginx

01PARTCoreWebApi tutorial demonstrates the local environment

Visual Studio2019 --- Vsersion:16.4.4 + NetCore3.1.2

02PARTNginx quickly build configure load balancing

Nginx is a lightweight Web server / reverse proxy server and e-mail (IMAP / POP3) proxy server, distributed under BSD-like agreement. It features occupy less memory, high concurrency, concurrent nginx fact the same type of ability in web server performance is better, mainland China use nginx web site users are: Baidu, Jingdong, Sina, Netease, Tencent, Taobao.

Here we show you the process of configuring Nginx

1. Download Nginx package: note storage path Nginx download the package must be in English; not with the Chinese character;

2. Start Nginx: Nginx directly to the download package, double-click to open the "nginx.exe" can be, you can start by command; command to start here does not explain; after launch, open the Task Manager, you will find the Task Manager will there Nginx services;

3. At this point you can use to configure Nginx load balancing, and I would like to start more WebApi server up and running, with a return of interface data for each server is slightly different; the first server interfaces I returned data is: --- 1 education overnight, the interface returns the data to the second server: education --- 2 overnight, the interface returns the data to the third server: --- 3 education overnight; after the server-initiated three ports are: 8011,8022,8033; 8011 port that is returned is: day and night education --- 1; return to port 8022 is: day and night education --- 2; 8033 port returns: overnight Education --- 3; that is the same as three server code returns the results presented here are not the same, in order to be able to distinguish test.

4. After starting debug results:

return: education --- 1 day and night;

return: education --- 2 day and night;

return: education day and night --- 3;

1 2 3

The tests showed that all three services has been launched: At this point I will configure three bronze drums nginx server cluster; configuration at the configuration file;

Figure 4

 

Modify the configuration file as follows:

CMD execution nginx-s reload command; reload services; tests are as follows:

6. The requests for the same address: three times to obtain a different result;

FIG 1 FIG 2

image 3


END

Reference herein Great God know almost Share https://zhuanlan.zhihu.com/p/112880145

Guess you like

Origin www.cnblogs.com/Gyutao/p/12512354.html