端到端的反馈式RESTful服务(也就是HTTP上的反压力)

时间:2021-11-22 19:34:28

I have been trying to clarify this question online for a while without success, so I will try to ask it here.

我一直试图在网上澄清这个问题,但没有成功,所以我想在这里问一下。

I would like to find some resource or example where it shows how I can build an end-to-end fully back-pressured REST service + client. What I mean is that I would like to see that, given a REST client that implements Reactive Streams (whether in Akka, JS, or whatever), I will have (and be able to "visualise") the back-pressure handled throughout a REST server built, e.g. with Akka-Http.

我希望找到一些资源或例子,说明如何构建一个端到端完全支持的REST服务+客户端。我的意思是,我希望看到一个REST客户端实现了响应流(不管是在Akka, JS,还是其他),我将拥有(并且能够“可视化”)在构建的REST服务器上处理的反压力,例如Akka- http。

To be clear, I am searching for something like the following talk (but I could not find slides or videos to confirm it): http://oredev.org/2014/sessions/reactive-streaming-restful-applications-with-akka-http

显然,我正在寻找类似下面的对话(但我找不到幻灯片或视频来证实它):http://oredev.org/2014/sessions/reactivestreamrestful-applicationwith-akka -http。

My doubts with most examples I see are about the fact that I can find plenty cases where the REST service (server) is using Akka Http and Akka streams for the back end, but I am not sure that the backpressure is "communicated" over HTTP and REST, if the client is implementing Reactive Streams. In such situation, would I have a single "stream" bridged over TCP/HTTP or just 2 independent streams? That is my main doubt and confusion.

我怀疑大多数例子我看到的是事实,我可以找到很多情况下,REST服务(服务器)使用Akka Http和Akka流的后端,但我不确定,反压力是“沟通”通过Http和休息,如果客户机正在实施无功流。在这种情况下,我是否会有一个跨越TCP/HTTP或仅2条独立流的单一“流”?这是我的主要疑问和困惑。

Hopefully I was clear enough and someone will be able to shed some light on the matter.
In any case, thank you!

希望我已经足够清楚了,有人将会对这件事有所了解。无论如何,谢谢你!

1 个解决方案

#1


8  

You’ve arrived in the right place to ask Akka questions :-)

你已经到了合适的地方问Akka问题:-)

There are two talks I’m aware of which show a demo how the backpressure mechanism really works when working with http.

我知道有两个对话演示了在使用http时,backpressure机制是如何工作的。

1) One is Roland Kuhn’s talk on ScalaDays SF 2015: the backpressure over http demo starts around the 44th minute of this talk.

1)一个是罗兰·库恩关于ScalaDays 2015的演讲:http演示的反压力开始于这个演讲的第44分钟。

2) My talk from ScalarConf Warsaw 2015. the streams part begins around the 18 minute, and the backpressuring demo is seen around the 24th minute. It shows a “fast processing” and “slow processing” server, in which you can see the curl client being backpressured when the file is being uploaded (I use a file as an example because it’s a nice “big request”).

我的演讲来自于2015年的“ScalarConf华沙”。流部分在18分钟左右开始,在第24分钟的时候可以看到反压力演示。它显示了一个“快速处理”和“慢处理”服务器,在这个服务器中,当文件被上传时,您可以看到curl客户端受到了压力(我以一个文件为例,因为这是一个很好的“大请求”)。

The back pressure is propagated to the client thanks to TCPs built in mechanisms for this - on the server side we simply do not read from the socket until demand is available, which causes the back pressure to be propagated properly.

由于在服务器端建立了TCPs,所以反压力会传播到客户端,而服务器端则是在需求可用时才从套接字读取,这将导致反向压力被正确地传播。

I hope this helps!

我希望这可以帮助!

#1


8  

You’ve arrived in the right place to ask Akka questions :-)

你已经到了合适的地方问Akka问题:-)

There are two talks I’m aware of which show a demo how the backpressure mechanism really works when working with http.

我知道有两个对话演示了在使用http时,backpressure机制是如何工作的。

1) One is Roland Kuhn’s talk on ScalaDays SF 2015: the backpressure over http demo starts around the 44th minute of this talk.

1)一个是罗兰·库恩关于ScalaDays 2015的演讲:http演示的反压力开始于这个演讲的第44分钟。

2) My talk from ScalarConf Warsaw 2015. the streams part begins around the 18 minute, and the backpressuring demo is seen around the 24th minute. It shows a “fast processing” and “slow processing” server, in which you can see the curl client being backpressured when the file is being uploaded (I use a file as an example because it’s a nice “big request”).

我的演讲来自于2015年的“ScalarConf华沙”。流部分在18分钟左右开始,在第24分钟的时候可以看到反压力演示。它显示了一个“快速处理”和“慢处理”服务器,在这个服务器中,当文件被上传时,您可以看到curl客户端受到了压力(我以一个文件为例,因为这是一个很好的“大请求”)。

The back pressure is propagated to the client thanks to TCPs built in mechanisms for this - on the server side we simply do not read from the socket until demand is available, which causes the back pressure to be propagated properly.

由于在服务器端建立了TCPs,所以反压力会传播到客户端,而服务器端则是在需求可用时才从套接字读取,这将导致反向压力被正确地传播。

I hope this helps!

我希望这可以帮助!