Question

I'm developing a multiplayer Android game with push notifications by using Google GCM. My web server has a REST API. Most of the requests sent to this API send a request to Google GCM server to send a notification to the opponent.

The thing is on average, a call to my API is ~140 ms long, and ~100 ms is due to the http request sent to Google server.

What can I do to speed up this? I was thinking (I have full control of my server, my stack is Bottle/gunicorn/nginx) of creating an independent process with a database that will try to send a queue of GCM requests, but maybe there's a much simpler way to do that directly in bottle or in pure python.

Was it helpful?

Solution 3

I've solved my problem thanks to this thread:

I'm using Celery to send my notifications through a task queue. I can't believe how simple it is!

Thanks anyway :)

OTHER TIPS

The problem is that your clients are waiting for your server to send the GCM push notifications. There is no logic to this behavior.

You need to change your server-side code to process your API requests, close the connection to your client, and only then send the push notifications.

The best thing you can do is making all networking asynchronous, if you don't do this yet.

The issue is that there will always be users with a slow internet connection and there isn't a generic approach to bring them fast internet :/. Other than that, ideas are to

  • send only few small packets or one huge in favor of many small packets (that's faster)
  • use UDP over TCP, UDP being connectionless and naturally faster
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top