If you have been paying attention to nginx, you must know what the nginx software is for. If your website traffic is getting higher and higher, one server can no longer withstand traffic pressure, let's increase the number of servers for load. Website load can be achieved by buying hardware devices, such as F5, but the price ranges from hundreds of thousands to millions, which is expensive. This article introduces that the software for website load is free of charge, nginx is currently used as an HTTP server for many portal websites and websites with high traffic volumes. Therefore, nginx is excellent. Let's introduce it for load testing.
Environment:
(2 servers)
First:
CPU: inter (r) Pentium (r) 4 CPU 2.8g
Memory: 1 GB
System: Windows 7
IIS: IIS 7
Nginx: nginx/Windows-0.8.22
IP: 172.10.1.97
Environment: Local
Second:
CPU: inter (r) Pentium (r) 4 CPU 3.0g
Memory: 2 GB
Windows Server 2003
IIS: IIS 6
IP: 172.10.1.236
Environment: Remote
Note:
In this test, the software nginx is placed locally (172.10.1.97), that is, the server bound to the domain name. The IIS of this server cannot use port 80, because the nginx software must use port 80.
The nginx download address is as follows:
Nginx download: http://nginx.net/
Download the version used in this test: nginx/Windows-0.8.22
Download and decompress the package to C:, and change the directory name to nginx.
Well, let's go to practice:
First:
On the local server (172.10.1.97), create a website using the port 808, for example:
IIS website binding settings
Second:
Create a website in the Remote IIS 172.10.1.236 using port 80, for example:
Remote IIS binding settings
Third:
Now, the IIS of the two servers has been set up. Configure the nginx software to achieve website load balancing. Open the following file:
C: \ nginx \ conf \ nginx. conf
1. Find Content Server {
Add the following content to it:
Upstream xueit.com {
Server 172.10.1.97: 808;
Server 172.10.1.236: 80;
}
(This is the IP address of the server website used for Load Switching)
2. Locate location /{
Root HTML;
Index index.html index.htm;
}
Change the content as follows:
Location /{
Proxy_pass http://xueit.com;
Proxy_redirect default;
}
3. Find server {
Listen 80;
SERVER_NAME localhost;
Change the content to the following:
Server {
Listen 80;
SERVER_NAME 172.10.1.97;
(This is a request to listen to the access domain name bound to port 80 of the server)
Well, the configuration is as simple as this. The following figure shows the configuration of the above three steps:
Load configuration Diagram
Fourth:
All configured. Start the nginx software below.
Enter the command prompt cmd, enter c: \ nginx>, and enter the nginx command, such:
Start nginx
At this time, there are two nginx.exe processes in the system process, such:
System nginx Process
Stop nginx running enter nginx-s stop
Fifth:
After the above configuration, let's look at the load effect:
On the local server (172.10.1.97), open IE and enter http: // 172.10.1.97.
Result chart of the first website opened:
First website running
Refresh the page and the result diagram is as follows:
View the website again
Good. The website has been loaded successfully.
After this test, it is no longer difficult to implement website load. You do not need to purchase expensive hardware. According to the introduction on the internet, nginx software can handle tens of thousands of concurrent jobs, so it is definitely a very good choice.
If the website traffic is very large, you can use a dedicated server to run nginx and other servers to run the websiteProgram(The programs on several servers are the same). In this way, the load will not be too high. If it doesn't work any more, make some sections of the website a second-level domain name, and the second-level domain name will also carry the same load, this is even worse.
The performance of nginx in Linux is better than that in windows. Therefore, you can run nginx in Linux and put the website developed by. Net to IIS on Windows server.
from: http://www.xueit.com/usenetwork/show-4866-1.aspx