I have an .Net windows service that sends GCM push notifications via https://android.googleapis.com/gcm/send.
The service periodically sends batches of approximately 10,000 messages at a rate of 10 / second. With each batch, 5 – 10 of the messages will cause a “502 Bad Gateway” response. The messages that generate the 502 always go through with a second try.
Is this normal? Could I be sending too many messages too quickly?
According to the GCM guide, all 5xx error codes should be treated as temporary errors, and requests that get these errors should be retried :
5xx Errors in the 500-599 range (such as 500 or 503) indicate that there was an internal error in the GCM server while trying to process the request, or that the server is temporarily unavailable (for example, because of timeouts). Sender must retry later, honoring any Retry-After header included in the response. Application servers must implement exponential back-off.
I don’t think 10 messages a second is too quick. As long as your code handles this error and retries, I don’t think there should be any problem.