Loadbalancing with feign and kubernetes

4/1/2019

I am using feign, through spring feign and load balancing seems off. I have one instance of service A and 2 instances of service B. Service A calls service B through a feign client. I plotted incoming requests on service B and they all seem to hit the same node and after some time switch to the other node and all hit that node again. Not really what i want. I use kubernetes DNS to get a node. Am i missing some part of the puzzle? does feign get the ip and use that for a while?

I am using the latest spring cloud, but am using httpclient instead of the standard client.

My spring feign annotation looks like:

@FeignClient(name = "serviceB", url="http://serviceb:8080")

where serviceb is the name of the service in kubernetes DNS.

-- Geert Olaerts
feign
kubernetes
spring-boot
spring-cloud-feign

1 Answer

4/1/2019

Do you mean Pod by node?

To test your theory, you can continuously make a call to serviceb and bring one of the pods abruptly and see if the other pod gets the request!

k8s seems to follow random algorithm for load balancing - so there is a chance that it might send the request to the same pod which I also have seen when there is no enough request. When you can send multiple concurrent requests & continuously for certain duration, I have seen requests are distributed across all the pods.

-- KitKarson
Source: StackOverflow