码迷,mamicode.com
首页 > 其他好文 > 详细

Using load balance for thrift servers

时间:2014-11-25 10:34:40      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   sp   for   

Software load balance .
Nginx(http://nginx.org)

 

1.Install nginx
download source code from http://nginx.org/en/download.html

./auto/configure
make & make install

 

2.Install tcp module patch
developed by Yao Weibin http://yaoweibin.github.io/nginx_tcp_proxy_module/
download from GitHub http://github.com/yaoweibin/nginx_tcp_proxy_module/zipball/master

$ patch -p1 < /path/nginx_tcp_proxy_module/tcp.patch
$ ./configure --add-module=/path/nginx_tcp_proxy_module/tcp.patch
$ make & make install

 

3. config load balance

#check status at http://localhost:8080/status
http {
        server{
                listen 8080;
                location /status {
                        tcp_check_status;
                }
        }
}
#load balance to other server
tcp { 
        upstream cluster {
                # simple round-robin
                server 192.168.0.111:11213;
                server 192.168.0.110:11213;

                check interval=3000 rise=2 fall=5 timeout=1000;

                #check interval=3000 rise=2 fall=5 timeout=1000 type=ssl_hello;

                #check interval=3000 rise=2 fall=5 timeout=1000 type=http;
                #check_http_send "GET / HTTP/1.0\r\n\r\n";
                #check_http_expect_alive http_2xx http_3xx;
        }

        server {
                listen 11113;

                proxy_pass cluster;
        }
}
                

 

4. Start Nginx
#start

$sudo /usr/local/nginx/sbin/nginx

#reopen

$sudo /usr/local/nginx/sbin/nginx -s reopen

#quit

$sudo /usr/local/nginx/sbin/nginx -s quit

5. note

1. each connection can be relocated to different servers with round-robin or weight.
2. one connection will not be relocated unless released.
3. other options for the optimize of nginx see the website. This is the basic usage only.

 

Using load balance for thrift servers

标签:style   blog   http   io   ar   color   os   sp   for   

原文地址:http://www.cnblogs.com/douzsh/p/4120291.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!