The first part of the Web layer balanced load
Under the. NET platform, there are two ways (IIS7 and nginx) for the balanced load that I have deployed, and the following is an example of nginx to explain the balanced load of the web layer.
Introduction: Nginx beyond the high performance and stability of Apache, so that the domestic use of Nginx as a Web server website is also more and more, including Sina Blog, Sina Podcast, NetEase news portal channel, six rooms, 56.com, video sharing site, discuz! official forum, Water and wood community and other well-known forums, watercress, Yupoo album, domestic SNS, Thunderbolt online and other emerging Web 2.0 sites.
It is said that Nginx can withstand the number of 30,000 concurrent connections, which is not tested, in short, Nginx is famous for high concurrency.
Nginx to do the front-end of the balanced load is also a good choice, and specific language independent, the following is the way Nginx distributed to IIS
Simple process: User visits Web site (server C) Server C (does not require IIS) Nginx distribution requests to->a or B or more servers (specific IIS servers) for front-end load
The configuration is very simple, as follows:
1. Download the nginx version of Windows, search on the internet on the line. Download and unzip it on the C server (192.168.0.3) C: or D: directory, for example (C:/nginx)
2. Copy the ASP. NET site to a server (192.168.0.1), b Server (192.168.0.2), and set up the appropriate IIS, the port is self-defined, for example (81)
Make sure that the a server and B server Pages are exactly the same, and that Web. config needs to be configured machinekey consistent, otherwise it will be reported as abnormal.
<system.web>
<machinekey validation= "3DES"
validationkey= "319b474b1d2b7a87c996b280450bb36506a95aedf9b51211"
decryptionkey= "280450bb36319b474c996b506a95aedf9b51211b1d2b7a87"
decryption= "3DES"/>
3. Configuring the C server (front-end load forwarding server) nginx configuration file nginx.conf
The following red is required to configure. where Ip_hash is important (you can ensure that each visitor can fix a backend to ensure that the session is not problematic)
#user nobody;
Worker_processes 1;
#error_log Logs/error.log;
#error_log Logs/error.log Notice;
#error_log Logs/error.log Info;
#pid Logs/nginx.pid;
Events {
Worker_connections 1024;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
#log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
# ' $status $body _bytes_sent ' $http _referer '
# ' "$http _user_agent" "$http _x_forwarded_for" ';
#access_log Logs/access.log Main;
Sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
Keepalive_timeout 65;
#gzip on;
Upstream mytest.oa.com
{
Ip_hash;
Server 192.168.0.1:81;
Server 192.168.0.2:81;
}
server {
Listen 80;
server_name mytest.oa.com;
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location/{
Proxy_pass http://mytest.oa.com;
Proxy_redirect default;
}
#error_page 404/404.html;
# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
# Proxy The PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~/.php$ {
# Proxy_pass http://127.0.0.1;
#}
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
&NB sp; #
#location ~/.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param script_filename / Scripts$fastcgi_script_name;
# include Fastcgi_params;
#}
# Deny access to. htaccess files, if Apache ' s document Root
# concurs with Nginx ' s one
#
#location ~//.ht {
# Deny All;
#}
}
# Another virtual host using mix of ip-, name-, and port-based configuration
#
#server {
# Listen 8000;
# Listen somename:8080;
# server_name somename alias Another.alias;
# location/{
# root HTML;
# index index.html index.htm;
# }
#}
# HTTPS Server
#
#server {
# Listen 443;
# server_name localhost;
# SSL on;
# ssl_certificate Cert.pem;
# Ssl_certificate_key Cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers all:! Adh:! Export56:rc4+rsa:+high:+medium:+low:+sslv2:+exp;
# ssl_prefer_server_ciphers on;
# location/{
# root HTML;
# index index.html index.htm;
# }
#}
}
5. After the configuration is complete, enter the Ngnix directory via the command line and run Ngnix.exe, which starts the Ngnix. (Make sure no other IIS or Apache occupies port 80)
6. Close the Ngnix command for: ngnix-s stop.
Large architecture. NET platform (web-level load balancer)