简体   繁体   English

微服务,服务注册,API网关和数据共享

[英]Microservice, service registry, API gateway and data sharing

I m actually reading tones of articles concerning microservices architecture, but, it seems that they are dealing the things the easiest way possible, without going deeper in explanations. 我实际上正在阅读有关微服务架构的文章,但似乎他们正在以最简单的方式处理事情,而不是更深入地解释。

To explain you my questions, I will show you my actual little architecture : 为了向您解释我的问题,我将向您展示我的实际小建筑:

在此输入图像描述

So, here's what I want to use. 所以,这就是我想要使用的。 Before making anything technically, I need more theoretical informations. 在技​​术上做任何事之前,我需要更多的理论信息。

Description of my domain 我的域名的描述

I have some mobile and browser based customers, able to connect themselves on an application, getting their user informations and able to consult billing informations about what they bought. 我有一些基于移动和浏览器的客户,能够在应用程序上连接自己,获取用户信息并能够查询有关他们购买的产品的账单信息。

On a monolithic application, I would use this architecture : - Presentation layer with Mobile / Angular-Ember - Business layer with a REST API with NGINX in front of that - DAL with a standard MySQL database - Scalability would be applied only on X-axis 在单片应用程序中,我将使用这种架构: - 具有Mobile / Angular-Ember的表示层 - 带有NGINX的REST API的业务层 - 带有标准MySQL数据库的DAL - 可扩展性仅适用于X轴

I want to use a microservice architecture in this case, because it's "domain scalable" and really flexible (and to learn a bit more about it of course). 在这种情况下,我想使用微服务架构,因为它是“域可扩展的”并且非常灵活(当然要学习更多关于它的内容)。

On the schema, in each service, there is the only HTTP URL exposed by the API concerned. 在架构上,在每个服务中,都有相关API公开的唯一HTTP URL。

Questions 问题

a/ In the (1) flux, "mobile" send an http request on http://myDomain.or/auth . a /在(1)flux中,“mobile”在http://myDomain.or/auth上发送http请求。

In my mind, the APIGateway is able to ask a standard Service Registry (Eureka, ZooKeeper, or something else) is able to find if a AuthSrv is accessible and can retrieve his network address. 在我看来,APIGateway能够要求标准的服务注册表(Eureka,ZooKeeper或其他东西)能够找到AuthSrv是否可访问并且可以检索他的网络地址。 Then the ApiGateway can request the AuthSrv and respond to the server 然后ApiGateway可以请求AuthSrv并响应服务器

Is that a good way to make it work ? 这是一个让它运作的好方法吗? Isn't there a latency problem when dealing with X machines to access a data ? 处理X机器访问数据时是否存在延迟问题?

b/ The flux (2) consults the service registry. b / flux(2)咨询服务注册表。 How can the service registry understand that every requests on /auth, even on children url like /auth/other (if it was exposed) are related to this service on this address ip:port ? 服务注册表如何理解/ auth上的每个请求,甚至在/ auth / other之类的子URL上(如果它被暴露)与此地址ip:port上的此服务相关?

c/ The flux (3) is showing that the service registry has an available AuthSrv. c / flux(3)显示服务注册表具有可用的AuthSrv。 The (3 bis) show the other : no AuthSrv is available. (3之二)显示另一个:没有AuthSrv可用。 In a little application, we can admit that we lose sometime of disponibility, but in a big system, where hundred of services are linked, how can we handle service deficiency ? 在一个小应用程序中,我们可以承认我们失去了一段时间的可用性,但在一个大型系统中,有数百个服务链接在一起,我们如何处理服务缺陷?

d/ In an other post, I was asking how to store a billing information because it's related to a user, from another service, and another database. d /在另一篇文章中,我询问如何存储结算信息,因为它与用户,其他服务和另一个数据库相关。

In a standard architecture I would have : 在标准架构中,我会:

{
   billingInformations:{...},
   billingUser:ObjectId("userId")
}

In a microservice architecture, somebody recommended to use : 在微服务架构中,有人建议使用:

{
    billingInformations:{...},
    billingUser:"/user/12365" // URL corresponding the the user Resource in the other service
}

Is this the best way to handle "service data sharing" and not couple the services ? 这是处理“服务数据共享”而不是耦合服务的最佳方式吗?

e/ When should I prefer using AMQP protocol instead of HTTP protocol in this specific case ? e /在这种特定情况下,我应该何时更喜欢使用AMQP协议而不是HTTP协议?

Thanks for advance 谢谢你提前

a/ 一个/

No, Service Registries like Zookeeper are in-memory guaranteeing high throughput and low latency. 不,像Zookeeper这样的服务注册表在内存中保证了高吞吐量和低延迟。

b/ b /

In Service Registries like Zookeeper you can make filesystem path like registering of services. 在像Zookeeper这样的服务注册表中,您可以创建文件系统路径,例如注册服务。 For example /App1/Service1 and /App1/Service2 例如/ App1 / Service1和/ App1 / Service2

c/ C/

Not really clear what is the problem is. 不是很清楚问题是什么。

d/ d /

The pattern recommended by somebody is the HATEOAS pattern which is recommended for API response. 某人推荐的模式是HATEOAS模式,建议用于API响应。

e/ E /

AMQP is only required when communication required in between Services. 只有在服务之间需要通信时才需要AMQP。 Should never directly call the API of another service directly from one service. 永远不应该直接从一个服务直接调用另一个服务的API。

EDIT 编辑

c/ C/

In that case you need to implement fallback logic. 在这种情况下,您需要实现回退逻辑。 For example if a service is not available, times out or any other failure some actions need to be taken. 例如,如果服务不可用,超时或任何其他故障,则需要采取某些操作。 Tools like Netflix's Hystrix helps to achieve this. 像Netflix的Hystrix这样的工具有助于实现这一目标。

e/ E /

The communication pattern must be symmetric not asymmetric. 通信模式必须是对称的而不是非对称的。 Just like below, 就像下面一样, 在此输入图像描述

This pattern will enable loose coupling between microservices thus enabling flexibility. 该模式将实现微服务之间的松散耦合,从而实现灵活性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 API 网关能否动态查找注册在服务注册中心的微服务的 URI? - Can an API Gateway find URIs of microservices registered on a Service Registry dynamically? 注册表发现服务与 api 网关相比有什么优势? - What is the advantage of registry discovery service versus api gateway? 行数据网关的注册表模式 - Registry pattern with Row Data Gateway 如何通过zuul或任意api网关调用安全的微服务端点 - How to call a secure microservice endpoint through zuul or any api gateway Swagger Gateway MicroService聚合 - Swagger Gateway MicroService Aggregation 在微服务架构中,在一个服务的内部客户端之间共享请求和响应契约的好方法是什么 - In a microservice architecture, what is the good way of sharing the request and response contracts among the internal clients of one service jhipster 网关不将请求路由到微服务 - jhipster gateway not routing requests to microservice 我需要了解如何将 API 网关与身份验证微服务和其他微服务连接起来 - I need to understand how to connect a API-Gateway with Authentication-Microservice and other Microservies 如何通过 Gateway/Api Gateway/Rest 将外部服务连接到队列? - How to connect a external service to a queue through Gateway / Api Gateway / Rest? 微服务:无需使用 Spring API Gateway 进行服务发现 - Microservices : Without Service Discovery With Spring API Gateway
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM