Feature #8681

Net::HTTP should set TCP_NODELAY for requests with body

Added by Eric Wong almost 2 years ago.

[ruby-core:56158]
Status:Open
Priority:Normal
Assignee:-

Description

Setting TCP_NODELAY to disable Nagle's algorithm speeds up successive writes which
we use when sending HTTP PUT/POST requests with body.

From https://en.wikipedia.org/wiki/Nagle%27s_algorithm

  The user-level solution is to avoid write-write-read sequences on
  sockets.  write-read-write-read is fine. write-write-write is
  fine. But write-write-read is a killer. So, if you can, buffer up
  your little writes to TCP and send them all at once. Using the
  standard UNIX I/O package and flushing write before each read
  usually works.

We currently hit the killer write-write-read case when sending requests
with body using Net::HTTP

net-http-persistent does this by default (for all connections), even.
I usually use net-http-persistent, but sometimes it's easier to use
Net::HTTP on a new (bare) system and I've been bitten by this :x

Associated revisions

Revision 42168
Added by Yui NARUSE almost 2 years ago

  • lib/net/http.rb (Net::HTTP#connect): disable Nagle's algorithm on HTTP connection. [Feature #8681]

Revision 42169
Added by Yui NARUSE almost 2 years ago

fix r42168; Add class name to constants

[Feature #8681]

Also available in: Atom PDF