Push notifications help/best practices and infrastructure?

Discussion in 'iOS Programming' started by Uplift, Nov 27, 2017.

  1. Uplift macrumors 6502

    Joined:
    Feb 1, 2011
    Location:
    UK
    #1
    We have recently had an iOS app built using the IONIC framework. We're having an issue with push notifications whereby, when we send out push notifications, our server load increases to such high levels that it locks up and on some occasions has even brought it to its knees. We have a good server that has no issues handling several thousand concurrent connections.


    I'm wondering if we're doing something wrong, or more likely just a case that our infrastructure is not right?


    - Within the app, users can subscribe to receive different notifications. A subscription is essentially a Device Endpoint in AWS SNS subscribed to a Topic in SNS.

    - Every evening, usually around 8 pm, we schedule a push notification from our backend system which is pushed out via a cron job.

    - Our biggest 'topic' is around 5000 devices, I'm assuming sending the notification to the Topic in SNS delivers the push notification to each of those devices.


    - The data contains the message and a payload which is a subscription ID (essentially opens the app on the correct page related to that notification) - a single integer.


    - When the app opens via the notification it will open the app on the relevant page and hit an endpoint to download data from our server, we believe this is the stage where our server load increases.. assuming 5000 devices are hitting our endpoint, DDOSing ourselves. To get around this we disabled functionality that downloads in the background, and will now only hit the endpoint when the app is opened by the user. We also tried to pre-cache the endpoint so that by the time the notification was sent, the data would already be cached and then not hit our server... However, this doesn't seem to have worked much at all... We'll also be hitting device auth endpoints.


    The 'backend' is a simple PHP API with data stored in MySQL.


    I know I haven't given much away from a technical point of view, but does it look like we're taking the wrong approach? Do we need to look at our infrastructure?


    tl;dr:

    - App sends push notification
    - Server is brought to its knees
    - Goes out to around 5000 devices, and hits an Apache 2.4 web server, API coded in PHP and data stored in MySQL
    - Data is pre-cached and I believe we have disabled app background refreshing, meaning the app should only attempt to download when the app is opened.



    Any advice appreciated
     
  2. MacMan988 macrumors 6502a

    Joined:
    Jul 7, 2012
    #2
    I also once faced a similar issue where we send a scheduled push notification causing a lot of users to open the app at the same time and the server load was increasing heavily. But then we made some changes to notification delivery so that the notification is sent based on each user's local time (i.e all receives the notification at 3 pm in local time) which improved the effectiveness as well as reduced the server load.
     

Share This Page