Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Ali Lei: what impact will the establishment of the Reactive Foundation have on the development approach?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Author | Zhao Yuying

Recently, the Linux Foundation announced the establishment of the Reactive Foundation. Reactive should be no stranger to developers, especially Node.js developers, but not many people really understand and realize the impact of this on the way they develop. In this article, InfoQ had the honor to conduct an exclusive interview with Alibaba's senior technical expert, Lei Juan, who promoted Alibaba to become a start-up member of the foundation, to further fully understand the background of the establishment of the Reactive Foundation and its promotion to the development of the development mode.

What is the Reactive Foundation?

Recently, the Linux Foundation announced the launch of the Reactive Foundation, which aims to accelerate the development of the architecture for building next-generation web applications. The foundation is composed of Alibaba, Facebook, Lightbend, Netifi and Pivotal and other initial members. Involves successful open source specifications Reactive Streams and RSocket, as well as programming language implementations.

Although the Reactive Foundation has just been established, Reactive, which developers often call responsive programming, has been developed for many years. Reactive has been in the public eye since 2011, when Microsoft built Reactive support, called Reactive Extensions, into .net Framework 4.0. In 2013, RxJava was released, which is well known to Java developers. Next, Reactive entered a stage of rapid development, with the emergence of RxRuby, RxJS (interested developers can visit http://reactivex.io/) and so on.

In the process of technological development, major manufacturers have begun to follow, such as Reactive Declaration, Lightbend's Akka, Spring's Reactor project, Spring Reactive Web and so on. Emerging micro-service frameworks are basically Reactive, such as Vert.x,Micronaut and so on. Many developers understand Reactive as a development package, such as integrating RxJava in Android and Reactive Web in Spring. However, the emergence of RSocket extends Reactive to distributed scenarios, so that all applications can be concatenated through Reactive and RSocket.

As for why Reactive is quickly accepted by developers, two typical values are as follows:

Non-blocking and high concurrency: Reactive is based on asynchronous message communication, similar to Node.js 's Event Loop design, such applications have no synchronous blocking, and the system throughput is high, which is equivalent to improving system performance. In the past, developers used thread pool to achieve concurrency, but now through the message model of Actor, the waiting of acquisition threads is eliminated, a large number of thread switching is reduced, and the utilization of CPU is improved. In addition, non-blocking and high concurrency are particularly important for customers on the cloud. Higher CPU utilization and higher QPS directly mean fewer bills. Functional programming paradigm: functional programming has been more and more accepted by developers, with the advantages of thread safety and efficient execution, but connecting these functions together requires certain paradigms and related frameworks, which is what Reactive does, such as standard Reactive Streams specifications, related development frameworks RxJava, Reactor, etc., which can make functional programming easier, and the code is still in a unified style and easy to read at the same time. Code Review is also very easy. It's like having Servlet specification in Java and many Web frameworks to simplify Web application development. If you see filter, map, flatMap, subscribe and other function calls in the code, it is basically the embryonic form of Reactive.

The emergence of the Reactive Foundation will undoubtedly maximize the value of this technology in the future. According to the Thunder Volume, the whole thing started at the end of 2018. At that time, Alibaba was working with Netifi, Pivotal and FaceBook to develop RSocket-related open source products. Although the word Reactive is often mentioned, few developers are known, and several companies feel the need to let more developers know about the technology, so they have the idea of setting up foundations. The Thunder Scroll says:

The whole preparation process took less than half a year, mainly thanks to the support of Netifi and Pivotal. Although many people do not know Reactive very well, many people in Linux Foundation still have a good grasp of the technical direction, so the establishment of the Reactive Foundation was completed in less than half a year.

Most developers are familiar with these start-up member companies. For example, Spring Framework, which is popular in the field of micro-services, is the maintenance and development of Pivotal. After that, these companies will jointly participate in the work of the foundation. Leijun said that Pivotal is mainly committed to the integration of RSocket and Spring ecology; Netifi is the core development team of RSocket SDK and has its own RSocket Broker commercial products; Facebook is also committed to the development of RSocket, in which RSocket-cpp and RSocket-js are mainly maintained by Facebook engineers, while Facebook is actively promoting the landing of RSocket. Lightbend may be unfamiliar to many developers, but it is not only the support company behind the Scala language, but also the forerunner of responsive programming, supporting the development of the Akka platform; Alibaba mainly focuses on the development of RSocket, pushing distributed development to the next level based on Reactive and RSocket, while actively developing internal RSocket products that will provide services for customers on the cloud.

The starting point of the establishment of the Reactive Foundation is to promote the development of Reactive Streams and RSocket, which has great guiding significance for the subsequent development of Reactive products, and ensures that these Reactive products are compatible with API and protocols, which is very important for the final developers.

Specifically, the Reactive Foundation will first promote the implementation of the RSocket 1.0 specification, including the development of SDK in various languages, which is a heavy and tedious task, which needs to be coordinated with all kinds of languages, testing, performance and so on. For developers, the Reactive Foundation will bring a lot of value, such as continuous promotion of specification evolution, SDK development, documentation, conference support, etc., as well as an introduction window for developers from various Reactive products.

How does Reactive change the way you develop?

In fact, the emergence of Reactive has brought many impacts to the existing architecture, such as event-driven design, streaming, Service Mesh, no network dependency, security and so on. Accordingly, the development method will change accordingly, and more and more frameworks begin to fully support Reactive, such as Spring WebFlux, Spring Data Reactive Repository, etc.; database operations have been fully Reactive through R2DDBC; various NoSQL products, such as Redis, MongoDB, etc., already support Reactive;RPC and HTTP REST API. Under the influence of RSocket, developers' understanding of distributed communication may also be changed. Among these changes and shocks, the most typical are coding and distributed communication.

Coding: our previous procedural code will be replaced by functional programming and Reactive paradigm, before a large number of if else, null judgment, for loop, try/catch, etc., will be greatly reduced, replaced by a variety of standard operations of Reactive, simpler and clearer, and the amount of code will be significantly reduced. Distributed communication: before distributed development, we paid great attention to communication details and concurrent processing, which is the core. With the intervention of Reactive and RSocket, the development threshold will be reduced to a minimum. You hardly need to care about the underlying details of communication, concurrent thread processing, open circuit protection, etc., all these RSocket under Reactive will solve for you, you may only use relational interface design and data serialization. Today's applications are increasingly pursuing the ultimate performance, such as CPU, GPU and FPGA. If there is no matching efficient communication protocol, then the performance will be discounted a lot. RSocket can help you do all this, and it is simpler and more elegant. We will introduce RSocket later.

It can be said that even if developers do not pay attention to Reactive at this stage, this undercurrent is already surging. At the same time, there are many technologies that integrate Reactive and Java in the industry, which make Reactive more mature and stable:

Reactive framework: RxJava, Reactor, Akka, Kotlin Coroutines & FlowWeb framework: Spring WebFlux, Vert.x, Micronaut, Helidon data layer: Spring Data Reactive, support for database, Redis, Cassandra, MongoDB and other communication layers: RSocket, Reactor Netty, Reactor Aeron,Reactive Dubbo integration: Reactor Kafka, Reactor RabbitMQ,RocketMQ, etc.

Nowadays, more and more developers are used to developing applications based on cloud platform. As mentioned above, the development of Reactive will also play an important role in the development of cloud native domain. In the interview, Thunder revealed that cloud natively allows applications to remain neutral and independent of the underlying architecture, so that they can run on the underlying architectures of different cloud vendors. However, this approach does not solve the problem of how to communicate between applications. Although there is collaboration based on API, it does not make specific requirements for API, especially asynchronous communication based on messages.

At present, the most common inter-application communication is RPC and HTTP REST API. Both of them have no problem with request/response communication at all. HTTP REST API just has some performance problems, but the overall situation is fine. However, these technologies are also moving closer to Reactive, such as Spring's RestTemplate to WebClient, and gRPC also has a corresponding Reactive gRPC. Traditional RPC is a bit inadequate for new architectural designs, such as Streaming, Event Driven, IoT, and two-way communication, which is what RSocket is good at.

After a very long demonstration of the RSocket protocol, of course, it also draws lessons from the ideas of other protocols, and finally forms the version 1.0.0 that developers see so far. RSocket protocol can be said to be a perfect version based on binary asynchronous message communication, overcoming some problems in previous protocol design, such as the conversion of Client/Server to role peer-to-peer; Pub/Sub is adjusted to a more flexible way of separating Request/Stream; metadata and data, providing more flexible message routing and message encoding; the transport layer is pluggable and supports TCP, WebSocket, UDP/Aeron, RDMA and so on. Multilingual access is supported at the same time, such as Java, Kotlin, Node, C++, Golang, Python, Rust, etc.

At present, RSocket has been widely supported. Spring Framework will have built-in RSocket,Spring Boot in version 5.2, version 2.2.0 will also support RSocket first, and other Spring Cloud Gateway,Spring Security will support RSocket. As Michael Dolan, vice president of strategy at the Linux Foundation, said, Reactive's message-driven approach ensures the resilience, scalability, and responsiveness required by cloud native applications, all independent of its underlying infrastructure. In other words, with the features of Reactive, developers do not need to rely on cloud vendors or Infra layers to achieve the resilience, scalability, and responsiveness described in the Reactive manifesto. It can be said that cloud native focuses on the external aspects of applications, such as packaging and deployment, running environment, monitoring, etc., while Reactive pays more attention to the interior of applications, such as more efficient code running, more natural and smooth communication between applications, a certain degree of flexibility and self-recovery.

Alibaba's Reactive practice and Open Source Plan

As a start-up member of the Reactive Foundation, Alibaba has always given the outside world the impression that he has used a large number of Java programming languages internally and accumulated a large number of Java technology stacks. However, according to the Thunder Volume, some products within Alibaba began to be Reactive very early. For example, Dubbo, which developers all know, is doing the integration of Reactive and RSocket. However, there are still many problems to be solved in the process of Reactive, such as SDK's BUG, which adapts to various internal architectures. According to Thunder Scroll, the biggest problem is how to adjust blocking to non-blocking, such as database operations, non-asynchronous RPC calls.

As a member of the foundation, Alibaba will share the experience of internal Reactive with developers in need, and his main contribution will be to RSocket, mainly the integration of distributed Reactive and cloud, because Alibaba has contributed a lot in security, performance testing and SDK development, while combining cloud features and multi-tenant support to make it easier for cloud users to use. Internally, Alibaba also actively promotes the Reactive of products and adds support for RSocket.

At the same time of technological innovation, Alibaba is also trying to solve the problem of cost. If developers have listened to the RSocket speech at QCon 2019 Beijing Conference, they may help enterprises implement micro-services by developing RSocket. In the 40000RPS scenario, Istio costs US $3495 per month, while Netifi costs US $388 per month, with a 10-fold improvement in performance, which is undoubtedly very attractive to any enterprise. It has been half a year since that speech, and the new RSocket Broker has supported multi-tenancy rather than an exclusive approach, which can reduce costs by another 50% to 70%, paying less than $200 a month in 40,000 RPS scenarios.

Although Alibaba's Reactive process is still in progress, the cost value it brings has been reflected. Thunder roll said that mainly after the synchronous to asynchronous, the overall performance of the application improved, the direct change is to spend less, which should be the same for other users.

Concluding remarks

For Node.js developers, it is almost all Reactive, but for Java developers, especially the back end, it is still in the early stage. The biggest problem encountered at present is that Reactive requires users to adjust the code, which is the biggest trouble, and developers need to be familiar with, understand and use it for a long time. And the relevant integration is not perfect, although Spring 5.0 already includes Reactive, but not all of them are supported. Thunder Volume said that Spring 5.2 will fully support Reactive from the bottom, and once this version is officially released, developers will be able to appreciate the convenience of Reactive and RSocket development.

In terms of open source, Alibaba is developing RSocket Broker products, hoping to launch soon, so that more developers can make better use of Reactive, help cloud native applications solve asynchronous communication problems, and make all organizations and developers more simple, efficient, secure and greatly reduce costs.

The author introduces:

Thunder Roll, a senior technical expert of Alibaba, currently works in Alibaba's Silicon Valley office. Alibaba has worked for more than 10 years, has 20 years of Java development experience, and has participated in a number of internal projects, from logistics, Wangpu to international middleware. At present, the main research methods are Reactive and RSocket, which bring Reactive and RSocket to the application development to build a more simple and efficient architecture design. Thunder Scroll is also a developer of RSocket, focusing on the development of RSocket Broker.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report