标签:The webapp ruby running dep res 平衡 name inf
https://gorails.com/deploy/actioncable
https://github.com/rails/rails/tree/master/actioncable
Passenger的高度优化load balancer负载平衡: Ruby apps 可以处理1个并发连接(或者线程限制的数量)。
但是终端deal with SSE/Websockets可以处理更多的并发连接,因此需要改变:
使用: force max concurrent requests per process configuration option 。
例子:如何设置并发来取消对special_websocket_endpoint的限制
server { listen 80; server_name www.example.com; root /webapps/my_app/public; passenger_enabled on; # Use default concurrency for the app. But for the endpoint # /special_websocket_endpoint, force a different concurrency. location /special_websocket_endpoint { passenger_app_group_name foo_websocket; passenger_force_max_concurrent_requests_per_process 0; } }
??:/special_websocket_endpoint改成你的cable名字,一般用/cable
??:passenger_app_group_name后面是你的app_group_name
如果使用的是Rails ,看 Integrating Action Cable with Passenger + Nginx
There are two ways to setup Action Cable with Passenger + Nginx:
需要使用:
Passenger 5.0.24以上
Redis, PostgreSQL或其他inter-process adapter supported by Cable。
。。暂时等待。。
In any case, to vary the WebSocket URL between environments, add the following configuration to each environment: 3步骤
config.action_cable.url = "xxxxxx"
Then add the following line to your layout before your JavaScript tag:
<%= action_cable_meta_tag %>
And finally, create your consumer like so:
App.cable = ActionCable.createConsumer()
Action Cable将只接受那些指定源头specific origins的请求 。
在server端的config/environments/production.rb中设置:
config.action_cable.allowed_request_origins = [‘http://xxxxxx.com‘]
??也可以是"http://111.xxx.xx.xx"的ip。取消文件中的注释并修改即可。
然后改写:config.aciton_cable.url = ‘/cable‘
这是为用户连接设置server url。
步骤:具体见https://gorails.com/deploy/actioncable
标签:The webapp ruby running dep res 平衡 name inf
原文地址:https://www.cnblogs.com/chentianwei/p/9900012.html