Akka HTTP 背压连接
Akka HTTP back-pressured connections
The documentation 在 Http().bindAndHandle()
上说:
there is no backpressure being applied to the connections Source, i.e.
all connections are being accepted at maximum rate, which, depending
on the applications, might present a DoS risk!
同样适用于bindAndHandleAsync()
bindAndHandleSync()
.
The documentation also states 甚至更高级别的系统,如文件 IO 或 TCP,我想 HTTP 在 TCP 之上将通过反应流机制工作。
Http().bind()
是神奇的功能吗?这会施加背压吗?
如何使用 akka-streams 公开背压 HTTP 端点?
在 java 中看起来像这样
Flow<ByteString, ByteString, BoxedUnit> dataFlow = ...;
Http
.get(actorSystem)
.bind(host, port, materializer)
.to(foreach(con -> {
logger.info("Accepted connection from {}.", con.remoteAddress());
con.handleWith(dataFlow, materializer)
}))
.run(materializer);
dataFlow 是转换传入消息并将它们映射到响应事件的任何流。这样您将受益于所有反应流的好东西。
您也可以尝试使用 http 路由和简单的 Tcp。
The documentation 在 Http().bindAndHandle()
上说:
there is no backpressure being applied to the connections Source, i.e. all connections are being accepted at maximum rate, which, depending on the applications, might present a DoS risk!
同样适用于bindAndHandleAsync()
bindAndHandleSync()
.
The documentation also states 甚至更高级别的系统,如文件 IO 或 TCP,我想 HTTP 在 TCP 之上将通过反应流机制工作。
Http().bind()
是神奇的功能吗?这会施加背压吗?
如何使用 akka-streams 公开背压 HTTP 端点?
在 java 中看起来像这样
Flow<ByteString, ByteString, BoxedUnit> dataFlow = ...;
Http
.get(actorSystem)
.bind(host, port, materializer)
.to(foreach(con -> {
logger.info("Accepted connection from {}.", con.remoteAddress());
con.handleWith(dataFlow, materializer)
}))
.run(materializer);
dataFlow 是转换传入消息并将它们映射到响应事件的任何流。这样您将受益于所有反应流的好东西。
您也可以尝试使用 http 路由和简单的 Tcp。