jeril
jeril

Reputation: 1253

Microservice api gateway/reverse proxy design Pattern

I have got an application which has few microservices like shown below

 - 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. I require clarification for the below options

OPTION 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  

OPTION 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   

Note: In OPTION 2 only a single nginx instance is running and for OPTION 1 each microservice has a nginx instance running. Which pattern is correct OPTION 1 or OPTION 2 ?

  1. Is it correct to containerize mongodb and expose it on port 80 ?

Upvotes: 0

Views: 599

Answers (1)

jackops
jackops

Reputation: 886

Question 1: If you use only one nginx you have a single point of failure. This means that if nginx fails for some reason, all the services will be down.

If you use several different nginx with different configurations it will require more maintenance, technical debt and resources.

A good approach here is to have replicas (e.g., 2) of the same nginx server which contains rules for routing all the microservices.

Question 2: There is no problem on deploying mongoDB in a container as soon as you have some persistent storage. The port is not a problem at all.

Upvotes: 1

Related Questions