3

I use file_get_contents/curl to get access for one API at the another server from my php script. This API isn't fast and can take up to 10 seconds to respond.

When I try to open 2 pages on my web site at the same time, which uses this API, they loaded one by one, i.e. I need to wait 1st to be loaded before server will start to server request for 2nd page.

I use Apache2 and php under linux. How I can avoid such behaviour, I don't want to block other clients while one of them access this API. Need help!

Thanks.

let4be
  • 1,048
  • 11
  • 30

1 Answers1

0

Yes.

There is this PHP library: http://code.google.com/p/multirequest/ (it's a multithreaded CURL lib).

As another solution, you could write a script that does that in a language that supports threading, like Ruby or Python. Then, just call the script with PHP. Seems rather simple.

Satyam Saxena
  • 581
  • 2
  • 10