【问题标题】:Microservice api gateway/reverse proxy design Pattern微服务api网关/反向代理设计模式
【发布时间】:2020-06-04 12:27:32
【问题描述】:

我有一个应用程序,它的微服务很少,如下所示

 - python microservice   - runs as a Docker container on port 5001, 5002, 5003, 5004, 5005
 - nodejs microservice  - runs as a Docker container on runs on port 4000
 - mongodb  - runs as a Docker container on port 27017
 - graphql microservice - runs as a Docker container on port 4000

  1. 我需要澄清以下选项

选项 1:

 Is it correct to configure nginx as a reverse proxy for each application so that I want to run each microservice on port 80

 i.e * python microservice docker container + nginx
     * nodejs microservice docker container + nginx
     * mongodb microservice docker container + nginx
     * graphql microservice docker container + nginx  

选项 2:


 or should I configure a single nginx instance and setup upstream for python application, nodejs application and mongodb ?

 ie python + nodejs + mongodb + graphql + nginx   

注意:在 OPTION 2 中,只有一个 nginx 实例正在运行,而对于 OPTION 1,每个微服务都有一个 nginx 实例在运行。哪种模式是正确的 OPTION 1 或 OPTION 2 ?

  1. 将 mongodb 容器化并暴露在 80 端口上是否正确?

【问题讨论】:

    标签: microservices api-gateway


    【解决方案1】:

    问题 1: 如果你只使用一个 nginx,你就会遇到单点故障。这意味着如果 nginx 由于某种原因失败,所有服务都将关闭。

    如果您使用具有不同配置的多个不同的 nginx,则需要更多的维护、技术债务和资源。

    这里的一个好方法是拥有相同 nginx 服务器的副本(例如 2 个),其中包含用于路由所有微服务的规则。

    问题 2: 只要你有一些持久存储,在容器中部署 mongoDB 就没有问题。端口根本不是问题。

    【讨论】:

      猜你喜欢
      • 2019-10-27
      • 2018-01-25
      • 2023-03-11
      • 1970-01-01
      • 2017-11-23
      • 2016-06-15
      • 2020-05-05
      • 2019-05-21
      • 2021-06-20
      相关资源
      最近更新 更多