0

Let's say I have a PHP script which running a long process which required 10 minutes to complete.

If I execute the script via browser twice, both request will run concurrently or the second request will stay in server queue until the first request complete?

I know the pthreads extension which able to process request concurrently but my server not support that.

1
  • As far as your machine is able to cope with that (as contemporary computers are), they will run concurrently. Commented Oct 12, 2015 at 8:26

1 Answer 1

2

This depends on how you set-up apache / nginx / webserver, in a default set-up, they will run concurrently.

I would however not recommend that you expose a long-running php script available to the outside world. You are asking to be DDOSed and also, this is not a good user experience.

If you have a script which you know will take a long time, then have an api endpoint which places the job on a messaging queue like beanstalkd / RabbitMQ and returns a processing / deferred response. You then can have a separate queue worker / many queue workers which would watch the queue and process the jobs in real-time.

See http://kr.github.io/beanstalkd/ or https://www.rabbitmq.com/ or even http://redis.io/topics/pubsub

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.