Ask PHP pthread background processing problem!

Source: Internet
Author: User
I want to do this now, create a background thread after a particular request and keep running, and the thread will not block the current request.

In the implementation process, the discovery background thread will block the current request, causing the page to wait for no data, if the thread::d Etach, there will be an error as follows, the official document does not recommend the use of this method, do not know whether it is related to this error:
[Sun Sep 14 11:13:03.819745 2014] [Core:notice] [PID 14343] Ah00052:child PID 14847 Exit Signal Segmentation Fault (11)


Thank you!


Reply to discussion (solution)

No detach need to wait for the end of the child process to block the request

Detach is likely to conflict with existing extensions

It is recommended to use Message Queuing to implement this function

With what multi-threaded, directly in the background asynchronously run a script is finished, a code, and does not block the current process
The code is as follows:
EXEC ("PHP task.php >/dev/null &")

No detach need to wait for the end of the child process to block the request

Detach is likely to conflict with existing extensions

It is recommended to use Message Queuing to implement this function



The volume of communication data is relatively large, Message Queuing is not very appropriate, looked under the command pipeline to do more suitable.

With what multi-threaded, directly in the background asynchronously run a script is finished, a code, and does not block the current process
The code is as follows:
EXEC ("PHP task.php >/dev/null &")


This is also a way, but when the concurrency is large, I worry about the resources will be too much, the reason why I want to refer to the background to do this, because it takes a long time.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.