hashgraph / hedera-mirror-node

Hedera Mirror Node archives data from consensus nodes and serves it via an API
Apache License 2.0
122 stars 108 forks source link

Improve performance of Mirror Archive Node by introducing virtual threads #7566

Closed IvanKavaldzhiev closed 5 months ago

IvanKavaldzhiev commented 7 months ago

Definition

With the recent update to JDK 21, we now have an access to the latest features in Java, including Java virtual threads. We can migrate the Spring WebFlux architecture that we currently have in hedera-mirror-web3 to Spring MVC that uses blocking calls. Then we can incorporate the usage of virtual threads and potentially speed up the Archive Nodes.

Abstract

We can improve Archive Node performance and scalability by using virtual threads.

Motivation

We can further increase Archive Node performance, so that we improve user experience and avoid possibility of hitting the rate limits.

Rationale

We need to align hedera-mirror-web3 module to start utilizing virtual threads and measure the performance difference after the changes. As part of the changes we should migrate Spring WebFlux to Spring MVC approach in our controllers.

Backwards Compatibility

No impact

Security Implications

None

References & Dependencies

steven-sheehy commented 7 months ago

See hedera-mirror-rest-java module which has already made this transition in https://github.com/hashgraph/hedera-mirror-node/pull/7488. Special care needs to be taken with the use of ThreadLocal. Perhaps we can try it with ScopedValue by opting into preview feature if we find ThreadLocal is a bottleneck.