Follow mechanism with php: what strategy to use?

crazybrumi

New Member
I am trying to build a twitter-like follow mechanism. User takes an action. We make a list of all that users' followers, and then populate all of their streams with some information. Since this can take some time (if you have 10,000 followers that's 10,000 streams to insert information in, ie. 10,000 SQL calls perhaps), I want to make sure that this is done in the background, while the user that takes the action can go on with his life.So, the strategy I'm considering is this:
  • user takes action.
  • php script opens another php script that will do all the work and that might take a second or two.
  • meanwhile, the user that took the action can go on with their life, their script just goes on and it's fast.
Thoughts? I also played around with using a queue, something like SQS, but this approach sounds like it might also work? Plus it has the advantage (for me) that it's easier to test locally and easier to run on non ec2 hosts.And if this is a good approach, how would I open a php script from within a php script? Could it be as simple as (if the php script lives at a url) doing a get on a url where that script lives?
 
Back
Top