1

Introducing Helidon Níma Using Virtual Threads to Achieve Simplicity and High Pe...

 1 year ago
source link: https://www.infoq.com/news/2022/09/introducing-helidon-nima/?itm_source=infoq&itm_medium=popular_widget&itm_campaign=popular_content_list&itm_content=
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Introducing Helidon Níma Using Virtual Threads to Achieve Simplicity and High Performance

Sep 16, 2022 2 min read

Under the umbrella of Project Helidon, Oracle introduced a new microservices framework based on virtual threads (JEP 425) called Helidon Níma. It is built from the ground up to achieve an easy-to-use programming model with outstanding performance. The technology preview is now available with the Helidon 4.0.0-ALPHA1 release for those who are interested in evaluating the latest Java technology. However, this is not yet production-ready.

Developers could achieve a certain level of throughput using the regular Helidon framework through Helidon MP or Helidon SE, but if the application needs to be more performant, their only choice is to revert to a reactive-based service. However, it is worth mentioning that writing, maintaining, and debugging reactive-based services is more challenging.

Helidon Níma uses virtual threads to carve out the issue, as blocking is cheap, and we can create millions of them. Thus, this offers a stellar, low-overhead, highly concurrent server while maintaining a blocking thread model. This will allow developers to write simple, debuggable, and maintainable code with less scaffolding. Consider the following example:

Blocking Code Reactive Code
private void one(ServerRequest req, ServerResponse res) {
    String response = callRemote(client());

    res.send(response);
}
private void one(ServerRequest req, ServerResponse res) {
    Single<String> response = client.get()
            .request(String.class);

    response.forSingle(res::send)
            .exceptionally(res::send);
}

Both blocking and reactive code accomplish the same goal; however, the reactive code is more cognitively demanding, has a steeper learning curve, and is less maintainable. This becomes more apparent with a slightly more complicated use case, as stated in the initial blog post written by Tomas Langer, architect at Oracle.

According to Langer, the primary focus of Heldion Níma was performance; therefore, it does produce results, as the following graph demonstrates.

1graph-1663271505131.png

This alpha release supports the following protocols:

  • HTTP/1.1 with pipelining — server and client
  • HTTP/2 server (prototype, known issues)
  • gRPC server (prototype, known issues)
  • WebSocket server (prototype)

Besides that, it supports the following features:

  • Tracing — using existing Helidon tracing implementations, such as Jaeger or Zipkin
  • Static content — from classpath or file system
  • Cross-Origin Resource Sharing (CORS)
  • Access Log
  • Observability endpoints (health, application information, config)
  • Fault Tolerance (Bulkhead, Circuit Breaker, Retry, and Timeout features)
  • HTTP/1.1 client
  • Testing

On top of these features, it also uses new Java language features like sealed classes and enhanced switch expressions.

Helidon Níma is a fully open-source framework and part of the Helidon codebase. Although the project Helidon is based on Netty, however, Dmitry Aleksandrov, software developer at Oracle, mentioned in his blog post writing:

The Helidon Níma web server intends to replace Netty in the Helidon ecosystem. It also can be used by other frameworks as an embedded web server component.

Developers who wish to evaluate Helidion Níma can leverage Tomas Langer's initial blog post and the source code hosted on this GitHub repository.

About the Author

A N M Bazlur Rahman

A N M Bazlur Rahman works at Contrast Security as a Sr. Software Engineer. He has more than ten years of professional experience in the software industry, predominantly in Java and Java-related technologies. Recently, he was named a Java Champion.

Outside of his regular work hours, he loves to mentor, write, speak at conferences, and contribute to open-source projects. He is the founder and current moderator of the Java User Group in Bangladesh. He has organized meetups and conferences to share Java-related knowledge with the community since 2013. He was named Most Valuable Blogger (MVP) at DZone, one of the most recognized technology publishers in the world. Besides DZone, he is an editor for the Java Queue at InfoQ, another leading technology content publisher and conference organizer, and an editor at Foojay.io, a place for friends of OpenJDK. In addition, he has published four books about the Java programming language in Bengali; they were bestsellers in Bangladesh.

He earned his bachelor's degree from the Institute of Information Technology, University of Dhaka, Bangladesh, in Information Technology, majoring in Software Engineering. He currently lives in Toronto, Canada.

Show more

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK