- Used for
- Authentication,
- Authorisation
- Security
- Limit the request.
- Fault tolerance
- Service aggregation
- To call a micro service, we need to aggregate response of many other Micro services.
- Gateway pattern provides a unified proxy interface to the client That delegates request to various micro services based on URI pattern.
- JVM based Router and server side load balancer
- We have multiple micro services and based on URL pattern request goes to corresponding micro service.
- This filter and routing logic is taken care by Zuul proxy Which is also an API gateway.
- Spring cloud has a nice integration with Embed ZUUL PROXY.
- We provide a unified proxy interface that will delegate the request or forward the request to various micro services based on URL pattern.
- To trace our request flow, there is a filter component. there are four types of filters
- PreFilter
- Prefilter is called before our request route to microservices.
- Before our request route to Micro services.
- RouteFilter
- Once request routes route filter is called.
- After request routes to micro services.
- PostFilter
- Once our micro service end point execution is done, Post filter is called.
- After response comes, Post filter is called.
- ErrorFilter
- If there is any error We trace that using error-filter.
- If we get error in response error filter is called.
- Based on URL pattern, the request needs to Forward to which micro service this filter and routing logic Is taken care by API Gateway.
- Zuul
- Zuul is JVM based router and server side load balancer.
- Zuul is decommissioned as of spring boot 3 And spring cloud Gateway is fully used and supported now.
- Zuul is an ad service that provides dynamic Routing, monitoring, resiliency, Security and more.
- Internal architecture of Zuul
- HTTP request hits Zuul servlet Which passes request to Zuul filter runner.
- The Zuul Filter runner Then possesses request through different pre routing Filters, routing filters.
- These filters are based on groovy.
- The Zuul filter runner Decides Which filter will execute and in what order.
- There are some predefined filters And there may be some custom filters.
- Then the request goes to request context for processing.
- The Post filters are applied then.
- If we want to pass anything from Gateway to service or runner, then we said that inside the request context, which passes with the request.
- Filter persistence is used To inject filters inside our API Gateway engine
- Filter poller Execute the filter in the defined order.
- Filter publisher comprises of filter persistence And filter poller.
- When the filter loader gets loaded, it is going to execute the filter runner.
- The filter polar uses filter directories, File filter manager And filter loader, To load the Concerned filter.
- Components of Zuul
- Filters
- Types
- PreFilter
- PostFilter
- RouteFilter
- ErrorFilter
- Execution order
- Decides the order in which custom filters should execute.
- Criteria
- Criteria which decides on which a particular filter should be picked.
- Action
- Action to be performed in a filter
- This is defined in run method
- API Gateway monitoring
- Management endpoints
- Routes
- /routes
- Give the details of end points of all the services we have considered
- Filters
- /filters
- Gives us all the filters that we have configured in our application.
No comments:
Post a Comment