Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Micro Service with API Gateway

For my new project, I have to use Micro Services with Api Gateway. So I gathered detailed informations about Micro Service but the Api Gateway part is not clear.

My question is,

  1. Is anyone know about how the request routing part is done in Api Gateway?
  2. Is that can be done by simple if condition[pseudo code: if(keyword=="product") then route("product service")]?
  3. Or Is that any better way to do it?

I am using C#.Net to develop Api.
I got some info about Api Gateway from https://www.nginx.com/blog/building-microservices-using-an-api-gateway/

Api Gateway

like image 566
Palanikumar Avatar asked Oct 16 '15 07:10

Palanikumar


People also ask

Can API gateway used with microservices?

The API Gateway offers a reverse proxy to redirect or route requests (layer 7 routing, usually HTTP requests) to the endpoints of the internal microservices. The gateway provides a single endpoint or URL for the client apps and then internally maps the requests to a group of internal microservices.

Which API Gateway is best for microservices?

Kong Gateway is a highly scalable, open source API gateway optimized for microservices and distributed architectures. Kong built the gateway on top of top of the NGINX web server, and governs it using the Apache 2.0 license.

Which is a benefit of using a microservices API gateway?

An API gateway's primary benefit is that it standardizes and centralizes delivery of services through APIs or microservices. Beyond this, API gateways also help secure and organize an organization's API-based integrations in a number of ways.

Can microservices work without gateway server?

A short answer Yes, you can survive with Spring Cloud API Gateway and no Service Discovery. But it's really dependent on the size of your application and the amount of traffic it will be handling. You can start migration to microservices without Service discovery.


1 Answers

You pretty much asked three questions and they're all somewhat related so I'll try my best to address all three together.

For one, request routing in an API gateway is more than just a proxy and the implementation would not involve conditions to examine the request before shipping it off to a downstream service. API gateway would likely be the only entry point to your services in which authentication would also be taken care of on the layer to make ensure that a request has the permission to go to a downstream service. Authentication is likely to be another service itself. The high level implementation of the API gateway is likely to consolidate most if not all of the endpoints on all the downstream services.

Lets take a small example such as an e-commerce application that includes a service for listing products, searching products, and shopping carts. The API gateway would then also have these same endpoints and will delegate the request further to a service responsible for the request. The API in this example may have /products to list all products, /products?query=... to search products, and finally /carts/:id/products to list the products in a shopping cart. Hope this answers your question.

Aside from that, I know that you've mentioned that its for a new project and just wanted to give you 2 cents that this may not be the best architecture to use for your new project if your team is really small because there is a large operational overhead. Overhead that requires standardization, automating deployments, integration, etc. Its probably best to start off with a traditional MVC architecture and slowly evolve it to microservices when the project has taken off.

like image 151
Will C Avatar answered Oct 19 '22 15:10

Will C