2008 Sina Podcast is composed of static server cluster and dynamic server cluster, static server cluster uses squid to do front-end cache, dynamic server is also called interface server, mainly used to achieve display playback, record playback logs and so on.
The interface server uses F5 big-IP hardware four/Seven load balancer switch, 4 nginx reverse proxy Server four layer load balancing, by the four Nginx server to determine the URL, group, the back end 3 groups of Web servers to load balance seven.
F5 big-IP Backend 3 sets of Web servers, configuration is not the same, the first set of memory-intensive, technology is mainly Php+mencache services, the 2nd is CPU-intensive services, the main consumption of CP resources, the third group is disk-intensive, logging and other operations, require large space.
The following code is the interface server Nginx load Balancing configuration;
/*** code is n years ago, Sina interface Server Nginx Load balancer configuration, provide by the URL group service, load Balancing service ***/usr www www;worker_processesTen; Error_log/data1/logs/nginx_error.log Crit;pid/tmp/nginx.pidworker_rlimt_nofile51200; events{ Use Epull; Worker_connections51200;} http{includeConf/mine.types; Default_type Application/octet-stream; CharSet gb2312; Server_name_hash_bucket_size -; Keeplaive_timeout the; Sendfile on; Tcp_mopush on; Tcp_nodelay on;#第一组接口机: Memcache related (hits)Upstream count.Interface. video.sian.com.cn{Server xx.xx.xx. the: the; Server xx.xx.xx.: the; Server xx.xx.xx.: the; }#第二组接口机: Provide data class programsUpstream data.Interface. video.sian.com.cn{Server xx.xx.xx.: the; Server xx.xx.xx.: the; Server xx.xx.xx.: the; }#第三组接口机: Logging programs, function-related, nested pagesUpstream log.Interface. video.sian.com.cn{Server xx.xx.xx. the: the; Server xx.xx.xx.: the; }}server{Listen the; server_name interface. video. Sian. com. cn; Location/{ Proxy_redirect off;#后端的web服务器可以直接通过X-forward-for Get the user real IPProxy_set_header x-forward- for $remote _adr;#按URL进行分组, Group One: Memcache related (hits) if($request _uri~"^\/app\/count\/") {Proxy_pass http://count.interface.video.sian.com.cn;}if($request _uri~"^\/app\/online\/") {Proxy_pass http://count.interface.video.sian.com.cn;}if($request _uri~"^\/interface\/user\/getlogingap.php") {Proxy_pass http://count.interface.video.sian.com.cn;}#按URL进行分组, second group: External Data Class program if($request _uri~"^\/crossdomain.xml") {Proxy_pass http://data.interface.video.sian.com.cn;}if($request _uri~"^\/interface\/client\/topvideoclient.php") {Proxy_pass http://data.interface.video.sian.com.cn;}if($request _uri~"^\/interface\/common\/") {Proxy_pass http://data.interface.video.sian.com.cn;}if($request _uri~"^\/interface\/randplay\/randplay.php") {Proxy_pass http://data.interface.video.sian.com.cn;}if($request _uri~"^\/interface\/topic\/suggtop.php") {Proxy_pass http://data.interface.video.sian.com.cn;}if($request _uri~"^\/interface\/uploadclient\/") {Proxy_pass http://data.interface.video.sian.com.cn;}if($request _uri~"^\/interface\/xml\/") {Proxy_pass http://data.interface.video.sian.com.cn;}if($request _uri~"^\/outinterface\/") {Proxy_pass http://data.interface.video.sian.com.cn;}#按URL进行分组, Group Three: Playing log class program if($request _uri~"^\/interface\/flash\/") {Proxy_pass http://log.interface.video.sian.com.cn;}if($request _uri~"^\/interface\/playrank\/playrank2008_10.php") {Proxy_pass http://log.interface.video.sian.com.cn;}#按URL进行分组, other groups: feature-related, nested pages, etc. unmatched URLsProxy_pass http://log.interface.video.sina.com.cn;}#定义日至格式Log_format Count' $remote _addr-$remote _user [$time _local] $request ' " $status" $body _bytes_sent "$http _referer" ' "$http _user_agent" "$http _x_forwarded_for" ';#打日志access_log/data1/logs/Interface.Log Count; #允许客户端请求的最大单文件字节数client_max_body_size10m#缓冲区代理缓冲用户端的最大字节数 can be understood as existing to the local and then passed to the userclient_body_size128k; #跟后端服务器连接的超时时间_Initiate handshake wait response time-outProxy_connect_time#连接成功后_Waiting for back-end server response time_has actually entered the back end of the party waiting to be processedProxy_read_timeout#后端回传时间_Incoming time to complete all dataProxy_send_timeout#代理请求缓存区, save the user's header information forNginxMake rules processingproxy_buffer_size8k;proxy_buffers4 32k;proxy_busy_buffers_size64k;proxy_temp_file_write_size64k;}}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
N years ago the application of Nginx load Balancing in Sina Podcast