gcloud socketIO is not working on multi-instances

£可爱£侵袭症+ 提交于 2019-12-10 22:24:42

问题


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.

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

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?

Thanks.


回答1:


Google Cloud does not natively support load balanced web sockets. There are a few options you can use to work around the problem.

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:

  • It doesn't natively work over HTTPS
  • Once a week VM instances in Managed VMs are recycled, leading to dropped connections.

Another option is to use a 3rd party service like pubnub or pusher:

  • https://www.pubnub.com/developers/
  • https://pusher.com/

Best of luck!



来源:https://stackoverflow.com/questions/34926954/gcloud-socketio-is-not-working-on-multi-instances

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!