Spring Boot Microservices Tutorial - Part 5 - Spring Cloud Gateway MVC
Vložit
- čas přidán 16. 07. 2024
- In this Spring Boot 3 Microservices tutorial series, we will learn how to build microservices using Spring Boot and Spring Cloud.
This is part 5 of the series, in this part, we will cover:
- What is API Gateway
- Use Spring Cloud Gateway MVC as the API Gateway
Link to the written tutorial: programmingtechie.com/2024/04/14/spring-boot-microservices-tutorial-part-3/
Nice Tutorial. Thanks
Can you please make the cloud deployment of the project so that we can learn how to do the deployment in cloud or else please provide some resources where we can learn that.
Thanks for the the greate tuturial.
Are you not going to use the discovery service in this new version of the course?
Yes discovery server will be replaced by kubernetes
@@ProgrammingTechie thanks, always appreciate learning new stuff.
When can we expect next tutorial ?
How can you add a header and a value to the request to pass on the the next component :)?
How to load balance while using Spring Cloud Gateway MVC?
can i deploye this api gateway to the external tomacat server
Sai, Erstwhile Spring Cloud Gateway used to be run on Netty server right? Back then with gateway we use Spring Webflux as well which was capable of handling functional programming too. There was only one api gateway for web & reactive then, right? Why they created two now, can you explain the logic?
I believe the community wanted also a Spring MVC version instead of the one using the reactive stack using Spring Webflux.
You can use the reactive stack when you are dealing with Reactive Streams.
Other than that you can choose the MVC stack as with the introduction of Virtual Threads, you can get same level of performance even with Spring Cloud Gateway MVC.
Do you need gateway and loadbalancer in google cloud or make google cloud it automatic?
Yes GCP has Cloud Load Balancing that can act as a Load Balancer.
How do we use Eureka Server to discover the service
I decided not to use Discovery Server for this series as we will anyway use Kubernetes for service discovery
Is Spring Cloud Gateway popular vs Nginx or Kong ?
It depends on the usecase, I don't have the data to say which is popular.
If you want to use a 3rd party library you can use the tools like Kong or Nginx, if you want to have more control over the way things in the API Gateway layer then you can implement this using Spring Cloud Gateway
if there are multiple instances how will the request get routed
If you are saying about /api/inventory/getAllProducts, /api/inventory/updateProducts/{id} etc. I edited the router code like "/api/product/**" btw When I call /api/inventory/getAllProducts with get, It returns 201 so It worked.
@@Hakan-mg2qj I mean if product service has three or more instance running . Say two instances of inventory service and five instances of order service.
Here we are hard coding the url.
Once we deploy the service to Kubernetes, the load balancing is done automatically for us. This will be covered in the future videos.
If you are not deploying on Kubernetes, we can use the libraries like Spring Cloud Loadbalancer together with Spring Cloud Netflix Eureka Discovery Server.
I covered this part in my previous video tutorial series, you can refer to that video to get a better understanding of the concept - czcams.com/video/0TQliqoX6Kc/video.html
Nice Tutorial. Thanks