How can I make use of HTTP 1.1 persistent connecti

2020-03-04 08:50发布

问题:

I'm building a REST API (using JSON as a data encoding). API calls will all be HTTP POSTs, and I need to be able to deal with considerable volume (potentially 1,000 calls per second or more).

The server (which I'm responsible for) will be implemented in Java, but the client will most-likely be in PHP. Due to the high rate of requests, I'm keen on taking advantage of request pipelining in HTTP 1.1, but I'm unsure whether it is possible to do this from PHP (ie. where PHP is the HTTP client, not the server).

Can anyone provide any advice on how do to this from PHP?

回答1:

You could use pecl_http's HttpRequestPool [1] class and call the undocumented

$pool->enablePipelining(true)

method.

[1] http://php.net/manual/en/function.httprequestpool-construct.php



标签: php http