开发者

How to add large number of event notification reminder via Google Calendar API using PHP?

开发者 https://www.devze.com 2023-01-25 14:29 出处:网络
I\'ve to add one event notification inside of the calendar of my users they all have an account of my Google Apps.

I've to add one event notification inside of the calendar of my users they all have an account of my Google Apps. The number of my users are for now 200 but it will increase to 1500. How can I add via PHP from Google Calendar API all those notifications? The secondary objective is that all the users that has the mobile configuration will al开发者_JAVA技巧so receive the sms notification. My issue is that if I launch a script now to add 200 notifications to an event that starts in 5 minutes, it will take a lot of time, so some users do not receive in time the notification.

thanks in advance!

Alberto


In nutshell, spread the large set of requests into smaller set of request.
Most of the servers nowadays are multi core, it should capable to perform multitasking

Setup two scripts

Master scripts

  1. fetch the event that start in 5 minutes
  2. find all the users & details that need to be notified (assume is 200)
  3. for every 10 notifcations, spawn a shell_exec process that calling Notification script, and make sure push the calling into background (refer php execute a background process )

Notification script

  • receive the details of 10 users need to be notified (details input from master scripts)
  • process the notification

Benefits

So, instead of traditional fetch one user notify one user,
you need 200 x 1 = 200 seconds

Now, you just need

1 seconds for master + (10 x 1 seconds) = 12 seconds

Things to take note

Server & bandwidth resources is not unlimited,
there is an capped on how many processes your server can run concurrently,
this up to you to perform testing and fine-tune

0

精彩评论

暂无评论...
验证码 换一张
取 消