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
- fetch the event that start in 5 minutes
- find all the users & details that need to be notified (assume is 200)
- 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
精彩评论