Web server cluster using software Load balancer

Source: Internet
Author: User
Tags server website dedicated server

I used nginx to implement the website load balancing test. In windows, IIS performs load measurement.

 

 

If your website traffic (pv) is getting higher and higher, and one server is no longer able to withstand the traffic pressure, increase the number of WEB servers for load.

Website load can be achieved by buying hardware devices. Our company uses F5, but the price ranges from hundreds of thousands to millions, which is too expensive,

At present, many portal websites and high-traffic websites are using nginx as the HTTP server, so nginx is very good. I will perform this load test myself.

Software/hardware environment:

 

(2 servers)
First:
CPU: Inter (R) Core i5 CPU 2.26 GHz

Memory: 2 GB
System: windows 7
IIS: IIS 7
Nginx: nginx/Windows-0.8.22
IP: 10.60.44.126
Environment: Local
Second:
CPU: Inter (R) Core i3 CPU 2.13 GHz

Memory: 2 GB
Windows Server 2003
IIS: IIS 6
IP: 10.60.44.127
Environment: Remote

 

Note:
In this test, the software nginx is placed locally (10.60.44.126), 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.

 

Practice steps:

First:

On the local server (10.60.44.126), create a website using the port 808, for example:

IIS website binding settings

Second:

Create a website in the Remote IIS 10.60.44.127 using the port 808, for example:

 

Remote IIS binding settings

Note: The first and second steps bind the same website program!

Third:

Now that we have configured IIS for the two servers, configure the nginx software to implement the website Load balancer. Open the following file:

C: \ nginx \ conf \ nginx. conf

1. Find Content server {

Add the following content to it:

Upstream chenlu.com {
Server 10.60.44.126: 808;
Server 10.60.44.127: 808;
}

(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://chenlu.com /;
Proxy_redirect default;
}

3. Find server {
Listen 80;
Server_name localhost;

Change the content to the following:

Server {
Listen 80;
Server_name 10.60.44.126;

(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:

 

 

Server Load balancer Configuration

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 (10.60.44.126), open IE and enter: http: // 10.60.44.126/

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 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 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.

Note:

1. Find \ WINDOWS \ system32 \ drivers \ etc on the local machine, modify the hosts file, and add 10.60.44.126 www.chenlulouis123456.com to comment out # host

2. Find the remote host \ WINDOWS \ system32 \ drivers \ etc and modify the hosts file 10.60.44.127 www.chenlulouis123456.com.

3.

 

Upstream chenlu.com
{
Server 10.60.44.126: 808;
Server 10.60.44.127: 808;
}
Server {
Listen 80;
Server_name http://www.chenlu123456.com /;

# Charset koi8-r;

# Access_log logs/host. access. log main;

Location /{
Proxy_pass http://chenlu.com /;
Proxy_redirect default;
}

After the above steps, local and remote machines can access the experiment through the domain name to avoid binding the actual domain name.

 

 

Hope you like it!

 

 

 

 

 

 

 

 

Related Article

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.