Nginx simple implementation of Web site load Balancing

Source: Internet
Author: User
Tags to domain

When the large-scale website is set up, it will consider that if the daily increase in user volume, a large number of concurrent access, will not give the site, the database to bring a crash disaster. Today we'll talk about how to solve these problems in reality in a set of the most easy to achieve solution.

Control concurrency, everyone will first consider the distributed, load-balancing and other commonly heard it terminology. How can the website achieve load balance, in addition to some of the world's load balancer, we have what software solutions, this time, Nginx, LVS and other nouns will appear in the mind. How do these load-balanced software work, how readers are. NET engineers, everyone will choose Nginx, because it supports Windows Server, at this time, a lot of netizens will criticize, said LVs better more excellent. In fact, we do not have to care too much, in fact, all the same, as long as you can control them OK, each has advantages and disadvantages. Nginx configuration is simple, the use of small and medium-sized projects more convenient, below we look at the Niginx under Windows configuration, LVS in the configuration of Linux next write.

Overview: Using Nginx to build a reverse server to achieve load balancing of Web server cluster

1, download nginx--windows version, (Nginx-1.6.2.zip) at the end of the blog can be downloaded, unzip

2. Use the Winsw-1.8-bin (Windows Service tools). EXE tool to publish Niginx to domain mode to control the operation of Niginx through the Windows service. At the end of the blog can be downloaded

(1) Configure the WINSW run XML file, such as: The WINSW tool is ported to the extracted Niginx file, the tool name is modified to "NginxServer.exe", create an XML configuration file "Nginxserver.xml" file, It is the same as the name of the tool, and of course you can not change the name. The XML file is as follows:

WINSW File Configuration

Configuration is simple mainly specify the location of the Nginx.exe \log location, etc., you can Google WINSW look at the specific configuration information.

(2) Click NginxServer.exe Installation Services, if you are Win8 above the system may not be installed, is because of compatibility issues, modulation compatible Win7 mode, run as an administrator,

When you view the Windows service, start the Nginxserver service,

At this point, the Ngixserver service started successfully.

3, modify the Nginx configuration, the agent point to the server cluster, to achieve site load balancing

Locate the conf/nginx.conf file under the extracted Nginx folder and open it for configuration:

nginx.conf Configuration

Don't be afraid, there are few places to change.

(1) worker_processes 4; #启动的线程数 the number of cores that are typically your proxy server

(2) IP address and port number of the Web site publishing for the server farm configured in the "HTTP" bracket

Upstream linuxidc.com{
Server x.x.x.x:8091; #服务器A
Server x.x.x.x:8092; #服务器B

}

(3) Configure the address of the proxy server, which is the server address, listening port, and default address of the Nginx installation

server {
Listen 8090; #监听端口
server_name localhost; #服务器Ip地址

#charset Koi8-r;

#access_log Logs/host.access.log Main;

Location/{
root HTML;
Index index.html index.htm Default.aspx; #默认网站首页地址
Proxy_pass http://linuxidc.com;
Proxy_redirect default;
}

Restart Nginx Windows service, finish, create a website, IP, port number, default home page to be consistent with the proxy server server configuration Oh, try it.

The code:

Http://pan.baidu.com/s/1pJukQ2R

Nginx simple implementation of Web site load Balancing

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.