Search code examples
websocketload-balancinggoogle-cloud-platformmanaged-vm

Load balancing websocket connections in the Google Cloud


I've got a problem I'm unable to fully solve using Google technology.

I need to serve >500 parallel websocket connections over SSL. The clients ideally connect to wss://wss.mydomain.com and get served by an instance.

Option 1: I currently use a custom runtime Managed VM to deploy a Dockerfile which runs the SSL enabled websocket server. Deploying a Managed VM instance results in one GCE instance. I use Google Cloud DNS to point wss.mydomain.com to this one IP address of the GCE instance.

Problem: I can't connect to wss.mydomain.com (not even my-mvm.appspot.com) because websocket connections (over SSL) don't get forwarded to a managed VM instance. Raised an issue, but didn't see any response that helps me. Also others reach this conclusion here and here.

So if Managed VMs are not the answer, where can I find it within the Google Cloud Architecture?

Option 2: Since managedVM seems a suger coating for GCE, perhaps I can keep the current setup that already provides my GCE instances and add load balancing myself?

Option 2a: HTTP(S) load balancing doesn't allow websocket traffic, so that one is out.

Option 2b: Network load balancing could work. I need to assign instances to a target pool for that to work. Can newly created managed VM instances automatically be assigned to a target pool so they're joining in the load balancing? If so, would this be a complete solution to the problem?

Option 3: I'd like to keep using my Dockerfile for the setup. So I'm looking at container engine. I've got no experience here at all.

Before I dabble into another minefield, which option is most likely to provide a solution to my problem? Perhaps there's another option I didn't think of.


Solution

  • Option 2b would also be out, since Managed VM traffic is still passing through the the appspot.com frontend which doesn't forward websocket traffic to the instances (as mentioned in the other issues linked).

    If you want to get it working right now I'd recommend starting by using GCE instances with autoscaling and network load balancing. If you want the same level of scalability you'd get with Managed VMs, then you would want to then start reading into Container Engine and deploy your app Dockerized.