Click here to Skip to main content
15,885,910 members
Please Sign up or sign in to vote.
1.57/5 (3 votes)
Hi All,

I am looking for a sample microservice application with at least two services.
I am confused about how the API gateway is managing the requests from services and how it is transferring the data to UI?

What I have tried:

I have created three services and a web application, but don't know how to create an API gateway.
Posted
Updated 4-Nov-18 0:12am
Comments
Richard MacCutchan 12-Oct-18 4:47am    
Try Google, or look at the documentation.
Nathan Minier 18-Oct-18 15:03pm    
Not specific enough.

An "API gateway" is a generic management term. Generally, in a microservice infrastructure, each service is its own "gateway". In faux-microservice architectures, I suppose you might use one central application to aggregate them, but that's generally not necessary.

When you say UI are you referring to a JS-driven browser-application (SPA/PWA, etc), or are you rolling a native app with microservice access?

1 solution

Hi
I think, API Gateway, I have to mention that the topic is related to service composition. So you first need to answer this question that what is your service composition strategy? Are you going to rely on orchestration or choreography?

Service choreography will not lead you to build an API Gateway because having API Gateway means creating a centralized service cooperation. In a simple word, service orchestration.
Some references recommend the use of API Gateway when the number of Microservices are not more than a few. Which I absolutely agree with it.
Read more here Microservices in .NET Core: With Examples in Nancy - Christian Horsdal, Christian Horsdal Gammelgaard - Google Books[^]

But if the number of services is more than a few services then you need a proper service cooperation, discovery, and deployment strategy. Like container-based solutions (For more information see Docker).

Thus, the moral of the story is that API Gateway will rout your requests to the responsive service. That means the service requester will ask the API Gateway to redirect the request to a responsive service (could exist several mirrors of a service with the same responsibilities in Microservice Architecture due to service load balancing) with respecting the target service interface and then receiving the response and delivering it to the service requester again, with the respected service interface.

What does mean this in practice?
1- Build your Microservices based solution by using your preferred technologies and frameworks (like Nancy and OWIN)
2- Define routes to expose HTTP (CURD) functionalities to the rest of system on your services
3- Create another service and call it API Gateway. Note that this service will provide different proxies to access different services (this is more less the same concept of service aggregation).
4- Transfer all requests to the API Gateway because only this service knows end-points that a service can be called and handover the request to the gateway and wait for the response.

I hope this answer will provide at least a good start to solve your problem.

Least but not last, you can read the below article:
Dive into Microservices Architecture - Part I[^]

Cheers,
-- AH
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900