Is there a way to run Spring Cloud Gateway as a websocket gateway in a cluster, and if one of the nodes goes down, the others take over without causing much disruption for the gateway's clients and the proxied server?
Related
Can someone explain how hosting works ? in my spring boot app there'ss embedded tomcat server. as I understand the spring app runs with tomcat, tomcat takes some port, 8080 for example, and listens to requests coming to that port (when deployed locally at least) localhost:8080. I can make requests from my front end app, which runs on localhost:3000 and tomcat will take the requests, find controllers mapped to the urls that front request is directed to "/user" or "/myposts" or whatever, that controller runs code, talks to db inserts data into response and tomcat sends it back to front end.
If I deploy my app to some hosting service, like Google cloud, does the spring app still run with tomcat ? in that case which port will tomcat run on, where would my front end send requests to ? to the subdomain that google cloud has set up for my project ? Where would i need to configure SSL/https ? Would my front end send secure requests to google subdomain over https endpoints and it would relay those requests to deployed spring app through http(unsecured, inside hosting server) ? Or how ?
One of the most straightforward way to do this is to spin up an instance, ssh into the that instance and run your spring boot app the same way you would run it on your machine. Everything works the same as it would on that cloud instance. Your spring boot app still runs within tomcat and it still listens to port 8080. The only difference is now the hostname is no longer localhost and it will be the DNS name of that instance. You can find the DNS name on the console.
You need to get a SSL certificate if you wanna enable https "natively" in your spring boot app. Alternatively, you can set up a load balancer or an API gateway in front of your cloud instance to do the SSL termination for you. In this case, your frontend will send request to the load balancer or API gateway instead of your spring boot app. They accept https requests and transform them to http request and send it to your spring boot app.
I want to create a server for IoT (ODB GPS trackers for cars) that will send its status to server in real time and show it to client via a web applications.
The devices will connect to server using TCP, and then there will be client/web connecting to server via Websocket.
Spring Webflux is used for the client side. But I do not find a tutorial of Spring Boot TCP Server. And I read that netty is good for that (found an example using netty). So, because webflux is using netty underneath, can I use netty application code with spring boot?? Or is there a way using spring boot for tcp socket programming??
I was reading about spring cloud architecture and technologies (like eureka, hystrix circuit breaker) used to prevent your application from downtime because of failure of some of yours microservices. And all in all spring cloud suggests to use Spring Cloud Gateway as an entry point to all the micro services. So I am questioning myself how to provide fault tolerance of spring cloud gateway itself? As I see right now if this entry point will fail then all these technologies like eureka and hystrix circuit breaker will not be available since they are implemented on the level of spring cloud gateway. Now when spring cloud gateway is down - all clients will not be able to reach all services behind spring cloud gateway. So how to deal with such kind of situations?
I don't think this is directly related to Spring Cloud Gateway, to be honest. The question is more "How to deploy highly available Java application?" (SCG is a Spring application).
The answer depends on the platform you use.
Most of IAAS platforms provide their own infrastructure load balancers, like ALB / ELB in AWS.
PAAS platform usually include out of the box LB , e.g. Cloud Foundry or Kubernetes can do that for you.
DNS is probably not the best choice for the reasons you've described - TTL and client caching. Also, DNS doesn't really have a way to do a health check of an upstream service. So using DNS requires client-side load balancing, when the client needs to be smart and invalidate cache / retry if a request failed.
I am using Spring Cloud for Creating Microservice Architecture.
I was using the below feature from the Spring Cloud
Zuul – API gateway service that provides dynamic routing, monitoring, resiliency, security, and more -
Ribbon – Client side load balancer
Feign – Declarative REST client
Eureka – Service registration and discovery
Sleuth – Distributed tracing via logs
Zipkin – Distributed tracing system with request visualization.
Hystrix - Circuit Breaker, Fault Tolerance, Hystrix Dashboard for all API
Now Lets say if I have 100 microservices, then we need 100 servers to maintain each microservices. So I thought of using Kubernetes to solve this issue by deploying each microservices in a separate docker container, so now since Kubernetes takes care of microserivice health check, autoscaling, load-balancing so do I need to again use Ribbon, Eureka and Zuul.
Can anyone please help me on this
Even when you use Spring Cloud, 100 services do NOT mean 100 servers. In Spring Cloud the packaging unit is Spring Boot application and a single server may host many such Spring Boot applications. If you want, you can containerize the Spring Boot applications and other Spring Cloud infrastructure support components. But that is not Kubernetes.
If you move to Kubernetes, you don't need the infrastructure support services like Zuul, Ribbon etc. because Kubernetes has its own components for service discovery, gateway, load balancer etc. In Kubernetes, the packaging unit is Docker images and one or more Docker containers can be put inside one pod which is the minimal scaling unit. So, Kubernetes has a different set of components to manage the Microservices.
Kubernetes is a different platform than Spring cloud. Both have the same objectives. However, Kubernetes has some additional features like self healing, auto-scaling, rolling updates, compute resource management, deployments etc.
Just to add to saptarshi basu's answer, you might want to look at https://dzone.com/articles/deploying-microservices-spring-cloud-vs-kubernetes as it walks through the comparison and asks which responsibilities you might want to be handled by which components when using Spring cloud on kubernetes
I have a eureka server and some services, they register to the eureka and use a Feign to communicate with each other.
Every of such services is deployed into embedded tomcat container. Also I have some services which are executed as a demons by scheduled, they shouldn't be into tomcat container, but they also have to use a Feign to get data from some services.
By example I have a monitoring which is executed one time per day and checks some data got from another service by REST. That monitoring don't have to register in eureka cause it doesn't have api for input.
If I put #EnableFeignClients without #EnableEurekaClient, it won't work, but
if i put both of these annotations, service will be deployed into tomcat.
How could I do that without tomcat container?