如何使用 Spray-Can 启用 HTTP 管道

How to enable HTTP Pipelining with Spray-Can

我在 spray-can 文档上读到它支持 HTTP 管道。但是在任何地方都没有具体说明如何做的方法或例子。

这是一个配置设置。有关 Spay 配置中所有可用设置的信息,请参阅 this or this 文档。

此设置将其打开:

spray.can.host-connector.pipelining = off

并且这个必须大于 1 才能有效启用它:

spray.can.server.pipelining-limit = 1

默认情况下流水线是关闭的。

各设置相关说明:

# 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