-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Http2 slower then http1 in high volume #2151
Comments
@ricardkollcaku We are working on fixes related to the observed behaviour. |
In the reproducible example you are using
While in the comment above you are specifying
Please clarify the scenario! Also with curl you are using |
Hi @violetagg Yes i have tested it with flatmap and concatmap. i thought maybe there was not working multiplexing with flatmap thats why i tested with concatmap. But the problem is not flatmap or concatmap is why http2 is performing worst than http1 |
@ricardkollcaku a fix is available in 1.0.20-SNAPSHOT. It will be great if you can test it. |
@violetagg is performing better than preview version but still outperformed by http1 and i think http2 should outperform http1 Github:ricardkollcaku/http2-test@f03d780 |
Hi @violetagg & @ricardkollcaku Out of curiosity, I just wanted to try myself the test. Your test looks good. HTTP2 is better than HTTP1.1 when we really use the persistent connection along with its multiplexing capabilities. If you keep creating new connections everytime as part of a request, HTTP2 might not be better and could be worse. Thats what this test seems to confirm. You also might want to monitor how many TCP connections you are creating by running this. If possible and you do not mind, please try this as well once. That is, we create persistent connections with HTTP2 for multiplexing.
In the flatMap - the default parallelism is only 256. Just increase it to 5000
Now see how many items are getting processed in a second. Once the test is done, try the same HTTP1.1, the results will not even be close. My point is - just by switching HTTP1.1 to HTTP2 will not help unless we use the multiplexing. |
Hi @kitkars |
@ricardkollcaku @samueldlightfoot Couple of things to notice. Issue 1:: I checked your gradle file. As far as I know you never used 1.0.20-SNAPSHOT because (I am a maven user. this comment is based on maven. I believe gradle should also behave more or less same) if you ever want to override the dependency webflux brings, you need to keep that dependency which you want to have , in this case reactor netty 1.0.20-SNAPSHOT, should be on the top of the list. The order of the dependencies matters!! https://stackoverflow.com/questions/31740785/why-order-of-maven-dependencies-matter Fix: Please fix this by using spring version latest 2.7.1 which brings the latest version of reactor-netty. So you do no longer need 1.0.20-SNAPSHOT anymore. Issue 2: We can appreciate the power of reactive programming/webflux etc only when we have more IO intensive tasks compared to CPU intensive tasks. Lets say you have more computation (finding a lot of permutations and combinations, sorting etc) here you will NOT see any major performance improvement just by using reactor. In this case traditional synchronous style code will perform better.
Additional Info: HTTP1.1 needs to make new TCP connections for every request. So, if you had noticed you would have created more than 250 TCP connections to get the work done. If you want to improve further, you have to create more connections. I am sure you will hit bottleneck at some point. HTTP2 on the other hand, you can have few TCP connections. Say 10. But you can get more work done by increasing the flatMap parallelism. Because, it will use same TCP connection to send all the requests. You can not increase the parallelism in HTTP1.1 like that. You can try and you will get connection closed error...etc. My aim here is not make HTTP2 look good somehow. HTTP2 is different and will perform better only when we have multiplexing. So for multiplexing, increase your parallelism to 10000 or more and see. Whatever HTTP1.1 does with 250 / 500 TCP connections, HTTP2 can do with 1 or 2 TCP connections. |
@kitkars Maybe my expectation is wrong but should not http2 beat http1 when it is without delay? |
@ricardkollcaku no keep-alive so every single request is establishing new connection, right? That's both for HTTP1 and HTTP2 but it seems HTTP2 is a bit heavier on establishing connection, it's not supposed to be used like that, the whole point of HTTP2 is multiplexing |
no in http2 im trying to get the benefit of multiplexing. so what i expect is that http2 to be better as it uses the same connection, meanwhile in the result is not better. |
@ricardkollcaku so just set connection pool to 1 in both HTTP1 and HTTP2 - even on local machine HTTP2 provides better results. However, if you want meaningful test you should run client and server on different machines to have real TCP connection, not just loopback(localhost). The benefit of HTTP2 is that it may provide same level of concurrency as HTTP 1.1 using much less connections - and connection is actually expensive resource, that's why HTTP2 is better. It just has less overhead on keeping bunch of connections and can provide better throughput |
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:
My client is another spring boot 2.6.6
and looks like
Using default protocol i can process up to 23,959 requests per second
with H2C protocol i can barely reach 16.000request per second
The text was updated successfully, but these errors were encountered: