gpt4 book ai didi

microservices - falcor 在微服务架构中的作用是什么?

转载 作者:行者123 更新时间:2023-12-04 15:19:37 25 4
gpt4 key购买 nike

假设我们有以下由松散耦合的微服务组成的叫车应用程序:

https://www.nginx.com/blog/introduction-to-microservices/

该示例取自 https://www.nginx.com/blog/introduction-to-microservices/

每个服务都有自己的休息 api,所有服务都组合在一个 api 网关中。客户端不与单个服务对话,而是与网关对话。网关从多个服务请求信息并将它们组合成一个响应。对于客户端来说,它看起来像是在与单体应用程序对话。

我试图理解:我们可以在哪里将 falcor 合并到这个应用程序中?

一个模型无处不在 来自 http://netflix.github.io/falcor/

Falcor lets you represent all your remote data sources as a single domain model via a virtual JSON graph. You code the same way no matter where the data is, whether in memory on the client or over the network on the server.



在这个叫车应用程序中,每个微服务都已经代表了一个域模型。你能想到通过用 falcor 包装每个微服务可以带来什么好处吗?我不能。

但是我认为将 falcor 合并到 api 网关非常方便,因为我们可以将微服务创建的不同域模型抽象为一个或至少几个模型。

你有什么意见?

最佳答案

你是对的。这就是 Netflix 使用 Falcor 的方式以及 Falcor 路由器的设计目的。
来自 documentation :

The Router is appropriate as an abstraction over a service layer or REST API. Using a Router over these types of APIs provides just enough flexibility to avoid client round-trips without introducing heavy-weight abstractions. Service-oriented architectures are common in systems that are designed for scalability. These systems typically store data in different data sources and expose them through a variety of different services. For example, Netflix uses a Router in front of its Microservice architecture.

It is rarely ideal to use a Router to directly access a single SQL Database. Applications that use a single SQL store often attempt to build one SQL Query for every server request. Routers work by splitting up requests for different sections of the JSON Graph into separate handlers and sending individual requests to services to retrieve the requested data. As a consequence, individual Router handlers rarely have sufficient context to produce a single optimized SQL query. We are currently exploring different options for supporting this type of data access pattern with Falcor in future.

关于microservices - falcor 在微服务架构中的作用是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39920488/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com