spring-cloud / spring-cloud-openfeign

Support for using OpenFeign in Spring Cloud apps
Apache License 2.0
1.18k stars 758 forks source link

Performance discussion about default openfeign client config #955

Closed raizoor closed 7 months ago

raizoor commented 7 months ago

Resume Discussion about default client performance of spring-cloud-openfeign

Versions Java 17 Springboot 2.7.18 spring-cloud-dependencies 2021.0.8

Scenario

During a performance tests in a microservice that contain a 3 feign clients, it was possible to saw a high GC usage (i.e. high cpu utilization as well) in two methods, as we can see at profiler image bellow

profiler-onlySpringCloudFeign

We have a high tps scenario here - 110tps. The situation was absolutely unstable and we has too much resources to handle with that.

After studying the issue I decided to use lib {io.github.openfeign:feign-httpclient:11.8} and do a new evaluation. To my surprise, we had a significant improvement in resource usage, as feign started using other classes and no longer generated as many objects, as shown bellow

springCloudFeign-httpClient

So, my question: Is this the expected behavior of the default implementation or is there something I did incorrectly, because we've a big difference here.

Code

I don't have a high customization clients, only a custom decoder and base64 auth, as bellow

@FeignClient(value = "...", url = "...",
        configuration = ClientConfig.class)
public interface .. {

    @PostMapping("..")
    SpecificObject post(
            @RequestHeader("..") Boolean ..,
            @RequestBody SpecificObject ..
    );
}

image

basicAuthInterceptor

OlgaMaciaszek commented 7 months ago

Hello @raizoor, the implementation that seems to be causing the issue is (Client.Default) is part of the OpenFeign/feign project and not Spring Cloud OpenFeign. Please create an issue there to start a discussion.

raizoor commented 7 months ago

Thks @OlgaMaciaszek . --> https://github.com/OpenFeign/feign/issues/2267