Load balancing between nginx and IIS

Source: Internet
Author: User
Tags server website
: This article mainly introduces the load balancing of nginx and IIS. For more information about PHP tutorials, see. 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:

Second:

Create a website in the remote IIS 172.10.1.236 using port 80, for example:

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:

Fourth:

All configured. start the nginx software below.

Enter the command prompt CMD, enter c: \ nginx>, and enter the nginx command, such:

At this time, there are two nginx.exe processes in the system process, such:

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:

Refresh the page and the result diagram is as follows:

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 website programs (the programs on several servers are the same), so that 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 also 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.


The above describes the load balancing of nginx and IIS, including some content, and hope to be helpful to friends who are interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.