There was a problem with multithreading in php. It is necessary to separate the parsing / generation of something between several threads. Give a small example, if possible

They say that in php there is no multithreading, then for the example of the "crutch" I will be grateful

I didn’t find anything sensible in Google.

  • one
    If this is done from the web of the muzzle, then use the js Ajax bundle and JSON. By creating separate files for parsing / generating and running them separately. - Makarenko_I_V
  • @Makarenko_I_V is perhaps the worst that can be advised. The next question will be about time_limit, after it there will be a question about how to work with cookies in cli-mode. - etki
  • @Etki, my solution seems to me the easiest to implement. Can you explain to me why it is bad? - Makarenko_I_V
  • @Makarenko_I_V because the script dies in thirty seconds. Because requests are intended to give a response, not to handle heavy data. Because IPC is either not at all, or it is conducted through a browser. Because if the client disconnects, the server is free to do anything. Because it can not be performed regularly on a schedule. Because it is necessary to fasten some protection against external requests to this. - etki

2 answers 2

why again these crutches? already if you already have fork ()

  • Explain the drop. I understand that with the help of this function there is a complete copy of the process. But it will not look the same and, for example, will it parse the same thing? Or will the parsing / generation be split into different URLs? (I apologize for stupidity, I got confused) - Vlad
  • From a formal point of view, the author asks about multithreading, you are talking about new processes. Despite the fact that there are no other options, it would be worth explaining what the difference is and note that this is not multithreading. - etki
  • @Etki Yes, the shoal. The multithreading was interesting in its own way. I thought it was possible to stick the process to everything, okay. I'm going to create a new question :( - Vlad
  • @Etki can minus but forks are too much described on the net. Yes, this approach highlights the new processes that implements multithreading. today it is the best solution for multithreading in php - username
  • @username 1) I would be minus if I wanted 2) this is NOT multithreading, multithreading implies the existence of parallel execution in a single environment. - etki

strange that no one wrote about curl_multi
With curl_multi, you can parse several pages at the same time.
true curl_multi is only suitable for parsing.

You can still use workers