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{ UseEpull; 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 programif($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 programif($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_size m; #缓冲区代理缓冲用户端的最大字节数 can be understood as existing to the local and then passed to the user Client_body_size k; #跟后端服务器连接的超时时间_ Initiate handshake wait response time-out proxy_connect_time #连接成功后 _ wait for back-end server Response time _ actually has entered the back end of the party waiting for processing proxy_read_timeout ; #后端回传时间_ The specified time incoming all data proxy_send_timeout ; #代理请求缓存区, save the user's header information for Nginx to handle the rules proxy_buffer_size 8K; proxy_buffers 4k; proxy_busy_buffers_size k; proxy_temp_file_write_size k;}}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above introduces the application of Nginx load Balancing in Sina podcast, including the content, and I hope to be helpful to the friends who are interested in PHP tutorial.