Spring Cloud Ribbon client-side load balancer

5/25/2020

I have a question for load balancing in scope of Spring and Ribbon.

I have Microservices architecture with several services. Let's say services: A, B, C and D. All of the services are deployed in the cloud. In front of the services stays LB that forwards requests to the corresponding service.

All of the services are implemented in Spring Boot. Docker images are created per each service.Each service is containerised. In my local setup I am able to start all of my services in my local kubernetes cluster. For example:

kubectl get deployment

will result in:

NAME                    READY   UP-TO-DATE   AVAILABLE   AGE
A                        1/1        1            1        9h
B                        2/2        2            2        59m
C                        1/1        1            1        9h
....

Running in K8S service B can access service A, C or any other service in the namespace with:

 public String getResponseFromService() {
    return this.restTemplate.getForObject("http://service-a:8080/deals", String.class);
}

If I have N number of instances of service A, a round-robin rule by default is activated and random server is fetched each time when node B invokes service A.

Question: Does it mean that k8s itself acts as Load Balancer and redirects the requests that are coming from node B to service A to one of the instances?

If the above is true, why I at all need Ribbon client LB. I know that it uses discovery client in order to check with k8s which are registered services in service registry, but if I do not care about the registry do I need the ribbon at all?

I need several instances per each service and communication between services through single endpoint (as example above).

Apologies for the question but I am pretty new to Spring Cloud Kubernete. I read a lot but still can not get this part.

Thanks in advance!

-- user2739823
kubernetes
spring-boot
spring-cloud
spring-cloud-feign
spring-cloud-netflix

0 Answers