BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

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

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

Bookmarks

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.

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

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Reactive code example

    by Nirmalya Sengupta,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    "however, the reactive code is more cognitively demanding, has a steeper learning curve, and is less maintainable. "

    Why do keep dumbing down good approaches to coding, by propagating such thoughts? Is the Reactive example really cognitively "demanding"?

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT