diff --git a/akka-http-core/src/main/resources/reference.conf b/akka-http-core/src/main/resources/reference.conf index 7c0a147b21..35ae9ead17 100644 --- a/akka-http-core/src/main/resources/reference.conf +++ b/akka-http-core/src/main/resources/reference.conf @@ -29,6 +29,18 @@ akka.http { # deliver an unlimited backpressured stream of incoming connections. max-connections = 1024 + # The maximum number of requests that are accepted (and dispatched to + # the application) on one single connection before the first request + # has to be completed. + # Incoming requests that would cause the pipelining limit to be exceeded + # are not read from the connections socket so as to build up "back-pressure" + # to the client via TCP flow control. + # A setting of 1 disables HTTP pipelining, since only one request per + # connection can be "open" (i.e. being processed by the application) at any + # time. Set to higher values to enable HTTP pipelining. + # This value must be > 0 and <= 1024. + pipelining-limit = 16 + # Enables/disables the addition of a `Remote-Address` header # holding the clients (remote) IP address. remote-address-header = off diff --git a/akka-http-core/src/main/scala/akka/http/ServerSettings.scala b/akka-http-core/src/main/scala/akka/http/ServerSettings.scala index 7d73c46f68..fd2a887b4d 100644 --- a/akka-http-core/src/main/scala/akka/http/ServerSettings.scala +++ b/akka-http-core/src/main/scala/akka/http/ServerSettings.scala @@ -26,6 +26,7 @@ final case class ServerSettings( serverHeader: Option[Server], timeouts: ServerSettings.Timeouts, maxConnections: Int, + pipeliningLimit: Int, remoteAddressHeader: Boolean, rawRequestUriHeader: Boolean, transparentHeadRequests: Boolean, @@ -38,6 +39,7 @@ final case class ServerSettings( parserSettings: ParserSettings) { require(0 < maxConnections, "max-connections must be > 0") + require(0 < pipeliningLimit && pipeliningLimit <= 1024, "pipelining-limit must be > 0 and <= 1024") require(0 < responseHeaderSizeHint, "response-size-hint must be > 0") require(0 < backlog, "backlog must be > 0") } @@ -55,6 +57,7 @@ object ServerSettings extends SettingsCompanion[ServerSettings]("akka.http.serve c getPotentiallyInfiniteDuration "idle-timeout", c getFiniteDuration "bind-timeout"), c getInt "max-connections", + c getInt "pipelining-limit", c getBoolean "remote-address-header", c getBoolean "raw-request-uri-header", c getBoolean "transparent-head-requests", diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala index a1540e97e0..a7351479bf 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala @@ -127,7 +127,7 @@ private[http] object HttpServerBluePrint { csRequestPrepOut ~> requestPrep // One2OneBidi - val one2one = b.add(new One2OneBidi[HttpRequest, HttpResponse](16)) // TODO: replace hard-coded value by reintroducing `pipeline-limit` setting from spray + val one2one = b.add(new One2OneBidi[HttpRequest, HttpResponse](settings.pipeliningLimit)) requestPrep.outlet ~> one2one.in1 one2one.out2 ~> csHttpResponseIn