1

I have implemented push notifications using service worker and from server I push the notification using the web-push-php library. When I have to send thousands of notifications, PHP timeout will occur. How to prevent this scenario?

Stanly
  • 663
  • 1
  • 9
  • 26
  • You probably need to use some sort of background worker. You can't send thousands of notifications from the same process of your frontend (web server): you need a separate process. See for example see [this related question](https://stackoverflow.com/questions/21313028/jobs-processing-in-background-from-web-application) or search "php sidekiq". Otherwise you can use a service that performs the sending for you: for example if you use Pushpad you can send bulk notifications to thousands of subscribers with just a single HTTP request. – collimarco Aug 23 '17 at 09:51

1 Answers1

0

In my WordPress Plugin for Web Push (unmaintained now) I used curl multi to speed up sending notifications.

Take a look at this class: https://github.com/mozilla/wp-web-push/blob/master/wp-web-push/web-push.php.

Arnelle Balane
  • 5,437
  • 1
  • 26
  • 32
Marco Castelluccio
  • 10,152
  • 2
  • 33
  • 48