Skip to content

Http2 slower then http1 in high volume #2151

@ricardkollcaku

Description

@ricardkollcaku

Im trying to do some benchmarking with spring boot using http1 and http2
and i see i weird behaviour.

Im using for client and server
SPRING BOOT 2.6.6
Java 17
Both using webflux

http2 is bit slower than http1 looks like is not taking advantage of single tcp connection with multiplexing.

you can find the project in https://github.com/ricardkollcaku/http2-test

My Server:
I have enabled http2 in properties :
server.http2.enabled= true
and in using curl

curl -I --http2 http://localhost:8080/sms-request/test
i get:

HTTP/1.1 101 Switching Protocols
connection: upgrade
upgrade: h2c

HTTP/2 200 
content-type: text/plain;charset=UTF-8
content-length: 10

My client is another spring boot 2.6.6
and looks like


 WebClient webClient = WebClient.create().mutate()
       .clientConnector(
            new ReactorClientHttpConnector(
                HttpClient.create().protocol(HttpProtocol.H2C)))
        .baseUrl("http://localhost:8080/sms-request/test").build();

    Flux.range(1, 100000000)
        .concatMap(integer -> webClient.get().retrieve().bodyToMono(String.class))
      .subscribe()
    ;

Using default protocol i can process up to 23,959 requests per second
with H2C protocol i can barely reach 16.000request per second

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions