Search code examples
scalaakkasprayspray-clientspray-can

How to enable HTTP Pipelining with Spray-Can


I read on the spray-can docs that it supports HTTP Pipelining. But there is no method or example specified anywhere on how to do it.


Solution

  • This is a config setting. See this or this doc for all available settings in Spay config.

    This setting turns it on:

    spray.can.host-connector.pipelining = off
    

    And this one has to be > 1 to effectively enable it:

    spray.can.server.pipelining-limit = 1
    

    By default pipelining is off.

    Relevant description of each setting:

    # 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.
    # Set to 'disabled' for completely disabling pipelining limits
    # (not recommended on public-facing servers due to risk of DoS attacks).
    # This value must be > 0 and <= 128.
    pipelining-limit = 1
    
    # If this setting is enabled, the `HttpHostConnector` pipelines requests
    # across connections, otherwise only one single request can be "open"
    # on a particular HTTP connection.
    pipelining = off