Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 689551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:20:38+00:00 2026-05-14T02:20:38+00:00

I have a PHP script that grabs data from an external service and saves

  • 0

I have a PHP script that grabs data from an external service and saves data to my database. I need this script to run once every minute for every user in the system (of which I expect to be thousands). My question is, what’s the most efficient way to run this per user, per minute? At first I thought I would have a function that grabs all the user Ids from my database, iterate over the ids and perform the task for each one, but I think that as the number of users grow, this will take longer, and no longer fall within 1 minute intervals. Perhaps I should queue the user Ids, and perform the task individually for each one? In which case, I’m actually unsure of how to proceed.

Thanks in advance for any advice.

Edit

To answer Oddthinking’s question:

I would like to start the processes for each user at the same time. When the process for each user completes, I want to wait 1 minute, then begin the process again. So I suppose each process for each user should be asynchronous – the process for user 1 shouldn’t care about the process for user 2.

To answer sims’ question:

I have no control over the external service, and the users of the external service are not the same as the users in my database. I’m afraid I don’t know any other scripting languages, so I need to use PHP to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:20:39+00:00Added an answer on May 14, 2026 at 2:20 am

    So, let me get this straight: You are querying an external service (what? SOAP? MYSQL?) every minute for every user in the database and storing the results in the same database. Is that correct?

    It seems like a design problem.

    If the users on the external service are the same as the users in your database, perhaps the two should be more closely configured. I don’t know if PHP is the way to go for syncing this data. If you give more detail, we could think about another solution. If you are in control of the external service, you may want to have that service dump it’s data or even write directly to the database. Some other syncing mechanism might be better.

    EDIT

    It seems that you are making an application that stores data for a user that can then be viewed chronologically. Otherwise you may as well just fetch the data when the user requests it.

    1. Fetch all the user IDs in go.

    2. Iterate over them one by one (assuming that the data being fetched is unique to each user) and (you’ll have to be creative here as PHP threads do not exist AFAIK) call a process for each request as you want them all to be executed at the same time and not delayed if one user does not return data.

    3. Said process should insert the data returned into the db as soon as it is returned.

    As for cron being right for the job: As long as you have a powerful enough server that can handle thousands of the above cron jobs running simultaneously, you should be fine.

    You could get creative with several PHP scripts. I’m not sure, but if every CLI call to PHP starts a new PHP process, then you could do it like that.

    foreach ($users as $user)
    {
        shell_exec("php fetchdata.php $user");
    }
    

    This is all very heavy and you should not expect to get it done snappy with PHP. Do some tests. Don’t take my word for it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php script that grabs links from another website. I am storing
I have a php script that inserts data from an Android app into a
I have a PHP script that connects to an API and grabs around 200
I have a javascript function that posts data to a validation script and grabs
I have a small PHP script that takes the values from a dropdown list
I have a Jquery UI autocomplete code that grabs data from an ajax request,
I have had lots of help with creating a PHP script that basically grabs
I have php script that creates a temporary watermark image for users that are
I have a php script that watches for the newest json file in a
I have a PHP script that very much like a commenting system, but requires

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.