N
N
Nikolay2014-08-26 15:39:54
PHP
Nikolay, 2014-08-26 15:39:54

How to implement multithreading in php?

Hello!
In general, I am mastering the API, and I ran into the problem of a long page load (about 40+ seconds)

A little more about the task
Делаю запрос на список пользователей, и затем в цикле (на каждого пользователя) ещё один запрос на другую страницу API

I read on the Internet that you can reduce the time by several times by creating a request in several threads, but I can not find anything where it would be simply explained.
Thanks :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
svd71, 2014-08-26
@svd71

implemented using regular ajax. The list of users is passed to the client. It requests each element individually via ajax. This makes it possible to visualize the processing process (projects or other) and also the client can interrupt the processing at any time and stay in the session.
Most CMS backups work on this principle, where the number of files, tables and their sizes is not known in advance.
If there is absolutely something secret, then the lists can be encrypted / decrypted.

V
Vit, 2014-08-26
@fornit1917

curl_multi.
You can use the Guzzle wrapper, or at least RollingCurl.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question