端到端反应式流 RESTful 服务(又名 Back-Pressure over HTTP) [英] End-to-End Reactive Streaming RESTful service (a.k.a. Back-Pressure over HTTP)

查看:23
本文介绍了端到端反应式流 RESTful 服务(又名 Back-Pressure over HTTP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上尝试澄清这个问题有一段时间没有成功,所以我会尝试在这里提问.

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

我想找到一些资源或示例,其中展示了如何构建端到端的完全背压式 REST 服务 + 客户端.我的意思是,我希望看到,给定一个实现 Reactive Streams 的 REST 客户端(无论是在 Akka、JS 还是其他中),我将拥有(并且能够可视化")整个过程中处理的背压构建的 REST 服务器,例如使用 Akka-Http.

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.

明确地说,我正在寻找类似于以下谈话的内容(但我找不到幻灯片或视频来确认):http://oredev.org/2014/sessions/reactive-streaming-restful-applications-with-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

我对我看到的大多数示例的疑虑是,我可以找到很多 REST 服务(服务器)在后端使用 Akka Http 和 Akka 流的情况,但我不确定背压是通信的"" 通过 HTTP 和 REST,如果客户端正在实现响应式流.在这种情况下,我会通过 TCP/HTTP 桥接单个流"还是只有 2 个独立的流?这是我的主要疑问和困惑.

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.

希望我足够清楚,有人能够对此事有所了解.
无论如何,谢谢!

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

推荐答案

你来对地方问 Akka 问题了 :-)

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

我知道有两个演讲展示了使用 http 时背压机制的真正工作原理.

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

1) 一个是 Roland Kuhn 在 ScalaDays SF 2015 上的演讲:http 演示的背压从本次演讲的第 44 分钟开始.

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

2) 我在 ScalarConf Warsaw 2015 上的演讲.溪流部分在 18 分钟左右开始,并且在第 24 分钟左右可以看到反压演示.它显示了快速处理"和慢速处理"服务器,您可以在其中看到curl 客户端在上传文件时被背压(我以文件为例,因为它是一个很好的大请求").

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").

由于 TCP 内置机制,背压传播到客户端 - 在服务器端,我们根本不从套接字读取直到需求可用,这会导致背压正确传播.

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.

我希望这会有所帮助!

这篇关于端到端反应式流 RESTful 服务(又名 Back-Pressure over HTTP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆