iphone - Apple Push Notifications in Bulk -


i have app involves sending apple push notifications ~1m users periodically. setup doing has been built , tested small numbers of notifications. since there no way can test sending @ scale, interested in knowing whether there gotchas in sending bulk push notifications. have scripts written in python open single connection push server , send notifications on connection. apple recommends keeping open long possible. have seen connection terminates , need reestablish it.

all in all, disconcerting successful sends not acknowledged, erroneous ones flagged. programmer's standpoint instead of checking 1 thing "if (success)" need watch numerous things go wrong.

my question is: typical set of errors need watch out make sure messages don't silently disappear oblivion? connection closing easy one. there others?

i agree api frustrating, , if have sent response each notification have been easier implement.

that said, here's apple should (from technical note) :

push notification throughput , error checking

there no caps or batch size limits using apns. ios 6.1 press release stated apns has sent on 4 trillion push notifications since established. announced @ wwdc 2012 apns sending 7 billion notifications daily.

if you're seeing throughput lower 9,000 notifications per second, server might benefit improved error handling logic.

here's how check errors when using enhanced binary interface. keep writing until write fails. if stream ready writing again, resend notification , keep going. if stream isn't ready writing, see if stream available reading.

if is, read available stream. if 0 bytes back, connection closed because of error such invalid command byte or other parsing error. if 6 bytes back, that's error response can check response code , id of notification caused error. you'll need send every notification following 1 again.

once has been sent, 1 last check error response.

it can take while dropped connection make way apns server because of normal latency. it's possible send on 500 notifications before write fails because of connection being dropped. around 1,700 notifications writes can fail because pipe full, retry in case once stream ready writing again.

now, here's tradeoffs interesting. can check error response after every write, , you'll catch error right away. causes huge increase in time takes send batch of notifications.

device tokens should valid if you've captured them correctly , you're sending them correct environment. makes sense optimize assuming failures rare. you'll way better performance if wait write fail or batch complete before checking error response, counting time send dropped notifications again.

none of specific apns, applies socket-level programming.

if development tool of choice supports multiple threads or interprocess communication, have thread or process waiting error response time , let main sending thread or process know when should give , retry.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -