If you have paid attention to nginx, you must know what the nginx software is used for. If the number of visits to your website is getting higher and higher, and one server can no longer bear the traffic pressure, then add a few more servers to handle the load. You can buy hardware equipment to load the website, such as F5, but the price is hundreds of thousands to millions, which is expensive enough. This article introduces the software to load the website is free, and nginx is currently used by many portals and websites with high traffic volume. I am using nginx as an HTTP server, so nginx is very good. Let’s introduce the load test below.
Environment:
(2 servers)
First server:
CPU: Inter(R) Pentium(R) 4 CPU 2.8G
Memory: 1G
System: windows 7
IIS: IIS 7
nginx: nginx/Windows- 0.8.22
IP: 172.10.1.97
Environment: Local
Second unit:
CPU:Inter(R) Pentium(R) 4 CPU 3.0G
Memory: 2G
System: windows Server 2003
IIS: IIS 6
IP : 172.10.1.236
Environment: Remote
Description:
For this test, the software nginx is placed locally (172.10.1.97), which means it is placed on the server where the domain name is bound. The IIS of this server cannot use port 80 , because the nginx software will use port 80 later.
The address to download nginx is as follows:
nginx download: http://nginx.net/
Download the version used in this test: nginx/Windows-0.8.22
Download and extract to C:, change the directory name to nginx
Okay, let’s get into practice:
First:
Create a website on the local server IIS (172.10.1.97), using port 808, as shown below:
Second:
On the remote 172.10.1.236 IIS creates a website, using port 80, as shown below:
Third:
Okay, the above has set up the IIS of the two servers, let’s configure the nginx software to achieve website load balancing, open the following file:
C:nginxconfnginx.conf
1. Find the content server {
Add the following content here:
upstream xueit.com {
server 172.10.1.97:808;
server 172.10.1.236:80;
}
(This is the server website IP used for load switching)
2. Find location / {
proxy_pass http ://xueit.com/;
proxy_redirect default;
Listen 80;
(This is to monitor the request to access port 80 of the server bound to the domain name)
Okay, it is so simple to configure it here. Let’s take a look at the above 3-step configuration diagram:
Fourth:
It’s all configured, let’s start the nginx software
Enter the command prompt CMD, enter c:nginx>, enter the nginx command, as shown below:
At this time, the system process has two nginx.exe processes, as shown below:运 Stop Nginx Run input Nginx -S STOP to
Fifth:
After the above configuration, we now see the load effect: Local (172.10.1.97) This server opens IE, IE, Input: http://172.10.1.97/
The result of opening the website for the first time:
Refresh the web page again, and the result image that appears:
Very good, the website has been loaded successfully. After this test, it is no longer difficult to achieve website load. There is no need to buy very expensive hardware equipment. Online introductions say that nginx software can handle tens of thousands of concurrent requests, so it is definitely a very good choice.
If the website visits are very large, you can use one server to run nginx, and other servers to run the website program (the programs of several servers are the same), so that the load will not be a big problem. If it still doesn't work, put some of the website The column is a second-level domain name, and the second-level domain name is also loaded. This is even more powerful.
The performance of nginx software running on Linux is better than running on Windows, so you can use Linux to run nginx for load, and the website developed by .net is placed on the Windows server IIS.
The above introduces the balanced load of nginx and IIS, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.