Okay so I wanna create an iPhone app that communicates with a WEB Service. BUT there are 2 points that aren’t clear to me.
-
When A user presses a button in the app, it informs the web service of the action and web service sends push notifications to the corresponding users. Since the no. of users to whom the notification has to be sent may be large, I was thinking of sending a response (OK/Error) to the iPhone app and then continue with sending the notifications. In other words, the PHP script should accept the request, respond to it and after responding, continue with sending notifications so that the iPhone app does not have to wait for the service.
-
The service will require to send push notifications to a lot of users. And I’m writing the web service in PHP. So is there a more effective alternate to PHP? Or is it the best way to implement the service?
Thanks.
I’m assuming the key issue is that you want to respond to the user immediately and then do other work such as sending out notifications asynchronously.
I would suggest using some kind of queue system such as Gearman (though there are plenty of alternatives such as Rabbit). You can get your interface to put a job into the Gearman Queue and then write a Gearman Worker to pick up notification tasks from the queue
You can do this kind of work in PHP, but if you do then you might want to use the Gearman Manager PHP library as PHP is not the best language for long running processes. Gearman Manager starts and stops scripts for you and makes it easier to write workers in PHP.
http://gearman.org/?id=gearman_php_extension
https://github.com/brianlmoon/GearmanManager