0

I'm planning on launching my first APNS server soon. It's based on PHP and working fine in the test phase. My problem is that im not sure if it can handle 10K or 20K users on a shared server. And to be frank, i cannot figure out how to calculate the exact maximum bandwidth of my server.

Since each payload is 255Bytes, Does it mean sending Notification to 10k users would require 10K*255Bytes bandwidth? Or it just sends a 255Byte packet to apple and apple APNS servers take it from there?

Also, since everytime the app launches we are supposed to get the users device info and token, does this mean a constant high traffic to my server everytime the users open the application?

Eran
  • 387,369
  • 54
  • 702
  • 768
devdev101
  • 241
  • 1
  • 5
  • 14
  • 1
    I don't think in this case bandwidth is what you need to worry about. Instead, computing resources (CPU, memory) are much likely your biggest worries if you're on a shared server. – ItalyPaleAle Aug 25 '14 at 16:34

1 Answers1

1
  1. 10K*255 is wrong. First of all, the payload limit is 256 bytes, not 255, and that's just the payload. To that you have to add 1 + 4 (message ID) + 4 (expiry) + 2 (token length) + 32 (device token) + 2 (payload length) bytes per notification (assuming you are using the enhanced binary format). This brings you up to 10K*301 bytes. However, that doesn't include any overheads introduced by the TCP protocol itself, so the actual number would be higher.

  2. Even if you send the same payload to all 10K users, you still have to send a copy of that payload along with the other fields for each device separately. That means the bandwidth would be around 10*301Bytes (not counting the TCP overhead).

  3. You don't want to access your server each time a user opens the application. You should ask Apple for a device token each time the app is launched (by registering to push notifications), but you should only send it to your server once, unless it changes. You can check if it changed by storing the device token on the device, and comparing the stored token to the token returns by Apple.

Eran
  • 387,369
  • 54
  • 702
  • 768
  • Regarding number 3: In the didregisterforpushnotification method of appDelegate, arnt we supposed to get the device,badge,sound,token,... status and send it to the server each time the app launches? or does this method get called only once when the user accept to recieve notifications? – devdev101 Aug 25 '14 at 13:17
  • @devdev101 You are supposed to call ` registerForRemoteNotificationTypes:` each time the app is launched. This triggers the callback `didRegisterForRemoteNotificationsWithDeviceToken:`, in which you should check if it's a different device token than the one you have stored locally on the device. If it's different (or you have nothing stored), you send it to your server. – Eran Aug 25 '14 at 13:20
  • Ok sounds convincing to me! Does it mean that i should save everything (badge number, sound, token, version,...) in a plist or NSUserDefault and everytime the app launched just check if the old values are different from the current values, if they are then send the values to the server? – devdev101 Aug 25 '14 at 13:31
  • @devdev101 I don't understand what badge number and sound you wish to store. You just have to store the device token in NSUserDefault. – Eran Aug 25 '14 at 13:33
  • My clients want to know all this crap. But i think its not bad to know the version of the application or the users time zone! Lots of paid APNs services like Parse.com do the same. – devdev101 Aug 25 '14 at 13:41
  • One more thing, with all the above, do you think that a shared php server can handle the traffic of sending notifications to 10 or 20K users? – devdev101 Aug 25 '14 at 13:42
  • @devdev101 I have no idea. I have no experience with PHP. – Eran Aug 25 '14 at 13:46