Search code examples
springkubernetesmicroservicesload-balancingservice-discovery

Client side spring cloud load balancer use cases


I'm trying to understand concept of client side load balancer architecture (i.e. eureka + spring cloud api gateway + ribbon). Assuming we have kubernetes env where is native discovery service and load balancer why would we use client side LB and eureka. Do you have any idea/any use case in mind or maybe this approach is useful with different environment?

Architecture diagram


Solution

  • It depends on your use-case. There can be situations where you need to directly use Eureka server registry and Eureka client discovery offered by Spring Cloud Netflix. Ribbon is the client side load balancer provided by Spring Cloud Netflix. In my experience, it is not impossible to use Eureka in any environment. It can be your local data centre or cloud infrastructure. However when it comes to deployment environment, there are so many alternatives for us to achieve the server registry mechanism. Sometimes those alternatives are the best solutions. I will give you an example below…

    If you host your application in your local server (Local data centre)

    Now in this scenario you can use Eureka and continue your server registry and discovery mechanism. (That is not the only way. I mentioned Eureka for this scenario because it would be a good use case for it)

    If you host your application in AWS infrastructure

    The AWS environment gives you lots of benefits and services such that you can forget the burden of maintaining and implementing Eureka. You can achieve simply the same behaviour by AWS load balancers, AWS target groups and even more by adding AWS auto scaling groups. In AWS it self there are so many other ways to achieve this as well. Long story in short that for your scenario, you can continue using the power of Kubernetes and get the privilege unless you have a specific reason to use Eureka and put a large effort to implement it. You should select what suits the best depending on time, effort, maintainability, performance etc. Hope this helps for you to get an idea. Happy coding!

    Spring micro service K8s:

    This sample application is to test spring apps service discovery with spring-cloud-kubernetes in K8 env. For other envs you can use Eureka(which is actually the default).

    For more information refer to this document.