Here’s my scenario. During signup for my app – i trigger a few PHP method calls that are long running (e.g. get UserFriendLikes, etc using OpenGraph API).
I want the methods to run in the background without the user noticing it – and leave the method to complete at its own time.
Whats the best way to acheive it? Does just calling longRunningMethod() from the user signup page work – or is there anything else i need to do to ensure that it is not terminated when user navigates to another page, etc?
Tim S’ solution above will work but it will be hard to scale. An alternative would be to put the work request in a queue where it will be picked up by a worker program and worked on. In other words, the sign up page can just drop in the queue and then the user can be free to navigate to other pages.
Have a look at work queues like RabbitMQ Here’s a word from the documentation that describes it and looks like it will help solve your problem:
If you don’t want to setup Rabbit MQ on your own, you can try signing up for workers at Iron.io. I think it comes with a free account.