MicroServices – GateWay Pattern
Microservice- GateWay Pattern | Techijournal.com

MicroServices – GateWay Pattern

What After Creating MicroServices

Now in our previous post we discussed how to break your monolithic application into microservices but now question arise what after services how client will know about all services that we have created. One way is that our client application will make request to all services as per need and deal with the response to show the result to user. I.e we will be having all details of services like url, port to client side and on
basis of that client will make request to requires resources/service. But this architecture has disadvantage like if we changed the service location to some other server then again we have to do all changes related to that service in all location in client application which will be a tedious job to do.
Figure 1

How to Solve Above Problem

What if we have some Interface that will take request from client and transfer that request to required services. This interface will act as the mediator that will bind client request to services. This interface will be called as the Gateway
Suppose we have order management application with following services 
  • Order Service 
  • Customer Service 
  • Kitchen Service
Now when we do not have the gateway then that time client has to remember all the services url to make an request as shown in above figure 1. This is not case with the gateway when following gateway pattern client application need not to remember about the services it only have to remember gateway url to make any request rest gateway will take care of. Gate will find specific service and route the request to required services as shown in figure 3. If any of the services is shifted to other server or port then that change needed to be updated at gateway. 
Figure 2
Points to be noted about Gateway
  • GateWay is entry point to our services.
  • Gate will act as the router that will routes all request from client to there specific services.
  • GateWay Insulates clients from how application is decomposed into several services.
  • GateWay reduces the burden of client from remembering request url of each client. 

Disadvantage about Gateway

  • It increases the complexity of the application.
  • It increases the response time due to extra hop that gateway has to make

Now its lot of theory about microservices now lets dive into the in next post.

If you haven’t gone to my previous code then please feel free to go through it.
Please feel free to comment below about your view and any extra clarification you require.

Durgesh Kumar

He is the Founder of TechiJournal.com. And have 4+ years of experience as full-stack Java developer. He worked with many reputed product companies and would like to share his experience and knowledge through this blog. He works very hard to provide you with quality content. But as no one is perfect, If you feel that some improvement can be made then feel free to add it in the comment section. We look forward to it.

Leave a Reply