Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netty and Project Loom

I may be wrong, but as far as I understand, the whole Reactive/Event Loop thing, and Netty in particular, was invented as an answer to the C10K+ problem. It has obvious drawbacks, as all your code now becomes Async, with ugly callbacks, meaningless stack traces, and therefore hard to maintain and to reason about.

Go's language with goroutines was a solution, now they can write Sync code and also handle C10K+. So now Java comes up with Loom, which essentially copies the Go's solution, soon we will have Fibers and Continuations and will be able to write Sync code again.

So the questions are:

  1. When the Loom is released in production, doesn't it make Netty kinda obsolete?

  2. If we have Fibers and Continuations in Java, can we write nice Sync code and be ok with C10K+ without Netty?

  3. Are there any advantages, for performance or solving C10K+, in writing Async code and using Netty, after production release of Loom?

I understand that Netty is more than just Reactive/Event Loop framework, it also has all the codecs for various protocols, which implementations will be useful somehow anyway, even afterwards.

like image 569
bxq Avatar asked Oct 02 '19 17:10

bxq


People also ask

What is Project Loom and how does it work?

Project Loom features a lightweight concurrency construct for Java. There are some prototypes already introduced in the form of Java libraries. The project is currently in the final stages of development and is planned to be released as a preview feature with JDK19. Project Loom is certainly a game-changing feature from Java so far.

What is Netty?

for rapid development of maintainable high performance protocol servers & clients. Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP and UDP socket server.

Is Netty really'quick and easy'?

'Quick and easy' doesn't mean that a resulting application will suffer from a maintainability or a performance issue. Netty has been designed carefully with the experiences earned from the implementation of a lot of protocols such as FTP, SMTP, HTTP, and various binary and text-based legacy protocols.

What makes Netty different from other protocols?

Netty has been designed carefully with the experiences earned from the implementation of a lot of protocols such as FTP, SMTP, HTTP, and various binary and text-based legacy protocols. As a result, Netty has succeeded to find a way to achieve ease of development, performance, stability, and flexibility without a compromise.


1 Answers

I'm focusing on the reactive parts of Netty because those you seem to mostly want to address answering on a general level:

Currently reactive programming paradigms are often used to solve performance problems, not because they fit the problem. Those should be covered completely via project Loom.

However, some problems may remain where the reactive programming approach makes sense and is more straight forward to read than imperative code. Reactive frameworks are typically stream oriented and are well suited to combine elements and operations on different entity/data streams. They also provide straight forward local event bus solutions with their provider/subscriber model. In such cases the reactive model might still be the best choice, performant and more readable than an imperative approach. But indeed, project loom should make all the "misuse" due to lack of better support in the native language structures obsolete.

like image 81
Frank Hopkins Avatar answered Sep 19 '22 12:09

Frank Hopkins