API Gateway in Microservices By Kunal Hire
Monolith Vs Microservices
API Gateway Pattern “Implement an API gateway that is the single entry point for all clients. The API gateway handles requests in one of two ways. Some requests are simply proxied/routed to the appropriate service. It handles other requests by fanning out to multiple services.” - microservices.io
API Gateway in Action
Key Features ● Request Routing ● API Composition ● Load Balancing ● Rate Limiting ● Authentication and authorization ● Caching ● Logging ● Metrics collection ● Circuit breakers
API Gateway by Example - Kong
Kong Architecture
Plugins ● Authentication ○ Basic Auth, Key Auth, OAuth, LDAP, JWT, OpenID Connect etc. ● Security ○ ACl, CORS, Dynamic SSL, IP Whitelisting, Bot detection etc. ● Traffic Control ○ Rate limiting, Proxy caching, Canary release etc. ● Serverless ○ AWS Lambda, Azure Functions etc. ● Analytics & Monitoring ○ Prometheus, Datadog etc ● Transformations ○ Request, response transformer etc. ● Logging
Kong - Admin API http://127.0.0.1:8001/
Demo
API Gateway - Pros and Cons
Thank You

Api gateway in microservices

  • 1.
    API Gateway inMicroservices By Kunal Hire
  • 2.
  • 3.
    API Gateway Pattern “Implementan API gateway that is the single entry point for all clients. The API gateway handles requests in one of two ways. Some requests are simply proxied/routed to the appropriate service. It handles other requests by fanning out to multiple services.” - microservices.io
  • 4.
  • 5.
    Key Features ● RequestRouting ● API Composition ● Load Balancing ● Rate Limiting ● Authentication and authorization ● Caching ● Logging ● Metrics collection ● Circuit breakers
  • 6.
    API Gateway byExample - Kong
  • 7.
  • 8.
    Plugins ● Authentication ○ BasicAuth, Key Auth, OAuth, LDAP, JWT, OpenID Connect etc. ● Security ○ ACl, CORS, Dynamic SSL, IP Whitelisting, Bot detection etc. ● Traffic Control ○ Rate limiting, Proxy caching, Canary release etc. ● Serverless ○ AWS Lambda, Azure Functions etc. ● Analytics & Monitoring ○ Prometheus, Datadog etc ● Transformations ○ Request, response transformer etc. ● Logging
  • 9.
    Kong - AdminAPI http://127.0.0.1:8001/
  • 10.
  • 11.
    API Gateway -Pros and Cons
  • 12.

Editor's Notes

  • #3 Pros and Cons- Monolith: Pros- Simple to implement Less integration test - easy to test Easy to ship Fast development Cons- Violates Open-Close principle Nightmare when it comes to managing the code Difficult to enhance Bigger artefacts Hard to replace individual components like DB, Logger etc. Microservices- Pros- Easy to manage One reason to change Dynamic scaling Single responsibility Cons- Multiple points of failure Hard to test - rich integration tests required Heterogeneity in infrastructure
  • #4 It is microservices design pattern. An API gateway is a service which is the entry point into the application from the outside world. It’s responsible for request routing, API composition, and other functions, such as authentication. There are a lot of issues when client is talking to multiple components to get the job done. These include multiple proxies at client side, different logic to handle different calls, client needs to know the implementation details of server. A much better approach is for a client to make a single request to what’s known as an API gateway. An API gateway is a service which is the single entry-point for API requests into an application. It’s similar to the Facade pattern from object-oriented design. Like a facade, an API gateway encapsulates the application’s internal architecture and provides an API to its clients. It might also have other responsibilities, such authentication, monitoring, and rate limiting. These are also termed as BFF - Backend For Frontend
  • #5 It acts as a “backend for the frontend”. The clients does not know which services they are talking to. They communicate with a single interface - API Gateway. The gateway resolves the client requests and distributes them to respective services.
  • #8 Kong is a cloud-native, fast, scalable, and distributed Microservice Abstraction Layer (also known as an API Gateway, API Middleware or in some cases Service Mesh). Made available as an open-source project in 2015, its core values are high performance and extensibility. Actively maintained, Kong is widely used in production at companies ranging from startups to Global 5000 as well as government organizations.
  • #9 Kong provides a rich set of plugins which makes it easier and compatible with other open source tools. It can convert the SOAP into REST by using transformations plugins
  • #10 Kong can be configured by executing the admin APIs. These are a set of REST APIs to create consumers, apis, plugins in Kong.
  • #12 Benefits of an API gateway: A major benefit of using an API gateway is that it encapsulates the internal structure of the application. Rather than having to invoke specific services, clients talk to the gateway. The API gateway provides each client with a client-specific API. This reduces the number of round trips between the client and application. It also simplifies the client code. Drawbacks of an API gateway: The API gateway pattern also has some drawbacks. It’s yet another highly available component that must be developed, deployed, and managed. This creates the risk that the API gateway becomes a development bottleneck. Developers must update the API gateway in order to expose their services’ API. It’s important that the process for updating the API gateway is as lightweight as possible. Otherwise, developers are forced to wait in line in order to update the gateway. Despite these drawbacks, for most real-world applications it makes sense to use an API gateway. If necessary, you can use the Backends for front ends patterns to enable the teams to develop and deploy their APIs independently.