QQ交流群:110826636

signalR的集群与负载均衡

signalR是相当不错的websocket应用,最近要做集群和负载均衡

主要用到了redis进行集群,signalR的backplane集成redis。

细节,订阅redis之后注意database号

再使用nginx进行负载均衡。

细节,设置websocket(我是用websocket的传输)的配置参数,Upgrade 头的处理

http {
    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }

    upstream websocket {
        server 192.168.100.10:8010;
    }

    server {
        listen 8020;
        location / {
            proxy_pass http://websocket;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
        }
    }
}

参考文章如下:

https://docs.microsoft.com/en-us/aspnet/signalr/overview/performance/scaleout-with-redis
https://www.nginx.com/blog/websocket-nginx/
http://www.cnblogs.com/liqiao/p/4396194.html

posted @ 2017-04-26 09:00  FourOne  阅读(2654)  评论(0编辑  收藏