通过CRON job PHP处理1000个用户

I have written a CRON job in PHP which loops through the users table and fetches tweets of each user using Twitter API and then stores it in Database.

My concern is what if the number of users grow over a period of time will it be able to execute in the defined execution time which is currently set to max_execution_time of 300 or it would fail

It would be great if someone can tell me what is the best approach for tackling such scenarios

The code is pretty basic, it goes like this

  1. Establish connection to database using mysql_connect
  2. Query users table - using the select statement
  3. Loop through all the records
  4. For each record fetch tweets using Twitter API
  5. Store tweets in database

best option is to use batch query specifying multiple userids in one request.

try this from:user1 OR from:user2 OR from:user3 and use the twitter search api to retrieve the batch results

other search query params can be seen here

https://dev.twitter.com/docs/using-search

https://dev.twitter.com/docs/api/1.1/get/search/tweets