1
votes

Is there a way to pool or reuse HTTP connections with PHP's curl client? I already found Persistent/keepalive HTTP with the PHP Curl library?, but it only allows connection reuse on the same handle, and there isn't a good way to persist handles between multiple fastcgi PHP calls, and that's probably a bad idea because the handle might never be closed.

The only solution I found was routing the requests through a proxy that does connection pooling.

1
Interesting question, can you clarify what you meant by multiple fastcgi PHP calls ?Mostafa Berg
Sure; and it changes what @lars-stegelitz was answering. What I really meant is that within a php script, is there a way to reuse HTTP connections across script invocations. In this case, it's a web page, so fastcgi (or mod-php) will make the PHP call.David Ehrmann
I see, if I understand you correctly, itsn't this something curl_multi_* methods can fix for you?Mostafa Berg
@MostafaBerg sadly, no, because there isn't a way to save (or release) handles or multi-handles between calls.David Ehrmann
@Kirzilla Nope; I did exactly that, use Apache/Nginx/whatever as a proxy.David Ehrmann

1 Answers

0
votes

That would depend on the Webserver and the fast-CGI configuration.

Should be possible with fast-CGI, but the webserver has to support it as well.

Read this SO article, which has a good explanation what multiplexing can do for you

fastcgi multiplexing?