Philoozushi
Philoozushi

Reputation: 546

Realtime game on Google Cloud : Channel API or Compute Engine?

We need to develop a multi-player game with real-time performance. This needs to be working worldwide (servers in America, Europe, Asia), and supporting a huge traffic. Using Google Cloud services for the hosting.

We're thinking of references like Jam with Chrome, Chrome Maze or Cube Slam.

The game :

The hosting :

We will obviously host the website on AppEngine, automagically scaling, but are thinking about 2 solutions for the real-time servers :

  1. Using websocket servers with Compute Engine

    Like they did for Jam with Chrome, Maze, etc.
    Developing our own websocket servers (technology TBD), deploying on datacenters in Europe, US, Asia, handling scaling, syncing between them, computing latency issues on servers and clients, etc.
    But it's pretty technically challenging as we are very short on time, and missing an admin sys and network guy for now.

  2. Or using Channel API

    We understand that it's not a websocket platform, and real-time performances are lower.
    But it would be way more simple and secure for us and the time we have.
    So, we would also like to know more about that.

In any case, we think we could use some graphical tricks on front ends, to make it look like real-time, but it really depends if we have a 100~500ms or a 500ms~10s latency.

Some questions :

Thank you for any helping comment !

EDIT :

Upvotes: 16

Views: 6057

Answers (3)

Philoozushi
Philoozushi

Reputation: 546

Alfred's answer is the best in the frame of the question I asked. Thank you very much !

However, I forgot to mention a few important points and the scope changed a bit :

  • We have very little development time (about 1 week only)
  • This is for a campaign that will last 3 weeks only (we'll need to keep it online a few months afterward, but this is not like we need a long-lasting architecture)
  • We need to make it work on the broader browser audience as possible (WebRTC only runs on Chrome & Firefox for now)

According to these points, we eventually came up to a 3rd solution :
Using a real-time PAAS.

It's way easier and faster to develop, way cheaper as we don't need a solid backend developer and system/network admin, and we can concentrate more on the project than on the infrastructure and platform.

There are a couple of services that seems good out there, already hosting MMO RPG and the kind, worldwide, with low latency, and good scaling systems.
Here is a list of providers :
https://github.com/leggetter/realtime-web-technologies-guide/blob/master/guide.md

Upvotes: 2

Justin Grayston
Justin Grayston

Reputation: 472

It also depends on other things like scalability.

Ingress is built on app engine and a part from the occasional cache glitch it is pretty impressive.

Remember that the channel api is using talk.Google which is the service that hangouts is built on. Scalable and real time.

Personally if your traffic levels are going to be erratic and unpredictable, go app engine. If you think it can be controlled and predictable use compute engine or something else.

Upvotes: 2

Alfred Godoy
Alfred Godoy

Reputation: 1043

If you need a server for processing the data:

I would definitely go with websockets at Compute Engine!

The Channels API is much slower, and also quite unpredictable (latency differs from message to message)! Data has to go to the Channels server, which sends it to the App Engine instance, which has to do a request back to the Channels server, which will push the message to the client. There is too much going on there if you want to keep latency down!

Here is a Channels API stress test:
http://channelapistresstest.appspot.com/
Try clicking "send 5"-button a lot, and you will see latency numbers going up to several seconds.

The Channels API is also quite expensive under heavy load (it probably does not scale well, even if Google of course can solve that with more instances).

When keeping latency down, geolocation is quite important. With a websocket server at Compute Engine, you can send your european visitors to google's european datacenter and your american visitors to the US datacenter (using the geo location headers that AppEngine will provide). You have no such control with the Channels API (or app engine, which all your messages are relayed through). Maybe Google has edge servers for the Channels API (I don't know), but if your AppEngine instance is on the other side of the planet, that does not matter.

If you do NOT need a server for processing the data:

You should establish a peer-to-peer connection with WebRTC, sending stuff directly between the users' browsers. That is was Cube Slam does. (WebRTC requires some initial handshaking ("signaling") so the two peers can find each other, and Channels API would work fine for that handshaking, that's just a couple of messages to establish the peer-to-peer connection.)

WebRTC DataChannels API will give you a nice websocket-like interface like channel.onmessage = function(e) { yadayada()... }; and channel.send("yadayada"); to send your data between the peers.

Occasionally, WebRTC is not able to make a peer-to-peer connection. Then it will fall back to a TURN server, which relays traffic between the peers. Cube Slam is using TURN servers running on ComputeEngine (in both Europe and America to keep latency down), but that is just the fallback when true peer-to-peer is not possible.

Upvotes: 21

Related Questions