'How to use http2 in Feign for better performance RPC?

A new project consider use Spring Cloud build micro service. But we have many inner RPC call within services.
For performance, how to upgrade Feign support http2?

There are gRPC has give a great example for high performance by http2 but our project based on JVM and Feign and relative annotation is good enough for interface definition.

So, I'm first consider Feign support http2 without SSL to speed up RPC.

Hope there are benchmark on http2 if someone has done.

Thanks.



Solution 1:[1]

To use http/2 with feign you just need to replace the Http client Bean with a client that prefers http/2.

With default HttpClient (as opposed to OkHttp), you can just add this as a bean, and feign should use it, or you can build it into the feignClient:

HttpClient client = HttpClient.newBuilder()
      .version(Version.HTTP_2)
      .build();

ref: https://openjdk.java.net/groups/net/httpclient/intro.html

The OkHttp Client may have http/2

I think you would also have to enable http/2 on the server with:

server.http2.enabled: true

This should allow it to receive incoming requests with http/2.

https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#application-properties.server.server.http2.enabled

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jordan Stewart