Tutorial on deploying multiple servers with WebApi and configuring Nginx load balancing

Tutorial on deploying multiple servers with WebApi and configuring Nginx load balancing

01PARTCoreWebApi tutorial local demonstration environment

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

02PARTNginx quickly builds and configures load balancing

Nginx is a lightweight web server/reverse proxy server and email (IMAP/POP3) proxy server released under the BSD-like protocol. Its characteristics are that it occupies less memory and has strong concurrency capabilities. In fact, nginx's concurrency capabilities perform better among web servers of the same type. Users of nginx websites in mainland China include: Baidu, JD.com, Sina, NetEase, Tencent, Taobao, etc.

The following demonstrates the process of configuring Nginx

1. Download the Nginx package: http://nginx.org/en/download.html Note that the path for downloading and storing the Nginx package must be in English and cannot contain Chinese characters;

2. Start Nginx: Just double-click the downloaded Nginx package to open "nginx.exe", or you can start it through the command; the command start is not explained in detail here; after starting, open the task manager, and you will find that there will be Nginx service in the task manager;

3. At this time, you can use Nginx to configure load balancing. I first start multiple WebApi servers and run them. The data returned by the same interface of each server is slightly different. The data returned by the interface of the first server is: Chaoxi Education---1, the data returned by the interface of the second server is: Chaoxi Education---2, and the data returned by the interface of the third server is: Chaoxi Education---3. The ports of the three servers after startup are: 8011, 8022, and 8033 respectively. In other words, the 8011 port returns: Chaoxi Education---1; the 8022 port returns: Chaoxi Education---2; the 8033 port returns: Chaoxi Education---3. In other words, the three server codes are the same, but the results returned here are different, in order to be able to test the difference.

4. After startup, the debugging results are:

http://127.0.0.1:8011/api/First returns: Chaoxi Education---1;

http://127.0.0.1:8022/api/First returns: Chaoxi Education---2;

http://127.0.0.1:8033/api/First returns: Chaoxi Education---3;

Figure 1

Figure 2

Figure 3

5. The test shows that all three services have been started: At this time, I will configure three server Tonggu nginx clusters; configure the configuration files;

Figure 4

Modify the configuration file as follows:

CMD executes the nginx-s reload command; reloads the service; the test is as follows:

6. Request the same address: http://127.0.0.1:8080/api/First three times and get three different results;

Figure 1

Figure 2

Figure 3

Summarize

This is the end of this article about WebApi deployment on multiple servers and Nginx load balancing configuration. For more information about WebApi deployment on multiple servers and Nginx load balancing configuration, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Nginx/Httpd load balancing tomcat configuration tutorial
  • Nginx load balancing configuration, automatic switching mode when downtime occurs
  • Detailed explanation of Nginx configuration parameters in Chinese (load balancing and reverse proxy)
  • Nginx forward and reverse proxy and load balancing functions configuration code example
  • Implementation of Nginx load balancing/SSL configuration
  • Detailed explanation of nginx server installation and load balancing configuration on Linux system
  • How to configure multiple tomcats with Nginx load balancing under Linux
  • Nginx server load balancing and ssl principle, generate ssl key pair, Nginx configuration ssl operation example
  • Detailed explanation of installing nginx server and load balancing configuration in CentOS6.5 environment
  • Nginx load balancing configuration simple configuration method
  • Detailed explanation of Linux system configuration nginx load balancing
  • Analysis of Nginx cluster load balancing configuration process
  • What is Nginx load balancing and how to configure it

<<:  Detailed explanation of the use of HTML canvas and page storage technology in JavaScript

>>:  ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

Recommend

MySQL Server IO 100% Analysis and Optimization Solution

Preface During the stress test, if the most direc...

Docker memory monitoring and stress testing methods

The Docker container that has been running shows ...

Introduction to who command examples in Linux

About who Displays users logged into the system. ...

How to use Web front-end vector icons

Preface When writing front-end pages, we often us...

Vue implements form data validation example code

Add rules to the el-form form: Define rules in da...

SQL implementation of LeetCode (177. Nth highest salary)

[LeetCode] 177.Nth Highest Salary Write a SQL que...

How to solve the problem of MySQL query character set mismatch

Find the problem I recently encountered a problem...

Linux configuration SSH password-free login "ssh-keygen" basic usage

Table of contents 1 What is SSH 2 Configure SSH p...

Thoughts on copy_{to, from}_user() in the Linux kernel

Table of contents 1. What is copy_{to,from}_user(...

How to implement a binary search tree using JavaScript

One of the most commonly used and discussed data ...

Steps for Vue to use Ref to get components across levels

Vue uses Ref to get component instances across le...

HTML text escape tips

Today I saw a little trick for HTML text escaping ...

What are the differences between var let const in JavaScript

Table of contents 1. Repeated declaration 1.1 var...

Vue.js implements music player

This article shares the specific code of Vue.js t...