Question about pushing messages to native apps

194 views
Skip to first unread message

Christoph Grossegger

unread,
Jan 13, 2012, 2:06:19 PM1/13/12
to google-a...@googlegroups.com

Hi everyone,

since this is my first post, i wanted to say "Hi!" to everyone reading these forums and thank you to everyone who is participating in the discussions.

Now to the reason i'm writing. I'm currently working on a mobile game for iOS and android (and maybe more …) which requires some server side action. Since i'm not that experienced in managing scaleable server architectures, i thought that GAE could help me out a lot. So i started reading into the documentation a few days ago, but now i'm uncertain about how to implement our application with GAE. 

I already read some discussions here and on other sites, but some of them seam to be "open-ended" while others are fairly old. So please forgive me if i ask something already answered.

Basically, my game creates hosted multiplayer games for up to 4 players (maybe more later on) per game (of course there are more games at the same time). Within each game, the players send messages to the server (or make http requests), the server checks the request and broadcasts the message to all players. 

The difficult part would be the last one, where the server pushes messages to the clients, because i need to be as fast as possible broadcasting those messages. For what i know, i have the following options (well, in theory):

a) each client polls every X seconds updates from the server, which seams to be fairly slow (?)

b) the channels api, which states that it is meant to be used in multiplayer games, but unfortunately lacks support of other client apis than the js api. I read about a python and java implementations but everyone warns about, if google changes the protocol, that those implementations would stop working. I'm also aware of the hidden webview method on iOS, but i don't think that this is an excellent way for cross platform applications.

By the way, is it true that the channels api uses long polling and the gtalk services on the server?

and c) xmpp

Since i would like to keep my application in one place, i would prefer not to host my own xmpp server (which would allow me anonymous jids, right?) and unfortunately the GAE api is "only" a xmpp client.

I'm still thinking about the down-sides of allowing the user to sign in with their own xmpp accounts (well in addition to that they have to subscribe too), but i really don't like the additional sign-in process. I'm also not sure if it's 100% secure to limit the messages to the game client (through the jid ressource) so that the user won't receive game messages in his other clients.

I thought about registering one gtalk account and use it within the game client (register each client with a unique ressource, or maybe with a ressource per game). So basically the GAE app would send messages to my_customapp [at] gmail [dot] com/<uniqueuserid>, but i'm not sure if this would be allowed by google. Maybe someone here has some information about that?


oh, and of course

d) another service (which probably means more work) and sockets :(


I know that this isn't an easy to answer question, and i'm sorry for that, and thank you to everyone who made it this far (:D). I hope that some of you can share their experiences and/or knowledge. Maybe i'm understanding something wrong or i'm just looking into the wrong direction. 

Thanks!

Christoph

Simon Knott

unread,
Jan 13, 2012, 5:49:25 PM1/13/12
to google-a...@googlegroups.com
Hi,

I know that a few people have mentioned using PubNub for broadcasting events to multiple users, although I've no idea what the latency is like for it.

Cheers,
Simon

dimi

unread,
Jan 14, 2012, 3:47:16 PM1/14/12
to google-a...@googlegroups.com
Hello Christoph,

Welcome to GAE (group)!

I'd like to share my PubNub experience:

I have been using PubNub for updating thousands of iPhones at the same time.
Once you have a (java) instance running which as already connected to pubnub in the past, it publishes fast.

I don't know the latency or speed... but in my experience while thousands of users where connected to the same channel this was the speed:
The admin submits a form on his computer, looks away from his screen and looks to his iPhone and the message arrives (PubNub uses GAE and Amazon for scaling).

Pubnub uses long polling in the browser, but sockets on iPhone (Apple will allow the app - they sometimes don't allow apps that use other http push-services than their own).

Two remarks: 
- when you're testing, you can use a demo-account (so you don't pay for used messages).
I have noticed that this demo account can crash your iPhone app (probably a build in security so you won't use this account in a production environment). Make sure the used channel when using the demo account is unique.. Other demo-users can crash your app during testing :)
- make sure you don't exceed the max-length of a message! It won't send (throws an error in your serverside code ! :))

Good luck with your project!

Dimitri

Tom Willis

unread,
Jan 15, 2012, 12:33:31 PM1/15/12
to google-a...@googlegroups.com
The latency is mind blowingly low in my experience. 

Christoph Grossegger

unread,
Jan 15, 2012, 4:45:48 PM1/15/12
to google-a...@googlegroups.com
thank you for mentioning and sharing your experiences with pubnub, althought it seams a bit expensive for my purpose (at least the pay as you go system, haven't calculated the prepaid options yet). It looks interesting for applications with somehow "moderate" update rates / pushes, since you get the whole package from client to server apis, but in my case here, it looks really expensive. 

If i understand the pricing model right, i would pay 5 credits per message on a broadcast to 4 players (currently the maximum player size per game), 1 to the system and 1 for each player. One credit costs "only" $0.0001 (which makes $0.0005 per broadcast), which doesn't look much, but throughout a game, there are a few of those. Let's say each player performs every 4 seconds an action that requires a broadcast, results in 1 broadcast per second per hosted game. That would cost a lot of money. Guess that an ec2 instance would cost way less and running the game logic directly their would also reduce the latency and the load of other instances. 

Brandon Wirtz

unread,
Jan 15, 2012, 6:05:48 PM1/15/12
to google-a...@googlegroups.com

EC2 is cheaper for a lot of things at the scale of things that can run on 10 instances. EC2 is a lot more expensive when you get to the point you need to hire a person to manage your EC2 instances. That $80k a year employee buys you a LOT of appengine services.

 

That is what you are paying for. Comparing EC2 and GAE isn’t really fair because EC2 is IaaS and GAE is PaaS.

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/jKU_t6a20QsJ.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Arthur Wiebe

unread,
Mar 18, 2013, 3:33:57 PM3/18/13
to google-a...@googlegroups.com
Hey Christoph, may I ask what you ended up doing?

I thought about registering one gtalk account and use it within the game client (register each client with a unique ressource, or maybe with a ressource per game). So basically the GAE app would send messages to my_customapp [at] gmail [dot] com/<uniqueuserid>, but i'm not sure if this would be allowed by google. Maybe someone here has some information about that?

I'm considering doing that as well. Unless there is a better way.

Vinny P

unread,
Mar 19, 2013, 5:06:10 PM3/19/13
to google-a...@googlegroups.com
Hi Arthur,

I'm not the original poster, but I deployed a simple communications app recently and I used a new company called Firebase. Firebase is still in beta, but it basically handles the entire communications backend for you, and all you need is some javascript on your side. Here's a quick tutorial on it: https://www.firebase.com/tutorial/#gettingstarted

(Not affiliated with them, just a happy customer.)

-Vinny P

Kristopher Giesing

unread,
Mar 19, 2013, 6:30:21 PM3/19/13
to google-a...@googlegroups.com
I ended up writing my own solution, which is essentially a replacement for the channel APIs.

The solution involves a node.js service that multiplexes to the clients.  I used websocket-node (https://github.com/Worlize/WebSocket-Node) on the node.js end, and SocketRocket (https://github.com/square/SocketRocket) on the iOS end. I had tried several other persistent-connection solutions for node, but none of them gave me the combination of flexibility and reliability that I needed.

I've been considering posting the code somewhere since it's pretty simple.  The advantage to it is that it's free (other than hosting costs, which run me $200/year, but I was already paying that).  The disadvantage is that, well, it's custom, so it's not as well tested as some other solutions might be.

- Kris

Arthur Wiebe

unread,
Mar 19, 2013, 11:25:21 PM3/19/13
to google-a...@googlegroups.com
Thanks for the inputs. I might just try firebase instead of trying to build my own solution. Either that or use XMPP which I have working right now using a resource for each client connection.

I did start down the NodeJS path as well just like Kris is doing except I used socket.io with NodeJS and was using python for the client. It worked, but my concern was scalability and what happens when the NodeJS server can't handle all the websockets. When you add more nodejs instances and load balance them, it makes things a lot more complicated.

So I prefer to try and make XMPP work because that's what the GAE channel API uses in the background anyway, but firebase does look tempting.
Reply all
Reply to author
Forward
0 new messages