gcloud socketIO在多实例上不起作用
我正在通过带有托管vms的gcloud应用程序引擎使用socketIO + Nodejs. 我遇到一个问题,当我使用手动缩放时,gcloud可与套接字配合使用.
I am working with socketIO + Nodejs over gcloud app-engine with managed vms. I am facing a problem that when I use manual scaling, the gcloud working well with sockets.
但是当我使用动态缩放时,套接字根本不起作用,我认为这是不起作用的,因为有两个实例的端口转发问题! 这是我的app.yaml实例处理正常的结果.
But when I use dynamic scaling, sockets not working at all, I think it doesn't work because of the port forwarding problem with two instances! here's my app.yaml instances handling that works.
manual_scaling:
instances: 1
resources:
cpu: 0.1
memory_gb: 0.1
disk_size_gb: 10
当我移除它们时,套接字根本无法工作. 有什么建议或解决方法吗? 因为我要处理大量的套接字请求(每天200万个). 如果找不到解决方法.应该为一个实例处理所有这些请求的规范是什么,或者如何计算它们?
When I remove them, sockets not works at all. Is there's any recommendation or a work around. As I am going to serve a very large number of socket requests (2 million/day). If no work around found. What is the specs that I should use for one instance to handle all of these requests, or how can I calculate them?
谢谢.
Google Cloud本身不支持负载平衡的Web套接字.您可以使用一些选项来解决此问题.
Google Cloud does not natively support load balanced web sockets. There are a few options you can use to work around the problem.
一种选择是将WebSocket流量直接路由到VM实例,而不是通过云负载均衡器.您可以在此处查看执行此操作的示例:
One option is to route websocket traffic directly to the VM instance, instead of through the cloud load balancer. You can see an example of doing that here:
https://github.com/GoogleCloudPlatform/nodejs- docs-samples/tree/master/appengine/websockets
这将起作用,但是您应该了解不利之处:
This will work, but you should know about the downsides:
- 它本身无法在HTTPS上运行
- 每周一次管理型VM中的VM实例被回收,从而导致连接断开.
另一种选择是使用pubnub或pusher之类的第三方服务:
Another option is to use a 3rd party service like pubnub or pusher:
- https://www.pubnub.com/developers/
- https://pusher.com/
祝你好运!