Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>PHP does do multithreading, the documentation for pthreads can be found: <a href="http://php.net/pthreads">http://php.net/pthreads</a></p> <p>Many examples of usage: <a href="https://github.com/krakjoe/pthreads/tree/master/examples">https://github.com/krakjoe/pthreads/tree/master/examples</a></p> <p>It is not as simple as simple create a thread and allow it to execute in the background while you finish servicing the request, while you could do that by detaching from the main thread servicing the request, it's not a very good idea. </p> <p>You never really want to create any threads in direct response to a web request, since this can only scale so far. What you want to do instead is separate that part of the application which you require to run constantly and regardless of what the front end parts of the website are doing. This newly separated part of the application we'll refer to as the back end. The back end of the application should be a service that runs all the time, independently of apache, fpm, or nginx. It very well may use multi threading to maximize throughput of the back end services, you will still need some simple way for the front and back ends to communicate; unix domain sockets, tcp sockets etc. With a communication channel between the front and back ends of your application, the front end can pass data and instruct the back end to queue transactions in whatever form is appropriate while the front end never has to wait for a result. This is a much better design, that doesn't necessarily require any multi-threading, although no doubt it's a candidate.</p> <p>It is important to remember that throwing threads at something doesn't necessarily make anything better, the only thing you can say for sure is that it will be busier, performance is not a product of use by default, you have to think carefully about how you will use resources, how you will communicate between the component parts of your application, and how to use the minimum number of threads (or indeed, processes) for the maximum amount of throughput.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload