Http PipeLining

*/-->

div.org-src-container {
font-size: 85%;
font-family: monospace;
}
pre.src {
background-color:#f8f4d7
}
p {font-size: 15px}
li {font-size: 15px}

1 Pipeline and Persistent Connection — From rfc2616

1.1 Pipeline

支持持久连接 (Persistent Connection) 的客户端可以选择 Pipeline,即同时发送多个请求而无需等待
Server 回应。而 Server 在接收到这些请求时候必须按照请求的顺序来回复。这里需要注意的是,
Pipeline 只能用在持久性链接上,如果 Client 在连接是否持久还未可知的时候就去 Pipeline ,
Client 自己需要做好重试的准备,且在重试的时候,必须等到确认连接的持久性之后再去重新 Pipeline。此外,如果在所有请求都返回之前 server 就关掉了连接, Client 也需要重新发送请求 (是否需要重所有请求??)

非幂等方法(如 POST等) 不应该被 Pipeline。

1.2 Persistent Connection

HTTP/1.1 默认使用持久性连接,如非特殊情况, Client 应该假设 Server 使用持久性连接,即便
server 返出错也应该如此。如果 server 不支持持久性连接,server应该在 Http Response 的 Header
中包括 token: "Close" ,而如果 Clinet 不想维护这种连接,Client 也可以用在 Request 的 Header
值声明 "Close" 。

2 Http Pipeline and libCurl

This contents is from the curl/lib/README.pipelining file.

2.1 Background

Since pipelining implies that one or more requests are sent to a server before
the previous response(s) have been received, we only support it for multi
interface use.

2.2 Considerations

When using the multi interface, you create one easy handle for each transfer.
Bascially any number of handles can be created, added and used with the multi
interface - simultaneously. It is an interface designed to allow many
simultaneous transfers while still using a single thread. Pipelining does not
change any of these details.

2.3 API

We've added a new option to curl_multi_setopt() called CURLMOPT_PIPELINING
that enables "attempted pipelining" and then all easy handles used on that
handle will attempt to use an existing pipeline.

Details:

  • A pipeline is only created if a previous connection exists to the same IP
    address that the new request is being made to use.
  • Pipelines are only supported for HTTP(S) as no other currently supported
    protocol has features resemembling this, but we still name this feature
    plain 'pipelining' to possibly one day support it for other protocols as
    well.
  • HTTP Pipelining is for GET and HEAD requests only.
  • When a pipeline is in use, we must take precautions so that when used easy
    handles (i.e those who still wait for a response) are removed from the multi
    handle, we must deal with the outstanding response nicely.
  • Explicitly asking for pipelining handle X and handle Y won't be supported.
    It isn't easy for an app to do this association. The lib should probably
    still resolve the second one properly to make sure that they actually can
    be considered for pipelining. Also, asking for explicit pipelining on handle
    X may be tricky when handle X get a closed connection.

Http PipeLining的更多相关文章

  1. 执行大量的Redis命令,担心效率问题?用Pipelining试试吧~

    参考的优秀文章 Request/Response protocols and RTT 来源 原来,系统中一个树结构的数据来源是Redis,由于数据增多.业务复杂,查询速度并不快.究其原因,是单次查询的 ...

  2. Redis教程02——管道(Pipelining)

    请求/响应协议和RTT Redis是一个使用客户端/服务器模型(也被称作请求/响应协议)的TCP服务器. 这说明通常来讲一个一个请求的实现有以下步骤: 客户端发送请求到服务器,并从socket中以堵塞 ...

  3. <Redis Advance><Pipelining><Memory Optimization><Expire><Transactions>

    Overview About Redis pipelining About Redis memory optimization About Redis expire About Redis trans ...

  4. Redis 请求应答模式和往返延时 Pipelining

    Redis是一个CS结构的TCP服务器,使用”请求-应答”的模式.,客户端发起一个请求是这样的步骤: 客户端发送一个请求给服务器,然后等待服务器的响应,一般客户端使用阻塞模式来等待服务器响应. 服务器 ...

  5. Redis Pipelining

    Redis是一种基于客户端-服务端模型以及请求/响应协议的TCP服务.这意味着通常情况下一个请求会遵循以下步骤: 客户端向服务端发送一个查询请求,并监听Socket返回,通常是以阻塞模式,等待服务端响 ...

  6. Redis(六)管道(Pipelining)

    管道技术并不是Redis特有的,管道技术在计算机科学中有很多地方的应用. 来自wiki的解释: In computing, a pipeline, also known as a data pipel ...

  7. Redis - pipelining(管道)

    客户端向服务器发送一个查询请求,并监听 socket 返回,等待服务器响应.通常是阻塞模式,在收到服务器响应之前是挂起的,不能继续发送请求. 可以使用管道来改善这种情况.在使用管道的情况下,客户端可以 ...

  8. 计算机体系结构——流水线技术(Pipelining)

    本文导读: 一.并行技术 .并行技术分类 .新技术的设计与实现 .指令周期 二.流水线技术 .什么是流水线 .指令重叠方式 .流水工作设计 .流水线的描述方法(时空图) .流水线特点 三.流水线的分类 ...

  9. netty5 HTTP协议栈浅析与实践

      一.说在前面的话 前段时间,工作上需要做一个针对视频质量的统计分析系统,各端(PC端.移动端和 WEB端)将视频质量数据放在一个 HTTP 请求中上报到服务器,服务器对数据进行解析.分拣后从不同的 ...

随机推荐

  1. C++模版详解(-)

    C++模版:       模版时C++支持多参数多态的工具,使用模版可以为用户为类或函数声明一般模式,使得类的数据成员,或者成员函数的参数,返回值取得任意类型. 模版是一种对类型进行参数化的工具: 通 ...

  2. group by实现原理及其作用

    mysql中group by实现方式有三种,松散索引,紧凑索引,临时文件(文件排序). 在网上看了相关的介绍,大部分介绍都比较晦涩难懂,这里说下我的理解. 在学习SQL优化时,我们都知道可以对grou ...

  3. Javascript 浮点计算问题分析与解决

    分析 JavaScript 只有一种数字类型 Number ,而且在Javascript中所有的数字都是以IEEE-754标准格式表示的. 浮点数的精度问题不是JavaScript特有的,因为有些小数 ...

  4. linux下yum错误:[Errno 14] problem making ssl connection Trying other mirror.

    今天是要yum命令安装EPEL仓库后 yum install epel-release 突然发现yum安装其他的软件出错. 错误:[Errno 14] problem making ssl conne ...

  5. matplotlib基础整理

    matplotlib主要从下面几个方面进行整理: 折线图绘制:https://douzujun.github.io/page/%E6%95%B0%E6%8D%AE%E6%8C%96%E6%8E%98% ...

  6. 20155315 2016-2017-2 《Java程序设计》第六周学习总结

    教材学习内容总结 第10章 输入与输出 1.串流设计的概念 从应用程序角度看,将数据从来源取出,可以使用输入串流,将数据写入目的地,可以使用输出串流:在Java中,输入串流代表对象为java.io.I ...

  7. 反卷积Deconvolution

    反卷积(转置卷积.空洞卷积(微步卷积))近几年用得较多,本篇博客主要是介绍一下反卷积,尤其是怎么计算反卷积(选择反卷积的相关参数) 图1 空洞卷积(微步卷积)的例子,其中下面的图是输入,上面的图是输出 ...

  8. 【leetcode 简单】 第八十二题 反转字符串

    编写一个函数,其作用是将输入的字符串反转过来. 示例 1: 输入: "hello" 输出: "olleh" 示例 2: 输入: "A man, a p ...

  9. 让arch阻止某个软件包的升级

    我更新了eclipse-java Mars版本的,感觉特别的卡,而且还有好多bug,不知道为什么,因此我去官网下载了luna版本的eclipse的安装包,不知道怎么下载的点击这里,然后安装luna版本 ...

  10. 转载-SVN常用命令

    SVN(Subversion)是一个自由.开源的项目源代码版本控制工具.目前,绝大多数开源软件和企业代码管理,都使用SVN作为代码版本管理软件. Subversion将文件存放在中心版本库里,这个版本 ...