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

  • Home
  • SEARCH
  • 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 6756783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:33:57+00:00 2026-05-26T13:33:57+00:00

I would like run a PHP script that runs every second to update a

  • 0

I would like run a PHP script that runs every second to update a MySQL table.

Suppose this script takes 0.99 seconds, will this prevent website visitors from accessing the website while the script is executed? Will they receive timeouts/internal server errors?
If so, is there a way around this using perhaps some sort of multi-threaded option?

To give more details, I’m trying to create a role playing game that has monsters in it.
These monsters are stored in a table called rpg_monsters. The monsters table has a ID, target, x and y field and need to look if they are in range of each other to attack possible hostiles.
If they are in range of each other, they need to update their target to that monster ID. Today I still have few monsters, but that number will increase in the future and thus increase execution time of the script.

I understand that in normal cases, you would require a dedicated server for this type of intense work. However, I would like to see how far I can push PHP/MySQL before becoming overloaded.

Thank you in advance!

  • 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-26T13:33:58+00:00Added an answer on May 26, 2026 at 1:33 pm

    Short answer: no.

    Every new call to a PHP script creates a new instance of PHP (usually a new process, in some cases it’s just run under a new thread, but this does not affect your question), and multiple instances run independently of each other.

    As a casing point, try running this script:

    <?php
    
      sleep(20);
    
    ?>
    

    …and sending a new request/starting another instance while it is running. You will see that the one does not affect the other in any way.

    To add a little more info about the threading element of the question: PHP itself cannot be multi-threaded. If you run it as an IIS module in a recent IIS (off the top of my head I can’t remember exactly when this starts) the PHP instance will be run under a new thread of the IIS process – but you cannot start a new thread from within PHP. In every other setup (AFAIK) every new PHP instance creates a new process.

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

Sidebar

Related Questions

I have some php script that I would like to run on EVERY row
I would like to run a PHP script from another PHP script so that
I would like to run a job through cron that will be executed every
I would like to write a cron job that has to run a PHP
I have a pretty complicated index.php now, and I would like to only run
I would like to run a (extensive) query that produces one line of XML.
I would like to run a timer for every 5 hours and delete the
I would like to run something like: select * from table where field in
I have a PHP script that I need to run as root from the
I have a script called notify_me.php which I run like so: script type=text/javascript> //Run

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.