quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.8k stars 2.68k forks source link

Performance decrease w/Quarkus 1.5.0, Mongo Extension, Mutiny #10184

Closed csotiriou closed 3 years ago

csotiriou commented 4 years ago

It seems that there is a considerable throughput performance hit (approx 40%) when upgrading one microservice from an older stack using Quarkus to a newer one.

Older stack:

Newer stack:

The microservice uses MongoDB for caching. Steps:

Our older stack was using RxJava, and was transforming the CompletionStages to Singles. The new stack uses Mutiny, and also exposes Mutiny Interfaces. In both cases, we use RestEasy interfaces, we are not using Reactive Routes.

On a performance load test lasting for approximately 30 minutes each, I have seen the following differences in performance:

The old stack's CPU load is something like the following

screenshot_2020-06-22_at_4 06 41_pm

The new stack's behaviour is totally different, however. Screenshot 2020-06-22 at 4 06 57 PM

It seems observed that the CPU consumption went up by 40%, thus losing throughput in the process. Both tests were conducted on a microservice using the same amount of RAM and CPU limits.

Tests already done to debug this:

quarkusbot commented 4 years ago

/cc @loicmathieu

csotiriou commented 4 years ago

Hello,

Just to add to this issue, I switched to the synchronous client in MongoDB, and I still faced problems. I decided to make another test:

I was surprised to see that using RxJava, without any other change in the code, my performance returned back to normal.

I am led to believe that perhaps Mutiny itself (regardless of how it's used inside the Mongo extension) is the real issue here.

gsmet commented 4 years ago

There is an ongoing discussion with @johnaohara on Zulip. Hopefully, this will provide useful feedback.

cescoffier commented 4 years ago

Do you have context propagation enabled?

csotiriou commented 4 years ago

Yes, we use the smallrye context propagation dependency.

cescoffier commented 4 years ago

Thanks for the very quick response. @johnaohara, that can explain the overhead due to the numbers of interception.

cescoffier commented 4 years ago

(Even on a simple: Uni.createFrom(item) you have 2 interceptions.)

csotiriou commented 4 years ago

That would explain why even after ditching the asynchonous mongo driver still creates problems when even synchronous results are mixed with plain Uni.createFrom().

I would like to clarify that I always had context propagation enabled even with the old implementation that used RxJava (no performance issues there).

cescoffier commented 4 years ago

yes, but mutiny enables it automatically, RX does not (it requires an additional dependency).

csotiriou commented 4 years ago

I understand. Does this mean that if I was including the context propagation extra dependency for RXJava I would see the same performance hit as with mutiny?

Or this is something that can be improved on the side of mutiny/context propagation library ?

cescoffier commented 4 years ago

In the mutiny side, definitely - especially for Uni. It’s actually planned. It would be great to have a way to reproduce your case, so I can test the improvements.

geoand commented 4 years ago

Did we come to a conclusion on this one? Has it since been remedied?

cescoffier commented 4 years ago

We have done some improvements in Mutiny. The context-propagation issue is still valid I guess.

geoand commented 3 years ago

@csotiriou would it be possible to try Quarkus 1.12 and / or the Quarkus Snapshots to see if the issue still persists?

csotiriou commented 3 years ago

@geoand, it seems that the issue is fixed, I have experienced no more crashes and strange behaviour.

geoand commented 3 years ago

That's awesome, thanks!