Sending many HTTP requests serially (one at a time) can cause an unnecessary delay in a script's execution. Each request must complete before a subsequent request can be sent. By sending requests in parallel, a pool of HTTP requests can complete at the speed of the slowest request in the pool, significantly reducing the amount of time needed to execute multiple HTTP requests.
These methods could be refactored. Break the caller into chunks of ~4 and then use Guzzle to download ~4 images at at time. Guzzle provides a wrapper for the curl_multi functions in PHP.
Feature Use Case
Faster cloning and importing of books with lots of images.
Feature Scope
Feature Description
Pressbooks has a few
fetchAndSaveUniqueImage
methods using WordPressdownload_url
. Ie.Sending many HTTP requests serially (one at a time) can cause an unnecessary delay in a script's execution. Each request must complete before a subsequent request can be sent. By sending requests in parallel, a pool of HTTP requests can complete at the speed of the slowest request in the pool, significantly reducing the amount of time needed to execute multiple HTTP requests.
These methods could be refactored. Break the caller into chunks of ~4 and then use Guzzle to download ~4 images at at time. Guzzle provides a wrapper for the
curl_multi
functions in PHP.Feature Use Case
Faster cloning and importing of books with lots of images.
Other Notes