如何从PHP中使用HTTP 1.1持久连接和流水线操作? [英] How can I make use of HTTP 1.1 persistent connections and pipelining from PHP?

查看:132
本文介绍了如何从PHP中使用HTTP 1.1持久连接和流水线操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个REST API(使用JSON作为数据编码)。 API调用都是HTTP POST,我需要能够处理相当大的量(每秒可能有1,000次或更多次调用)。

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).

服务器(我是m负责)将用Java实现,但客户端最有可能是PHP。由于请求率很高,我热衷于利用HTTP 1.1中的请求流水线,但我不确定是否可以通过PHP执行此操作(即,PHP是HTTP客户端,不是服务器)。

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).

任何人都可以从PHP提供有关如何做到这一点的任何建议吗?

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

推荐答案

您可以使用pecl_http的HttpRequestPool [1]类并调用未记录的

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

$ pool-> enablePipelining(true)

$pool->enablePipelining(true)

方法。

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

这篇关于如何从PHP中使用HTTP 1.1持久连接和流水线操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆